effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
Prims.Tot
val shift_left (#n: pos) (a: uint_t n) (s: nat) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let shift_left (#n:pos) (a:uint_t n) (s:nat) : Tot (uint_t n) = from_vec (shift_left_vec #n (to_vec #n a) s)
val shift_left (#n: pos) (a: uint_t n) (s: nat) : Tot (uint_t n) let shift_left (#n: pos) (a: uint_t n) (s: nat) : Tot (uint_t n) =
false
null
false
from_vec (shift_left_vec #n (to_vec #n a) s)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.UInt.uint_t", "Prims.nat", "FStar.UInt.from_vec", "FStar.BitVector.shift_left_vec", "FStar.UInt.to_vec" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1)) let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0) val to_vec_lemma_1: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:nat -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) val from_vec_aux: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> s2:nat{s2 < s1} -> Lemma (requires True) (ensures (from_vec #s2 (slice a 0 s2)) * pow2 (n - s2) + (from_vec #(s1 - s2) (slice a s2 s1)) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n)) = ((from_vec #s2 (slice a 0 s2)) * pow2 (s1 - s2) + (from_vec #(s1 - s2) (slice a s2 s1))) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n))) val seq_slice_lemma: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> t1:nat{t1 >= s1 && t1 <= n} -> s2:nat{s2 < t1 - s1} -> t2:nat{t2 >= s2 && t2 <= t1 - s1} -> Lemma (equal (slice (slice a s1 t1) s2 t2) (slice a (s1 + s2) (s1 + t2))) val from_vec_propriety: #n:pos -> a:bv_t n -> s:nat{s < n} -> Lemma (requires True) (ensures from_vec a = (from_vec #s (slice a 0 s)) * pow2 (n - s) + from_vec #(n - s) (slice a s n)) (decreases (n - s)) val append_lemma: #n:pos -> #m:pos -> a:bv_t n -> b:bv_t m -> Lemma (from_vec #(n + m) (append a b) = (from_vec #n a) * pow2 m + (from_vec #m b)) val slice_left_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a 0 s) = (from_vec #n a) / (pow2 (n - s))) val slice_right_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a (n - s) n) = (from_vec #n a) % (pow2 s)) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:nat{p < n} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:uint_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val pow2_nth_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - p - 1 ==> nth (pow2_n #n p) i = true) /\ (i <> n - p - 1 ==> nth (pow2_n #n p) i = false)) [SMTPat (nth (pow2_n #n p) i)] val one_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b)) let logor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b)) let lognot (#n:pos) (a:uint_t n) : Tot (uint_t n) = from_vec #n (lognot_vec #n (to_vec #n a)) (* Bitwise operators definitions *) val logand_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logand a b) i = (nth a i && nth b i))) [SMTPat (nth (logand a b) i)] val logxor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logxor a b) i = (nth a i <> nth b i))) [SMTPat (nth (logxor a b) i)] val logor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logor a b) i = (nth a i || nth b i))) [SMTPat (nth (logor a b) i)] val lognot_definition: #n:pos -> a:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (lognot a) i = not(nth a i))) [SMTPat (nth (lognot a) i)] (* Two's complement unary minus *) inline_for_extraction let minus (#n:pos) (a:uint_t n) : Tot (uint_t n) = add_mod (lognot a) 1 (* Bitwise operators lemmas *) (* TODO: lemmas about the relations between different operators *) (* Bitwise AND operator *) val logand_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand #n a b = logand #n b a)) val logand_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logand #n (logand #n a b) c = logand #n a (logand #n b c))) val logand_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a a = a)) val logand_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (zero n) = zero n)) val logand_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (ones n) = a)) (* subset_vec_le_lemma proves that a subset of bits is numerically smaller or equal. *) val subset_vec_le_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_subset_vec #n a b) (ensures (from_vec a) <= (from_vec b)) (* logand_le proves the the result of AND is less than or equal to both arguments. *) val logand_le: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand a b) <= a /\ (logand a b) <= b) (* Bitwise XOR operator *) val logxor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logxor #n a b = logxor #n b a)) val logxor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logxor #n (logxor #n a b) c = logxor #n a (logxor #n b c))) val logxor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a a = zero n)) val logxor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (zero n) = a)) val logxor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (ones n) = lognot #n a)) private let xor (b:bool) (b':bool) : Tot bool = b <> b' private val xor_lemma (a:bool) (b:bool) : Lemma (requires (True)) (ensures (xor (xor a b) b = a)) [SMTPat (xor (xor a b) b)] val logxor_inv: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (a = logxor #n (logxor #n a b) b) val logxor_neq_nonzero: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (a <> b ==> logxor a b <> 0) (* Bitwise OR operators *) val logor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logor #n a b = logor #n b a)) val logor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logor #n (logor #n a b) c = logor #n a (logor #n b c))) val logor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a a = a)) val logor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a (zero n) = a)) val logor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a (ones n) = ones n)) (* superset_vec_le_lemma proves that a superset of bits is numerically greater than or equal. *) val superset_vec_ge_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_superset_vec #n a b) (ensures (from_vec a) >= (from_vec b)) (* logor_ge proves that the result of an OR is greater than or equal to both arguments. *) val logor_ge: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logor a b) >= a /\ (logor a b) >= b) (* Bitwise NOT operator *) val lognot_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (lognot #n (lognot #n a) = a)) val lognot_lemma_1: #n:pos -> Lemma (requires True) (ensures (lognot #n (zero n) = ones n)) (** Used in the next two lemmas *) private val index_to_vec_ones: #n:pos -> m:nat{m <= n} -> i:nat{i < n} -> Lemma (requires True) (ensures (pow2 m <= pow2 n /\ (i < n - m ==> index (to_vec #n (pow2 m - 1)) i == false) /\ (n - m <= i ==> index (to_vec #n (pow2 m - 1)) i == true))) [SMTPat (index (to_vec #n (pow2 m - 1)) i)] val logor_disjoint: #n:pos -> a:uint_t n -> b:uint_t n -> m:pos{m < n} -> Lemma (requires (a % pow2 m == 0 /\ b < pow2 m)) (ensures (logor #n a b == a + b)) val logand_mask: #n:pos -> a:uint_t n -> m:pos{m < n} -> Lemma (pow2 m < pow2 n /\ logand #n a (pow2 m - 1) == a % pow2 m) (* Shift operators *)
false
false
FStar.UInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val shift_left (#n: pos) (a: uint_t n) (s: nat) : Tot (uint_t n)
[]
FStar.UInt.shift_left
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> s: Prims.nat -> FStar.UInt.uint_t n
{ "end_col": 46, "end_line": 448, "start_col": 2, "start_line": 448 }
Prims.Tot
val zero_extend (#n: pos) (a: uint_t n) : Tot (uint_t (n + 1))
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let zero_extend (#n:pos) (a:uint_t n): Tot (uint_t (n+1)) = from_vec (zero_extend_vec (to_vec a))
val zero_extend (#n: pos) (a: uint_t n) : Tot (uint_t (n + 1)) let zero_extend (#n: pos) (a: uint_t n) : Tot (uint_t (n + 1)) =
false
null
false
from_vec (zero_extend_vec (to_vec a))
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.UInt.uint_t", "FStar.UInt.from_vec", "Prims.op_Addition", "FStar.UInt.zero_extend_vec", "FStar.UInt.to_vec" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1)) let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0) val to_vec_lemma_1: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:nat -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) val from_vec_aux: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> s2:nat{s2 < s1} -> Lemma (requires True) (ensures (from_vec #s2 (slice a 0 s2)) * pow2 (n - s2) + (from_vec #(s1 - s2) (slice a s2 s1)) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n)) = ((from_vec #s2 (slice a 0 s2)) * pow2 (s1 - s2) + (from_vec #(s1 - s2) (slice a s2 s1))) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n))) val seq_slice_lemma: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> t1:nat{t1 >= s1 && t1 <= n} -> s2:nat{s2 < t1 - s1} -> t2:nat{t2 >= s2 && t2 <= t1 - s1} -> Lemma (equal (slice (slice a s1 t1) s2 t2) (slice a (s1 + s2) (s1 + t2))) val from_vec_propriety: #n:pos -> a:bv_t n -> s:nat{s < n} -> Lemma (requires True) (ensures from_vec a = (from_vec #s (slice a 0 s)) * pow2 (n - s) + from_vec #(n - s) (slice a s n)) (decreases (n - s)) val append_lemma: #n:pos -> #m:pos -> a:bv_t n -> b:bv_t m -> Lemma (from_vec #(n + m) (append a b) = (from_vec #n a) * pow2 m + (from_vec #m b)) val slice_left_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a 0 s) = (from_vec #n a) / (pow2 (n - s))) val slice_right_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a (n - s) n) = (from_vec #n a) % (pow2 s)) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:nat{p < n} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:uint_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val pow2_nth_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - p - 1 ==> nth (pow2_n #n p) i = true) /\ (i <> n - p - 1 ==> nth (pow2_n #n p) i = false)) [SMTPat (nth (pow2_n #n p) i)] val one_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b)) let logor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b)) let lognot (#n:pos) (a:uint_t n) : Tot (uint_t n) = from_vec #n (lognot_vec #n (to_vec #n a)) (* Bitwise operators definitions *) val logand_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logand a b) i = (nth a i && nth b i))) [SMTPat (nth (logand a b) i)] val logxor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logxor a b) i = (nth a i <> nth b i))) [SMTPat (nth (logxor a b) i)] val logor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logor a b) i = (nth a i || nth b i))) [SMTPat (nth (logor a b) i)] val lognot_definition: #n:pos -> a:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (lognot a) i = not(nth a i))) [SMTPat (nth (lognot a) i)] (* Two's complement unary minus *) inline_for_extraction let minus (#n:pos) (a:uint_t n) : Tot (uint_t n) = add_mod (lognot a) 1 (* Bitwise operators lemmas *) (* TODO: lemmas about the relations between different operators *) (* Bitwise AND operator *) val logand_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand #n a b = logand #n b a)) val logand_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logand #n (logand #n a b) c = logand #n a (logand #n b c))) val logand_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a a = a)) val logand_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (zero n) = zero n)) val logand_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (ones n) = a)) (* subset_vec_le_lemma proves that a subset of bits is numerically smaller or equal. *) val subset_vec_le_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_subset_vec #n a b) (ensures (from_vec a) <= (from_vec b)) (* logand_le proves the the result of AND is less than or equal to both arguments. *) val logand_le: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand a b) <= a /\ (logand a b) <= b) (* Bitwise XOR operator *) val logxor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logxor #n a b = logxor #n b a)) val logxor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logxor #n (logxor #n a b) c = logxor #n a (logxor #n b c))) val logxor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a a = zero n)) val logxor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (zero n) = a)) val logxor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (ones n) = lognot #n a)) private let xor (b:bool) (b':bool) : Tot bool = b <> b' private val xor_lemma (a:bool) (b:bool) : Lemma (requires (True)) (ensures (xor (xor a b) b = a)) [SMTPat (xor (xor a b) b)] val logxor_inv: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (a = logxor #n (logxor #n a b) b) val logxor_neq_nonzero: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (a <> b ==> logxor a b <> 0) (* Bitwise OR operators *) val logor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logor #n a b = logor #n b a)) val logor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logor #n (logor #n a b) c = logor #n a (logor #n b c))) val logor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a a = a)) val logor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a (zero n) = a)) val logor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a (ones n) = ones n)) (* superset_vec_le_lemma proves that a superset of bits is numerically greater than or equal. *) val superset_vec_ge_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_superset_vec #n a b) (ensures (from_vec a) >= (from_vec b)) (* logor_ge proves that the result of an OR is greater than or equal to both arguments. *) val logor_ge: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logor a b) >= a /\ (logor a b) >= b) (* Bitwise NOT operator *) val lognot_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (lognot #n (lognot #n a) = a)) val lognot_lemma_1: #n:pos -> Lemma (requires True) (ensures (lognot #n (zero n) = ones n)) (** Used in the next two lemmas *) private val index_to_vec_ones: #n:pos -> m:nat{m <= n} -> i:nat{i < n} -> Lemma (requires True) (ensures (pow2 m <= pow2 n /\ (i < n - m ==> index (to_vec #n (pow2 m - 1)) i == false) /\ (n - m <= i ==> index (to_vec #n (pow2 m - 1)) i == true))) [SMTPat (index (to_vec #n (pow2 m - 1)) i)] val logor_disjoint: #n:pos -> a:uint_t n -> b:uint_t n -> m:pos{m < n} -> Lemma (requires (a % pow2 m == 0 /\ b < pow2 m)) (ensures (logor #n a b == a + b)) val logand_mask: #n:pos -> a:uint_t n -> m:pos{m < n} -> Lemma (pow2 m < pow2 n /\ logand #n a (pow2 m - 1) == a % pow2 m) (* Shift operators *) let shift_left (#n:pos) (a:uint_t n) (s:nat) : Tot (uint_t n) = from_vec (shift_left_vec #n (to_vec #n a) s) let shift_right (#n:pos) (a:uint_t n) (s:nat) : Tot (uint_t n) = from_vec (shift_right_vec #n (to_vec #n a) s) (* Shift operators lemmas *) val shift_left_lemma_1: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i >= n - s} -> Lemma (requires True) (ensures (nth (shift_left #n a s) i = false)) [SMTPat (nth (shift_left #n a s) i)] val shift_left_lemma_2: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i < n - s} -> Lemma (requires True) (ensures (nth (shift_left #n a s) i = nth #n a (i + s))) [SMTPat (nth (shift_left #n a s) i)] val shift_right_lemma_1: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i < s} -> Lemma (requires True) (ensures (nth (shift_right #n a s) i = false)) [SMTPat (nth (shift_right #n a s) i)] val shift_right_lemma_2: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i >= s} -> Lemma (requires True) (ensures (nth (shift_right #n a s) i = nth #n a (i - s))) [SMTPat (nth (shift_right #n a s) i)] (* Lemmas with shift operators and bitwise operators *) val shift_left_logand_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logand #n a b) s = logand #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logand_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logand #n a b) s = logand #n (shift_right #n a s) (shift_right #n b s))) val shift_left_logxor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logxor #n a b) s = logxor #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logxor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logxor #n a b) s = logxor #n (shift_right #n a s) (shift_right #n b s))) val shift_left_logor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logor #n a b) s = logor #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logor #n a b) s = logor #n (shift_right #n a s) (shift_right #n b s))) (* Lemmas about value after shift operations *) val shift_left_value_aux_1: #n:pos -> a:uint_t n -> s:nat{s >= n} -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) val shift_left_value_aux_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures shift_left #n a 0 = (a * pow2 0) % pow2 n) val shift_left_value_aux_3: #n:pos -> a:uint_t n -> s:pos{s < n} -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) val shift_left_value_lemma: #n:pos -> a:uint_t n -> s:nat -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) [SMTPat (shift_left #n a s)] val shift_right_value_aux_1: #n:pos -> a:uint_t n -> s:nat{s >= n} -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) val shift_right_value_aux_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures shift_right #n a 0 = a / pow2 0) val shift_right_value_aux_3: #n:pos -> a:uint_t n -> s:pos{s < n} -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) val shift_right_value_lemma: #n:pos -> a:uint_t n -> s:nat -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) [SMTPat (shift_right #n a s)] (* Lemmas about the most significant bit in various situations *) let msb (#n:pos) (a:uint_t n) : Tot bool = nth a 0 val lemma_msb_pow2: #n:pos -> a:uint_t n -> Lemma (msb a <==> a >= pow2 (n-1)) val lemma_minus_zero: #n:pos -> a:uint_t n -> Lemma (minus a = 0 ==> a = 0) val lemma_msb_gte: #n:pos{n > 1} -> a:uint_t n -> b:uint_t n -> Lemma ((a >= b && not (msb a)) ==> not (msb b)) (* Lemmas toward showing ~n + 1 = -a *) val lemma_uint_mod: #n:pos -> a:uint_t n -> Lemma (a = a % pow2 n) val lemma_add_sub_cancel: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (add_mod (sub_mod a b) b = a) val lemma_mod_sub_distr_l: a:int -> b:int -> p:pos -> Lemma ((a - b) % p = ((a % p) - b) % p) val lemma_sub_add_cancel: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (sub_mod (add_mod a b) b = a) let zero_extend_vec (#n:pos) (a:BitVector.bv_t n): Tot (BitVector.bv_t (n+1)) = Seq.append (Seq.create 1 false) a let one_extend_vec (#n:pos) (a:BitVector.bv_t n): Tot (BitVector.bv_t (n+1)) = Seq.append (Seq.create 1 true) a
false
false
FStar.UInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val zero_extend (#n: pos) (a: uint_t n) : Tot (uint_t (n + 1))
[]
FStar.UInt.zero_extend
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> FStar.UInt.uint_t (n + 1)
{ "end_col": 97, "end_line": 566, "start_col": 60, "start_line": 566 }
Prims.Tot
val lognot (#n: pos) (a: uint_t n) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lognot (#n:pos) (a:uint_t n) : Tot (uint_t n) = from_vec #n (lognot_vec #n (to_vec #n a))
val lognot (#n: pos) (a: uint_t n) : Tot (uint_t n) let lognot (#n: pos) (a: uint_t n) : Tot (uint_t n) =
false
null
false
from_vec #n (lognot_vec #n (to_vec #n a))
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.UInt.uint_t", "FStar.UInt.from_vec", "FStar.BitVector.lognot_vec", "FStar.UInt.to_vec" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1)) let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0) val to_vec_lemma_1: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:nat -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) val from_vec_aux: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> s2:nat{s2 < s1} -> Lemma (requires True) (ensures (from_vec #s2 (slice a 0 s2)) * pow2 (n - s2) + (from_vec #(s1 - s2) (slice a s2 s1)) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n)) = ((from_vec #s2 (slice a 0 s2)) * pow2 (s1 - s2) + (from_vec #(s1 - s2) (slice a s2 s1))) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n))) val seq_slice_lemma: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> t1:nat{t1 >= s1 && t1 <= n} -> s2:nat{s2 < t1 - s1} -> t2:nat{t2 >= s2 && t2 <= t1 - s1} -> Lemma (equal (slice (slice a s1 t1) s2 t2) (slice a (s1 + s2) (s1 + t2))) val from_vec_propriety: #n:pos -> a:bv_t n -> s:nat{s < n} -> Lemma (requires True) (ensures from_vec a = (from_vec #s (slice a 0 s)) * pow2 (n - s) + from_vec #(n - s) (slice a s n)) (decreases (n - s)) val append_lemma: #n:pos -> #m:pos -> a:bv_t n -> b:bv_t m -> Lemma (from_vec #(n + m) (append a b) = (from_vec #n a) * pow2 m + (from_vec #m b)) val slice_left_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a 0 s) = (from_vec #n a) / (pow2 (n - s))) val slice_right_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a (n - s) n) = (from_vec #n a) % (pow2 s)) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:nat{p < n} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:uint_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val pow2_nth_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - p - 1 ==> nth (pow2_n #n p) i = true) /\ (i <> n - p - 1 ==> nth (pow2_n #n p) i = false)) [SMTPat (nth (pow2_n #n p) i)] val one_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b)) let logor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b))
false
false
FStar.UInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lognot (#n: pos) (a: uint_t n) : Tot (uint_t n)
[]
FStar.UInt.lognot
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> FStar.UInt.uint_t n
{ "end_col": 43, "end_line": 308, "start_col": 2, "start_line": 308 }
Prims.Tot
val zero_extend_vec (#n: pos) (a: BitVector.bv_t n) : Tot (BitVector.bv_t (n + 1))
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let zero_extend_vec (#n:pos) (a:BitVector.bv_t n): Tot (BitVector.bv_t (n+1)) = Seq.append (Seq.create 1 false) a
val zero_extend_vec (#n: pos) (a: BitVector.bv_t n) : Tot (BitVector.bv_t (n + 1)) let zero_extend_vec (#n: pos) (a: BitVector.bv_t n) : Tot (BitVector.bv_t (n + 1)) =
false
null
false
Seq.append (Seq.create 1 false) a
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.BitVector.bv_t", "FStar.Seq.Base.append", "Prims.bool", "FStar.Seq.Base.create", "Prims.op_Addition" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1)) let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0) val to_vec_lemma_1: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:nat -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) val from_vec_aux: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> s2:nat{s2 < s1} -> Lemma (requires True) (ensures (from_vec #s2 (slice a 0 s2)) * pow2 (n - s2) + (from_vec #(s1 - s2) (slice a s2 s1)) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n)) = ((from_vec #s2 (slice a 0 s2)) * pow2 (s1 - s2) + (from_vec #(s1 - s2) (slice a s2 s1))) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n))) val seq_slice_lemma: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> t1:nat{t1 >= s1 && t1 <= n} -> s2:nat{s2 < t1 - s1} -> t2:nat{t2 >= s2 && t2 <= t1 - s1} -> Lemma (equal (slice (slice a s1 t1) s2 t2) (slice a (s1 + s2) (s1 + t2))) val from_vec_propriety: #n:pos -> a:bv_t n -> s:nat{s < n} -> Lemma (requires True) (ensures from_vec a = (from_vec #s (slice a 0 s)) * pow2 (n - s) + from_vec #(n - s) (slice a s n)) (decreases (n - s)) val append_lemma: #n:pos -> #m:pos -> a:bv_t n -> b:bv_t m -> Lemma (from_vec #(n + m) (append a b) = (from_vec #n a) * pow2 m + (from_vec #m b)) val slice_left_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a 0 s) = (from_vec #n a) / (pow2 (n - s))) val slice_right_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a (n - s) n) = (from_vec #n a) % (pow2 s)) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:nat{p < n} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:uint_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val pow2_nth_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - p - 1 ==> nth (pow2_n #n p) i = true) /\ (i <> n - p - 1 ==> nth (pow2_n #n p) i = false)) [SMTPat (nth (pow2_n #n p) i)] val one_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b)) let logor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b)) let lognot (#n:pos) (a:uint_t n) : Tot (uint_t n) = from_vec #n (lognot_vec #n (to_vec #n a)) (* Bitwise operators definitions *) val logand_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logand a b) i = (nth a i && nth b i))) [SMTPat (nth (logand a b) i)] val logxor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logxor a b) i = (nth a i <> nth b i))) [SMTPat (nth (logxor a b) i)] val logor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logor a b) i = (nth a i || nth b i))) [SMTPat (nth (logor a b) i)] val lognot_definition: #n:pos -> a:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (lognot a) i = not(nth a i))) [SMTPat (nth (lognot a) i)] (* Two's complement unary minus *) inline_for_extraction let minus (#n:pos) (a:uint_t n) : Tot (uint_t n) = add_mod (lognot a) 1 (* Bitwise operators lemmas *) (* TODO: lemmas about the relations between different operators *) (* Bitwise AND operator *) val logand_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand #n a b = logand #n b a)) val logand_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logand #n (logand #n a b) c = logand #n a (logand #n b c))) val logand_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a a = a)) val logand_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (zero n) = zero n)) val logand_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (ones n) = a)) (* subset_vec_le_lemma proves that a subset of bits is numerically smaller or equal. *) val subset_vec_le_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_subset_vec #n a b) (ensures (from_vec a) <= (from_vec b)) (* logand_le proves the the result of AND is less than or equal to both arguments. *) val logand_le: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand a b) <= a /\ (logand a b) <= b) (* Bitwise XOR operator *) val logxor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logxor #n a b = logxor #n b a)) val logxor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logxor #n (logxor #n a b) c = logxor #n a (logxor #n b c))) val logxor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a a = zero n)) val logxor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (zero n) = a)) val logxor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (ones n) = lognot #n a)) private let xor (b:bool) (b':bool) : Tot bool = b <> b' private val xor_lemma (a:bool) (b:bool) : Lemma (requires (True)) (ensures (xor (xor a b) b = a)) [SMTPat (xor (xor a b) b)] val logxor_inv: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (a = logxor #n (logxor #n a b) b) val logxor_neq_nonzero: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (a <> b ==> logxor a b <> 0) (* Bitwise OR operators *) val logor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logor #n a b = logor #n b a)) val logor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logor #n (logor #n a b) c = logor #n a (logor #n b c))) val logor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a a = a)) val logor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a (zero n) = a)) val logor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a (ones n) = ones n)) (* superset_vec_le_lemma proves that a superset of bits is numerically greater than or equal. *) val superset_vec_ge_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_superset_vec #n a b) (ensures (from_vec a) >= (from_vec b)) (* logor_ge proves that the result of an OR is greater than or equal to both arguments. *) val logor_ge: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logor a b) >= a /\ (logor a b) >= b) (* Bitwise NOT operator *) val lognot_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (lognot #n (lognot #n a) = a)) val lognot_lemma_1: #n:pos -> Lemma (requires True) (ensures (lognot #n (zero n) = ones n)) (** Used in the next two lemmas *) private val index_to_vec_ones: #n:pos -> m:nat{m <= n} -> i:nat{i < n} -> Lemma (requires True) (ensures (pow2 m <= pow2 n /\ (i < n - m ==> index (to_vec #n (pow2 m - 1)) i == false) /\ (n - m <= i ==> index (to_vec #n (pow2 m - 1)) i == true))) [SMTPat (index (to_vec #n (pow2 m - 1)) i)] val logor_disjoint: #n:pos -> a:uint_t n -> b:uint_t n -> m:pos{m < n} -> Lemma (requires (a % pow2 m == 0 /\ b < pow2 m)) (ensures (logor #n a b == a + b)) val logand_mask: #n:pos -> a:uint_t n -> m:pos{m < n} -> Lemma (pow2 m < pow2 n /\ logand #n a (pow2 m - 1) == a % pow2 m) (* Shift operators *) let shift_left (#n:pos) (a:uint_t n) (s:nat) : Tot (uint_t n) = from_vec (shift_left_vec #n (to_vec #n a) s) let shift_right (#n:pos) (a:uint_t n) (s:nat) : Tot (uint_t n) = from_vec (shift_right_vec #n (to_vec #n a) s) (* Shift operators lemmas *) val shift_left_lemma_1: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i >= n - s} -> Lemma (requires True) (ensures (nth (shift_left #n a s) i = false)) [SMTPat (nth (shift_left #n a s) i)] val shift_left_lemma_2: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i < n - s} -> Lemma (requires True) (ensures (nth (shift_left #n a s) i = nth #n a (i + s))) [SMTPat (nth (shift_left #n a s) i)] val shift_right_lemma_1: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i < s} -> Lemma (requires True) (ensures (nth (shift_right #n a s) i = false)) [SMTPat (nth (shift_right #n a s) i)] val shift_right_lemma_2: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i >= s} -> Lemma (requires True) (ensures (nth (shift_right #n a s) i = nth #n a (i - s))) [SMTPat (nth (shift_right #n a s) i)] (* Lemmas with shift operators and bitwise operators *) val shift_left_logand_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logand #n a b) s = logand #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logand_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logand #n a b) s = logand #n (shift_right #n a s) (shift_right #n b s))) val shift_left_logxor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logxor #n a b) s = logxor #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logxor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logxor #n a b) s = logxor #n (shift_right #n a s) (shift_right #n b s))) val shift_left_logor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logor #n a b) s = logor #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logor #n a b) s = logor #n (shift_right #n a s) (shift_right #n b s))) (* Lemmas about value after shift operations *) val shift_left_value_aux_1: #n:pos -> a:uint_t n -> s:nat{s >= n} -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) val shift_left_value_aux_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures shift_left #n a 0 = (a * pow2 0) % pow2 n) val shift_left_value_aux_3: #n:pos -> a:uint_t n -> s:pos{s < n} -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) val shift_left_value_lemma: #n:pos -> a:uint_t n -> s:nat -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) [SMTPat (shift_left #n a s)] val shift_right_value_aux_1: #n:pos -> a:uint_t n -> s:nat{s >= n} -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) val shift_right_value_aux_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures shift_right #n a 0 = a / pow2 0) val shift_right_value_aux_3: #n:pos -> a:uint_t n -> s:pos{s < n} -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) val shift_right_value_lemma: #n:pos -> a:uint_t n -> s:nat -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) [SMTPat (shift_right #n a s)] (* Lemmas about the most significant bit in various situations *) let msb (#n:pos) (a:uint_t n) : Tot bool = nth a 0 val lemma_msb_pow2: #n:pos -> a:uint_t n -> Lemma (msb a <==> a >= pow2 (n-1)) val lemma_minus_zero: #n:pos -> a:uint_t n -> Lemma (minus a = 0 ==> a = 0) val lemma_msb_gte: #n:pos{n > 1} -> a:uint_t n -> b:uint_t n -> Lemma ((a >= b && not (msb a)) ==> not (msb b)) (* Lemmas toward showing ~n + 1 = -a *) val lemma_uint_mod: #n:pos -> a:uint_t n -> Lemma (a = a % pow2 n) val lemma_add_sub_cancel: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (add_mod (sub_mod a b) b = a) val lemma_mod_sub_distr_l: a:int -> b:int -> p:pos -> Lemma ((a - b) % p = ((a % p) - b) % p) val lemma_sub_add_cancel: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (sub_mod (add_mod a b) b = a)
false
false
FStar.UInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val zero_extend_vec (#n: pos) (a: BitVector.bv_t n) : Tot (BitVector.bv_t (n + 1))
[]
FStar.UInt.zero_extend_vec
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.BitVector.bv_t n -> FStar.BitVector.bv_t (n + 1)
{ "end_col": 113, "end_line": 563, "start_col": 80, "start_line": 563 }
Prims.Tot
val shift_right (#n: pos) (a: uint_t n) (s: nat) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let shift_right (#n:pos) (a:uint_t n) (s:nat) : Tot (uint_t n) = from_vec (shift_right_vec #n (to_vec #n a) s)
val shift_right (#n: pos) (a: uint_t n) (s: nat) : Tot (uint_t n) let shift_right (#n: pos) (a: uint_t n) (s: nat) : Tot (uint_t n) =
false
null
false
from_vec (shift_right_vec #n (to_vec #n a) s)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.UInt.uint_t", "Prims.nat", "FStar.UInt.from_vec", "FStar.BitVector.shift_right_vec", "FStar.UInt.to_vec" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1)) let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0) val to_vec_lemma_1: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:nat -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) val from_vec_aux: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> s2:nat{s2 < s1} -> Lemma (requires True) (ensures (from_vec #s2 (slice a 0 s2)) * pow2 (n - s2) + (from_vec #(s1 - s2) (slice a s2 s1)) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n)) = ((from_vec #s2 (slice a 0 s2)) * pow2 (s1 - s2) + (from_vec #(s1 - s2) (slice a s2 s1))) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n))) val seq_slice_lemma: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> t1:nat{t1 >= s1 && t1 <= n} -> s2:nat{s2 < t1 - s1} -> t2:nat{t2 >= s2 && t2 <= t1 - s1} -> Lemma (equal (slice (slice a s1 t1) s2 t2) (slice a (s1 + s2) (s1 + t2))) val from_vec_propriety: #n:pos -> a:bv_t n -> s:nat{s < n} -> Lemma (requires True) (ensures from_vec a = (from_vec #s (slice a 0 s)) * pow2 (n - s) + from_vec #(n - s) (slice a s n)) (decreases (n - s)) val append_lemma: #n:pos -> #m:pos -> a:bv_t n -> b:bv_t m -> Lemma (from_vec #(n + m) (append a b) = (from_vec #n a) * pow2 m + (from_vec #m b)) val slice_left_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a 0 s) = (from_vec #n a) / (pow2 (n - s))) val slice_right_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a (n - s) n) = (from_vec #n a) % (pow2 s)) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:nat{p < n} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:uint_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val pow2_nth_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - p - 1 ==> nth (pow2_n #n p) i = true) /\ (i <> n - p - 1 ==> nth (pow2_n #n p) i = false)) [SMTPat (nth (pow2_n #n p) i)] val one_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b)) let logor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b)) let lognot (#n:pos) (a:uint_t n) : Tot (uint_t n) = from_vec #n (lognot_vec #n (to_vec #n a)) (* Bitwise operators definitions *) val logand_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logand a b) i = (nth a i && nth b i))) [SMTPat (nth (logand a b) i)] val logxor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logxor a b) i = (nth a i <> nth b i))) [SMTPat (nth (logxor a b) i)] val logor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logor a b) i = (nth a i || nth b i))) [SMTPat (nth (logor a b) i)] val lognot_definition: #n:pos -> a:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (lognot a) i = not(nth a i))) [SMTPat (nth (lognot a) i)] (* Two's complement unary minus *) inline_for_extraction let minus (#n:pos) (a:uint_t n) : Tot (uint_t n) = add_mod (lognot a) 1 (* Bitwise operators lemmas *) (* TODO: lemmas about the relations between different operators *) (* Bitwise AND operator *) val logand_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand #n a b = logand #n b a)) val logand_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logand #n (logand #n a b) c = logand #n a (logand #n b c))) val logand_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a a = a)) val logand_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (zero n) = zero n)) val logand_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (ones n) = a)) (* subset_vec_le_lemma proves that a subset of bits is numerically smaller or equal. *) val subset_vec_le_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_subset_vec #n a b) (ensures (from_vec a) <= (from_vec b)) (* logand_le proves the the result of AND is less than or equal to both arguments. *) val logand_le: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand a b) <= a /\ (logand a b) <= b) (* Bitwise XOR operator *) val logxor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logxor #n a b = logxor #n b a)) val logxor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logxor #n (logxor #n a b) c = logxor #n a (logxor #n b c))) val logxor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a a = zero n)) val logxor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (zero n) = a)) val logxor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (ones n) = lognot #n a)) private let xor (b:bool) (b':bool) : Tot bool = b <> b' private val xor_lemma (a:bool) (b:bool) : Lemma (requires (True)) (ensures (xor (xor a b) b = a)) [SMTPat (xor (xor a b) b)] val logxor_inv: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (a = logxor #n (logxor #n a b) b) val logxor_neq_nonzero: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (a <> b ==> logxor a b <> 0) (* Bitwise OR operators *) val logor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logor #n a b = logor #n b a)) val logor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logor #n (logor #n a b) c = logor #n a (logor #n b c))) val logor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a a = a)) val logor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a (zero n) = a)) val logor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a (ones n) = ones n)) (* superset_vec_le_lemma proves that a superset of bits is numerically greater than or equal. *) val superset_vec_ge_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_superset_vec #n a b) (ensures (from_vec a) >= (from_vec b)) (* logor_ge proves that the result of an OR is greater than or equal to both arguments. *) val logor_ge: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logor a b) >= a /\ (logor a b) >= b) (* Bitwise NOT operator *) val lognot_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (lognot #n (lognot #n a) = a)) val lognot_lemma_1: #n:pos -> Lemma (requires True) (ensures (lognot #n (zero n) = ones n)) (** Used in the next two lemmas *) private val index_to_vec_ones: #n:pos -> m:nat{m <= n} -> i:nat{i < n} -> Lemma (requires True) (ensures (pow2 m <= pow2 n /\ (i < n - m ==> index (to_vec #n (pow2 m - 1)) i == false) /\ (n - m <= i ==> index (to_vec #n (pow2 m - 1)) i == true))) [SMTPat (index (to_vec #n (pow2 m - 1)) i)] val logor_disjoint: #n:pos -> a:uint_t n -> b:uint_t n -> m:pos{m < n} -> Lemma (requires (a % pow2 m == 0 /\ b < pow2 m)) (ensures (logor #n a b == a + b)) val logand_mask: #n:pos -> a:uint_t n -> m:pos{m < n} -> Lemma (pow2 m < pow2 n /\ logand #n a (pow2 m - 1) == a % pow2 m) (* Shift operators *) let shift_left (#n:pos) (a:uint_t n) (s:nat) : Tot (uint_t n) = from_vec (shift_left_vec #n (to_vec #n a) s)
false
false
FStar.UInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val shift_right (#n: pos) (a: uint_t n) (s: nat) : Tot (uint_t n)
[]
FStar.UInt.shift_right
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> s: Prims.nat -> FStar.UInt.uint_t n
{ "end_col": 47, "end_line": 451, "start_col": 2, "start_line": 451 }
Prims.Tot
val one_extend_vec (#n: pos) (a: BitVector.bv_t n) : Tot (BitVector.bv_t (n + 1))
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let one_extend_vec (#n:pos) (a:BitVector.bv_t n): Tot (BitVector.bv_t (n+1)) = Seq.append (Seq.create 1 true) a
val one_extend_vec (#n: pos) (a: BitVector.bv_t n) : Tot (BitVector.bv_t (n + 1)) let one_extend_vec (#n: pos) (a: BitVector.bv_t n) : Tot (BitVector.bv_t (n + 1)) =
false
null
false
Seq.append (Seq.create 1 true) a
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.BitVector.bv_t", "FStar.Seq.Base.append", "Prims.bool", "FStar.Seq.Base.create", "Prims.op_Addition" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1)) let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0) val to_vec_lemma_1: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:nat -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) val from_vec_aux: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> s2:nat{s2 < s1} -> Lemma (requires True) (ensures (from_vec #s2 (slice a 0 s2)) * pow2 (n - s2) + (from_vec #(s1 - s2) (slice a s2 s1)) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n)) = ((from_vec #s2 (slice a 0 s2)) * pow2 (s1 - s2) + (from_vec #(s1 - s2) (slice a s2 s1))) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n))) val seq_slice_lemma: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> t1:nat{t1 >= s1 && t1 <= n} -> s2:nat{s2 < t1 - s1} -> t2:nat{t2 >= s2 && t2 <= t1 - s1} -> Lemma (equal (slice (slice a s1 t1) s2 t2) (slice a (s1 + s2) (s1 + t2))) val from_vec_propriety: #n:pos -> a:bv_t n -> s:nat{s < n} -> Lemma (requires True) (ensures from_vec a = (from_vec #s (slice a 0 s)) * pow2 (n - s) + from_vec #(n - s) (slice a s n)) (decreases (n - s)) val append_lemma: #n:pos -> #m:pos -> a:bv_t n -> b:bv_t m -> Lemma (from_vec #(n + m) (append a b) = (from_vec #n a) * pow2 m + (from_vec #m b)) val slice_left_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a 0 s) = (from_vec #n a) / (pow2 (n - s))) val slice_right_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a (n - s) n) = (from_vec #n a) % (pow2 s)) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:nat{p < n} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:uint_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val pow2_nth_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - p - 1 ==> nth (pow2_n #n p) i = true) /\ (i <> n - p - 1 ==> nth (pow2_n #n p) i = false)) [SMTPat (nth (pow2_n #n p) i)] val one_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b)) let logor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b)) let lognot (#n:pos) (a:uint_t n) : Tot (uint_t n) = from_vec #n (lognot_vec #n (to_vec #n a)) (* Bitwise operators definitions *) val logand_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logand a b) i = (nth a i && nth b i))) [SMTPat (nth (logand a b) i)] val logxor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logxor a b) i = (nth a i <> nth b i))) [SMTPat (nth (logxor a b) i)] val logor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logor a b) i = (nth a i || nth b i))) [SMTPat (nth (logor a b) i)] val lognot_definition: #n:pos -> a:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (lognot a) i = not(nth a i))) [SMTPat (nth (lognot a) i)] (* Two's complement unary minus *) inline_for_extraction let minus (#n:pos) (a:uint_t n) : Tot (uint_t n) = add_mod (lognot a) 1 (* Bitwise operators lemmas *) (* TODO: lemmas about the relations between different operators *) (* Bitwise AND operator *) val logand_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand #n a b = logand #n b a)) val logand_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logand #n (logand #n a b) c = logand #n a (logand #n b c))) val logand_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a a = a)) val logand_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (zero n) = zero n)) val logand_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (ones n) = a)) (* subset_vec_le_lemma proves that a subset of bits is numerically smaller or equal. *) val subset_vec_le_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_subset_vec #n a b) (ensures (from_vec a) <= (from_vec b)) (* logand_le proves the the result of AND is less than or equal to both arguments. *) val logand_le: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand a b) <= a /\ (logand a b) <= b) (* Bitwise XOR operator *) val logxor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logxor #n a b = logxor #n b a)) val logxor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logxor #n (logxor #n a b) c = logxor #n a (logxor #n b c))) val logxor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a a = zero n)) val logxor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (zero n) = a)) val logxor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (ones n) = lognot #n a)) private let xor (b:bool) (b':bool) : Tot bool = b <> b' private val xor_lemma (a:bool) (b:bool) : Lemma (requires (True)) (ensures (xor (xor a b) b = a)) [SMTPat (xor (xor a b) b)] val logxor_inv: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (a = logxor #n (logxor #n a b) b) val logxor_neq_nonzero: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (a <> b ==> logxor a b <> 0) (* Bitwise OR operators *) val logor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logor #n a b = logor #n b a)) val logor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logor #n (logor #n a b) c = logor #n a (logor #n b c))) val logor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a a = a)) val logor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a (zero n) = a)) val logor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a (ones n) = ones n)) (* superset_vec_le_lemma proves that a superset of bits is numerically greater than or equal. *) val superset_vec_ge_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_superset_vec #n a b) (ensures (from_vec a) >= (from_vec b)) (* logor_ge proves that the result of an OR is greater than or equal to both arguments. *) val logor_ge: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logor a b) >= a /\ (logor a b) >= b) (* Bitwise NOT operator *) val lognot_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (lognot #n (lognot #n a) = a)) val lognot_lemma_1: #n:pos -> Lemma (requires True) (ensures (lognot #n (zero n) = ones n)) (** Used in the next two lemmas *) private val index_to_vec_ones: #n:pos -> m:nat{m <= n} -> i:nat{i < n} -> Lemma (requires True) (ensures (pow2 m <= pow2 n /\ (i < n - m ==> index (to_vec #n (pow2 m - 1)) i == false) /\ (n - m <= i ==> index (to_vec #n (pow2 m - 1)) i == true))) [SMTPat (index (to_vec #n (pow2 m - 1)) i)] val logor_disjoint: #n:pos -> a:uint_t n -> b:uint_t n -> m:pos{m < n} -> Lemma (requires (a % pow2 m == 0 /\ b < pow2 m)) (ensures (logor #n a b == a + b)) val logand_mask: #n:pos -> a:uint_t n -> m:pos{m < n} -> Lemma (pow2 m < pow2 n /\ logand #n a (pow2 m - 1) == a % pow2 m) (* Shift operators *) let shift_left (#n:pos) (a:uint_t n) (s:nat) : Tot (uint_t n) = from_vec (shift_left_vec #n (to_vec #n a) s) let shift_right (#n:pos) (a:uint_t n) (s:nat) : Tot (uint_t n) = from_vec (shift_right_vec #n (to_vec #n a) s) (* Shift operators lemmas *) val shift_left_lemma_1: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i >= n - s} -> Lemma (requires True) (ensures (nth (shift_left #n a s) i = false)) [SMTPat (nth (shift_left #n a s) i)] val shift_left_lemma_2: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i < n - s} -> Lemma (requires True) (ensures (nth (shift_left #n a s) i = nth #n a (i + s))) [SMTPat (nth (shift_left #n a s) i)] val shift_right_lemma_1: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i < s} -> Lemma (requires True) (ensures (nth (shift_right #n a s) i = false)) [SMTPat (nth (shift_right #n a s) i)] val shift_right_lemma_2: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i >= s} -> Lemma (requires True) (ensures (nth (shift_right #n a s) i = nth #n a (i - s))) [SMTPat (nth (shift_right #n a s) i)] (* Lemmas with shift operators and bitwise operators *) val shift_left_logand_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logand #n a b) s = logand #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logand_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logand #n a b) s = logand #n (shift_right #n a s) (shift_right #n b s))) val shift_left_logxor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logxor #n a b) s = logxor #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logxor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logxor #n a b) s = logxor #n (shift_right #n a s) (shift_right #n b s))) val shift_left_logor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logor #n a b) s = logor #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logor #n a b) s = logor #n (shift_right #n a s) (shift_right #n b s))) (* Lemmas about value after shift operations *) val shift_left_value_aux_1: #n:pos -> a:uint_t n -> s:nat{s >= n} -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) val shift_left_value_aux_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures shift_left #n a 0 = (a * pow2 0) % pow2 n) val shift_left_value_aux_3: #n:pos -> a:uint_t n -> s:pos{s < n} -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) val shift_left_value_lemma: #n:pos -> a:uint_t n -> s:nat -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) [SMTPat (shift_left #n a s)] val shift_right_value_aux_1: #n:pos -> a:uint_t n -> s:nat{s >= n} -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) val shift_right_value_aux_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures shift_right #n a 0 = a / pow2 0) val shift_right_value_aux_3: #n:pos -> a:uint_t n -> s:pos{s < n} -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) val shift_right_value_lemma: #n:pos -> a:uint_t n -> s:nat -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) [SMTPat (shift_right #n a s)] (* Lemmas about the most significant bit in various situations *) let msb (#n:pos) (a:uint_t n) : Tot bool = nth a 0 val lemma_msb_pow2: #n:pos -> a:uint_t n -> Lemma (msb a <==> a >= pow2 (n-1)) val lemma_minus_zero: #n:pos -> a:uint_t n -> Lemma (minus a = 0 ==> a = 0) val lemma_msb_gte: #n:pos{n > 1} -> a:uint_t n -> b:uint_t n -> Lemma ((a >= b && not (msb a)) ==> not (msb b)) (* Lemmas toward showing ~n + 1 = -a *) val lemma_uint_mod: #n:pos -> a:uint_t n -> Lemma (a = a % pow2 n) val lemma_add_sub_cancel: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (add_mod (sub_mod a b) b = a) val lemma_mod_sub_distr_l: a:int -> b:int -> p:pos -> Lemma ((a - b) % p = ((a % p) - b) % p) val lemma_sub_add_cancel: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (sub_mod (add_mod a b) b = a)
false
false
FStar.UInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val one_extend_vec (#n: pos) (a: BitVector.bv_t n) : Tot (BitVector.bv_t (n + 1))
[]
FStar.UInt.one_extend_vec
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.BitVector.bv_t n -> FStar.BitVector.bv_t (n + 1)
{ "end_col": 111, "end_line": 564, "start_col": 79, "start_line": 564 }
Prims.Tot
val logxor (#n: pos) (a b: uint_t n) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let logxor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b))
val logxor (#n: pos) (a b: uint_t n) : Tot (uint_t n) let logxor (#n: pos) (a b: uint_t n) : Tot (uint_t n) =
false
null
false
from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b))
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.UInt.uint_t", "FStar.UInt.from_vec", "FStar.BitVector.logxor_vec", "FStar.UInt.to_vec" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1)) let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0) val to_vec_lemma_1: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:nat -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) val from_vec_aux: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> s2:nat{s2 < s1} -> Lemma (requires True) (ensures (from_vec #s2 (slice a 0 s2)) * pow2 (n - s2) + (from_vec #(s1 - s2) (slice a s2 s1)) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n)) = ((from_vec #s2 (slice a 0 s2)) * pow2 (s1 - s2) + (from_vec #(s1 - s2) (slice a s2 s1))) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n))) val seq_slice_lemma: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> t1:nat{t1 >= s1 && t1 <= n} -> s2:nat{s2 < t1 - s1} -> t2:nat{t2 >= s2 && t2 <= t1 - s1} -> Lemma (equal (slice (slice a s1 t1) s2 t2) (slice a (s1 + s2) (s1 + t2))) val from_vec_propriety: #n:pos -> a:bv_t n -> s:nat{s < n} -> Lemma (requires True) (ensures from_vec a = (from_vec #s (slice a 0 s)) * pow2 (n - s) + from_vec #(n - s) (slice a s n)) (decreases (n - s)) val append_lemma: #n:pos -> #m:pos -> a:bv_t n -> b:bv_t m -> Lemma (from_vec #(n + m) (append a b) = (from_vec #n a) * pow2 m + (from_vec #m b)) val slice_left_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a 0 s) = (from_vec #n a) / (pow2 (n - s))) val slice_right_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a (n - s) n) = (from_vec #n a) % (pow2 s)) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:nat{p < n} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:uint_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val pow2_nth_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - p - 1 ==> nth (pow2_n #n p) i = true) /\ (i <> n - p - 1 ==> nth (pow2_n #n p) i = false)) [SMTPat (nth (pow2_n #n p) i)] val one_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b))
false
false
FStar.UInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val logxor (#n: pos) (a b: uint_t n) : Tot (uint_t n)
[]
FStar.UInt.logxor
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> FStar.UInt.uint_t n
{ "end_col": 57, "end_line": 302, "start_col": 2, "start_line": 302 }
Prims.Tot
val logor (#n: pos) (a b: uint_t n) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let logor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b))
val logor (#n: pos) (a b: uint_t n) : Tot (uint_t n) let logor (#n: pos) (a b: uint_t n) : Tot (uint_t n) =
false
null
false
from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b))
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.UInt.uint_t", "FStar.UInt.from_vec", "FStar.BitVector.logor_vec", "FStar.UInt.to_vec" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1)) let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0) val to_vec_lemma_1: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:nat -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) val from_vec_aux: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> s2:nat{s2 < s1} -> Lemma (requires True) (ensures (from_vec #s2 (slice a 0 s2)) * pow2 (n - s2) + (from_vec #(s1 - s2) (slice a s2 s1)) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n)) = ((from_vec #s2 (slice a 0 s2)) * pow2 (s1 - s2) + (from_vec #(s1 - s2) (slice a s2 s1))) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n))) val seq_slice_lemma: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> t1:nat{t1 >= s1 && t1 <= n} -> s2:nat{s2 < t1 - s1} -> t2:nat{t2 >= s2 && t2 <= t1 - s1} -> Lemma (equal (slice (slice a s1 t1) s2 t2) (slice a (s1 + s2) (s1 + t2))) val from_vec_propriety: #n:pos -> a:bv_t n -> s:nat{s < n} -> Lemma (requires True) (ensures from_vec a = (from_vec #s (slice a 0 s)) * pow2 (n - s) + from_vec #(n - s) (slice a s n)) (decreases (n - s)) val append_lemma: #n:pos -> #m:pos -> a:bv_t n -> b:bv_t m -> Lemma (from_vec #(n + m) (append a b) = (from_vec #n a) * pow2 m + (from_vec #m b)) val slice_left_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a 0 s) = (from_vec #n a) / (pow2 (n - s))) val slice_right_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a (n - s) n) = (from_vec #n a) % (pow2 s)) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:nat{p < n} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:uint_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val pow2_nth_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - p - 1 ==> nth (pow2_n #n p) i = true) /\ (i <> n - p - 1 ==> nth (pow2_n #n p) i = false)) [SMTPat (nth (pow2_n #n p) i)] val one_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b))
false
false
FStar.UInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val logor (#n: pos) (a b: uint_t n) : Tot (uint_t n)
[]
FStar.UInt.logor
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> FStar.UInt.uint_t n
{ "end_col": 56, "end_line": 305, "start_col": 2, "start_line": 305 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.PropositionalExtensionality", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let predicate (a:Type) = a -> Tot prop
let predicate (a: Type) =
false
null
false
a -> Tot prop
{ "checked_file": "FStar.PredicateExtensionality.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.PredicateExtensionality.fst" }
[ "total" ]
[ "Prims.prop" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.PredicateExtensionality module F = FStar.FunctionalExtensionality module P = FStar.PropositionalExtensionality
false
true
FStar.PredicateExtensionality.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val predicate : a: Type -> Type
[]
FStar.PredicateExtensionality.predicate
{ "file_name": "ulib/FStar.PredicateExtensionality.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> Type
{ "end_col": 38, "end_line": 20, "start_col": 25, "start_line": 20 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.PropositionalExtensionality", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let peq (#a:Type) (p1:predicate a) (p2:predicate a) = forall x. (p1 x <==> p2 x)
let peq (#a: Type) (p1 p2: predicate a) =
false
null
false
forall x. (p1 x <==> p2 x)
{ "checked_file": "FStar.PredicateExtensionality.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.PredicateExtensionality.fst" }
[ "total" ]
[ "FStar.PredicateExtensionality.predicate", "Prims.l_Forall", "Prims.l_iff", "Prims.logical" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.PredicateExtensionality module F = FStar.FunctionalExtensionality module P = FStar.PropositionalExtensionality let predicate (a:Type) = a -> Tot prop
false
false
FStar.PredicateExtensionality.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val peq : p1: FStar.PredicateExtensionality.predicate a -> p2: FStar.PredicateExtensionality.predicate a -> Prims.logical
[]
FStar.PredicateExtensionality.peq
{ "file_name": "ulib/FStar.PredicateExtensionality.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
p1: FStar.PredicateExtensionality.predicate a -> p2: FStar.PredicateExtensionality.predicate a -> Prims.logical
{ "end_col": 28, "end_line": 23, "start_col": 2, "start_line": 23 }
FStar.Pervasives.Lemma
val predicateExtensionality (a: Type) (p1 p2: predicate a) : Lemma (requires (peq #a p1 p2)) (ensures (F.on_domain a p1 == F.on_domain a p2))
[ { "abbrev": true, "full_module": "FStar.PropositionalExtensionality", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let predicateExtensionality (a:Type) (p1 p2:predicate a) : Lemma (requires (peq #a p1 p2)) (ensures (F.on_domain a p1==F.on_domain a p2)) = P.axiom(); assert (F.feq p1 p2)
val predicateExtensionality (a: Type) (p1 p2: predicate a) : Lemma (requires (peq #a p1 p2)) (ensures (F.on_domain a p1 == F.on_domain a p2)) let predicateExtensionality (a: Type) (p1 p2: predicate a) : Lemma (requires (peq #a p1 p2)) (ensures (F.on_domain a p1 == F.on_domain a p2)) =
false
null
true
P.axiom (); assert (F.feq p1 p2)
{ "checked_file": "FStar.PredicateExtensionality.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.PropositionalExtensionality.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "FStar.PredicateExtensionality.fst" }
[ "lemma" ]
[ "FStar.PredicateExtensionality.predicate", "Prims._assert", "FStar.FunctionalExtensionality.feq", "Prims.prop", "Prims.unit", "FStar.PropositionalExtensionality.axiom", "FStar.PredicateExtensionality.peq", "Prims.squash", "Prims.eq2", "FStar.FunctionalExtensionality.arrow", "FStar.FunctionalExtensionality.on_domain", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.PredicateExtensionality module F = FStar.FunctionalExtensionality module P = FStar.PropositionalExtensionality let predicate (a:Type) = a -> Tot prop let peq (#a:Type) (p1:predicate a) (p2:predicate a) = forall x. (p1 x <==> p2 x) let predicateExtensionality (a:Type) (p1 p2:predicate a) : Lemma (requires (peq #a p1 p2))
false
false
FStar.PredicateExtensionality.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val predicateExtensionality (a: Type) (p1 p2: predicate a) : Lemma (requires (peq #a p1 p2)) (ensures (F.on_domain a p1 == F.on_domain a p2))
[]
FStar.PredicateExtensionality.predicateExtensionality
{ "file_name": "ulib/FStar.PredicateExtensionality.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> p1: FStar.PredicateExtensionality.predicate a -> p2: FStar.PredicateExtensionality.predicate a -> FStar.Pervasives.Lemma (requires FStar.PredicateExtensionality.peq p1 p2) (ensures FStar.FunctionalExtensionality.on_domain a p1 == FStar.FunctionalExtensionality.on_domain a p2)
{ "end_col": 24, "end_line": 29, "start_col": 4, "start_line": 28 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Impl.P256.Qinv", "short_module": "QI" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.PointMul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Scalar", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lbytes len = lbuffer uint8 len
let lbytes len =
false
null
false
lbuffer uint8 len
{ "checked_file": "Hacl.Impl.P256.Sign.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Scalar.fsti.checked", "Hacl.Impl.P256.Qinv.fsti.checked", "Hacl.Impl.P256.PointMul.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Sign.fst" }
[ "total" ]
[ "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8" ]
[]
module Hacl.Impl.P256.Sign open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Scalar open Hacl.Impl.P256.Point open Hacl.Impl.P256.PointMul module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module QI = Hacl.Impl.P256.Qinv module BB = Hacl.Bignum.Base module BSeq = Lib.ByteSequence #set-options "--z3rlimit 50 --ifuel 0 --fuel 0"
false
true
Hacl.Impl.P256.Sign.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lbytes : len: Lib.IntTypes.size_t -> Type0
[]
Hacl.Impl.P256.Sign.lbytes
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Sign.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_t -> Type0
{ "end_col": 34, "end_line": 26, "start_col": 17, "start_line": 26 }
FStar.HyperStack.ST.Stack
val check_signature: are_sk_nonce_valid:uint64 -> r_q:felem -> s_q:felem -> Stack bool (requires fun h -> live h r_q /\ live h s_q /\ disjoint r_q s_q /\ (v are_sk_nonce_valid = ones_v U64 \/ v are_sk_nonce_valid = 0)) (ensures fun h0 res h1 -> modifies0 h0 h1 /\ res == ((v are_sk_nonce_valid = ones_v U64) && (0 < as_nat h0 r_q) && (0 < as_nat h0 s_q)))
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Impl.P256.Qinv", "short_module": "QI" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.PointMul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Scalar", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let check_signature are_sk_nonce_valid r_q s_q = let h0 = ST.get () in let is_r_zero = bn_is_zero_mask4 r_q in let is_s_zero = bn_is_zero_mask4 s_q in [@inline_let] let m0 = lognot is_r_zero in [@inline_let] let m1 = lognot is_s_zero in [@inline_let] let m2 = m0 &. m1 in lognot_lemma is_r_zero; lognot_lemma is_s_zero; logand_lemma m0 m1; let m = are_sk_nonce_valid &. m2 in logand_lemma are_sk_nonce_valid m2; assert ((v m = ones_v U64) <==> ((v are_sk_nonce_valid = ones_v U64) && (0 < as_nat h0 r_q) && (0 < as_nat h0 s_q))); BB.unsafe_bool_of_limb m
val check_signature: are_sk_nonce_valid:uint64 -> r_q:felem -> s_q:felem -> Stack bool (requires fun h -> live h r_q /\ live h s_q /\ disjoint r_q s_q /\ (v are_sk_nonce_valid = ones_v U64 \/ v are_sk_nonce_valid = 0)) (ensures fun h0 res h1 -> modifies0 h0 h1 /\ res == ((v are_sk_nonce_valid = ones_v U64) && (0 < as_nat h0 r_q) && (0 < as_nat h0 s_q))) let check_signature are_sk_nonce_valid r_q s_q =
true
null
false
let h0 = ST.get () in let is_r_zero = bn_is_zero_mask4 r_q in let is_s_zero = bn_is_zero_mask4 s_q in [@@ inline_let ]let m0 = lognot is_r_zero in [@@ inline_let ]let m1 = lognot is_s_zero in [@@ inline_let ]let m2 = m0 &. m1 in lognot_lemma is_r_zero; lognot_lemma is_s_zero; logand_lemma m0 m1; let m = are_sk_nonce_valid &. m2 in logand_lemma are_sk_nonce_valid m2; assert ((v m = ones_v U64) <==> ((v are_sk_nonce_valid = ones_v U64) && (0 < as_nat h0 r_q) && (0 < as_nat h0 s_q))); BB.unsafe_bool_of_limb m
{ "checked_file": "Hacl.Impl.P256.Sign.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Scalar.fsti.checked", "Hacl.Impl.P256.Qinv.fsti.checked", "Hacl.Impl.P256.PointMul.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Sign.fst" }
[]
[ "Lib.IntTypes.uint64", "Hacl.Impl.P256.Bignum.felem", "Hacl.Spec.Bignum.Base.unsafe_bool_of_limb", "Lib.IntTypes.U64", "Prims.unit", "Prims._assert", "Prims.l_iff", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Lib.IntTypes.ones_v", "Prims.op_AmpAmp", "Prims.op_LessThan", "Hacl.Impl.P256.Bignum.as_nat", "Lib.IntTypes.logand_lemma", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.lognot_lemma", "Lib.IntTypes.lognot", "Prims.bool", "Hacl.Impl.P256.Bignum.bn_is_zero_mask4", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module Hacl.Impl.P256.Sign open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Scalar open Hacl.Impl.P256.Point open Hacl.Impl.P256.PointMul module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module QI = Hacl.Impl.P256.Qinv module BB = Hacl.Bignum.Base module BSeq = Lib.ByteSequence #set-options "--z3rlimit 50 --ifuel 0 --fuel 0" inline_for_extraction noextract let lbytes len = lbuffer uint8 len inline_for_extraction noextract val ecdsa_sign_r (r k:felem) : Stack unit (requires fun h -> live h r /\ live h k /\ disjoint r k /\ as_nat h k < S.order) (ensures fun h0 _ h1 -> modifies (loc r) h0 h1 /\ (let x, _ = S.to_aff_point (S.point_mul_g (as_nat h0 k)) in as_nat h1 r == x % S.order)) let ecdsa_sign_r r k = push_frame (); let p = create_point () in point_mul_g p k; // p = [k]G to_aff_point_x r p; qmod_short r r; pop_frame () inline_for_extraction noextract val ecdsa_sign_s (s k r d_a m:felem) : Stack unit (requires fun h -> live h s /\ live h m /\ live h d_a /\ live h k /\ live h r /\ disjoint s r /\ disjoint s k /\ disjoint r k /\ disjoint s d_a /\ disjoint r d_a /\ disjoint m s /\ 0 < as_nat h k /\ as_nat h k < S.order /\ as_nat h r < S.order /\ as_nat h m < S.order /\ 0 < as_nat h d_a /\ as_nat h d_a < S.order) (ensures fun h0 _ h1 -> modifies (loc s |+| loc m) h0 h1 /\ (let kinv = S.qinv (as_nat h0 k) in as_nat h1 s == S.qmul kinv (S.qadd (as_nat h0 m) (S.qmul (as_nat h0 r) (as_nat h0 d_a))))) let ecdsa_sign_s s k r d_a m = push_frame (); let h0 = ST.get () in let kinv = create_felem () in QI.qinv kinv k; let h1 = ST.get () in assert (qmont_as_nat h1 kinv == S.qinv (qmont_as_nat h0 k)); SM.qmont_inv_lemma (as_nat h0 k); assert (qmont_as_nat h1 kinv == S.qinv (as_nat h0 k) * SM.qmont_R % S.order); qmul s r d_a; // s = r * d_a let h2 = ST.get () in assert (as_nat h2 s == (as_nat h0 r * as_nat h0 d_a * SM.qmont_R_inv) % S.order); from_qmont m m; let h3 = ST.get () in assert (as_nat h3 m == as_nat h2 m * SM.qmont_R_inv % S.order); qadd s m s; // s = z + s let h4 = ST.get () in assert (as_nat h4 s == (as_nat h3 m + as_nat h2 s) % S.order); qmul s kinv s; // s = kinv * s let h5 = ST.get () in assert (as_nat h5 s == (as_nat h1 kinv * as_nat h4 s * SM.qmont_R_inv) % S.order); SM.lemma_ecdsa_sign_s (as_nat h0 k) (as_nat h1 kinv) (as_nat h0 r) (as_nat h0 d_a) (as_nat h0 m); pop_frame () inline_for_extraction noextract val ecdsa_sign_load (d_a k_q:felem) (private_key nonce:lbytes 32ul) : Stack uint64 (requires fun h -> live h private_key /\ live h nonce /\ live h d_a /\ live h k_q /\ disjoint d_a k_q /\ disjoint d_a private_key /\ disjoint d_a nonce /\ disjoint k_q private_key /\ disjoint k_q nonce) (ensures fun h0 m h1 -> modifies (loc d_a |+| loc k_q) h0 h1 /\ (let d_a_nat = BSeq.nat_from_bytes_be (as_seq h0 private_key) in let k_nat = BSeq.nat_from_bytes_be (as_seq h0 nonce) in let is_sk_valid = 0 < d_a_nat && d_a_nat < S.order in let is_nonce_valid = 0 < k_nat && k_nat < S.order in (v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = (is_sk_valid && is_nonce_valid) /\ as_nat h1 d_a == (if is_sk_valid then d_a_nat else 1) /\ as_nat h1 k_q == (if is_nonce_valid then k_nat else 1))) let ecdsa_sign_load d_a k_q private_key nonce = let is_sk_valid = load_qelem_conditional d_a private_key in let is_nonce_valid = load_qelem_conditional k_q nonce in let m = is_sk_valid &. is_nonce_valid in logand_lemma is_sk_valid is_nonce_valid; m inline_for_extraction noextract val check_signature: are_sk_nonce_valid:uint64 -> r_q:felem -> s_q:felem -> Stack bool (requires fun h -> live h r_q /\ live h s_q /\ disjoint r_q s_q /\ (v are_sk_nonce_valid = ones_v U64 \/ v are_sk_nonce_valid = 0)) (ensures fun h0 res h1 -> modifies0 h0 h1 /\ res == ((v are_sk_nonce_valid = ones_v U64) && (0 < as_nat h0 r_q) && (0 < as_nat h0 s_q)))
false
false
Hacl.Impl.P256.Sign.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val check_signature: are_sk_nonce_valid:uint64 -> r_q:felem -> s_q:felem -> Stack bool (requires fun h -> live h r_q /\ live h s_q /\ disjoint r_q s_q /\ (v are_sk_nonce_valid = ones_v U64 \/ v are_sk_nonce_valid = 0)) (ensures fun h0 res h1 -> modifies0 h0 h1 /\ res == ((v are_sk_nonce_valid = ones_v U64) && (0 < as_nat h0 r_q) && (0 < as_nat h0 s_q)))
[]
Hacl.Impl.P256.Sign.check_signature
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Sign.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
are_sk_nonce_valid: Lib.IntTypes.uint64 -> r_q: Hacl.Impl.P256.Bignum.felem -> s_q: Hacl.Impl.P256.Bignum.felem -> FStar.HyperStack.ST.Stack Prims.bool
{ "end_col": 26, "end_line": 133, "start_col": 48, "start_line": 119 }
FStar.HyperStack.ST.Stack
val ecdsa_sign_load (d_a k_q:felem) (private_key nonce:lbytes 32ul) : Stack uint64 (requires fun h -> live h private_key /\ live h nonce /\ live h d_a /\ live h k_q /\ disjoint d_a k_q /\ disjoint d_a private_key /\ disjoint d_a nonce /\ disjoint k_q private_key /\ disjoint k_q nonce) (ensures fun h0 m h1 -> modifies (loc d_a |+| loc k_q) h0 h1 /\ (let d_a_nat = BSeq.nat_from_bytes_be (as_seq h0 private_key) in let k_nat = BSeq.nat_from_bytes_be (as_seq h0 nonce) in let is_sk_valid = 0 < d_a_nat && d_a_nat < S.order in let is_nonce_valid = 0 < k_nat && k_nat < S.order in (v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = (is_sk_valid && is_nonce_valid) /\ as_nat h1 d_a == (if is_sk_valid then d_a_nat else 1) /\ as_nat h1 k_q == (if is_nonce_valid then k_nat else 1)))
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Impl.P256.Qinv", "short_module": "QI" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.PointMul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Scalar", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ecdsa_sign_load d_a k_q private_key nonce = let is_sk_valid = load_qelem_conditional d_a private_key in let is_nonce_valid = load_qelem_conditional k_q nonce in let m = is_sk_valid &. is_nonce_valid in logand_lemma is_sk_valid is_nonce_valid; m
val ecdsa_sign_load (d_a k_q:felem) (private_key nonce:lbytes 32ul) : Stack uint64 (requires fun h -> live h private_key /\ live h nonce /\ live h d_a /\ live h k_q /\ disjoint d_a k_q /\ disjoint d_a private_key /\ disjoint d_a nonce /\ disjoint k_q private_key /\ disjoint k_q nonce) (ensures fun h0 m h1 -> modifies (loc d_a |+| loc k_q) h0 h1 /\ (let d_a_nat = BSeq.nat_from_bytes_be (as_seq h0 private_key) in let k_nat = BSeq.nat_from_bytes_be (as_seq h0 nonce) in let is_sk_valid = 0 < d_a_nat && d_a_nat < S.order in let is_nonce_valid = 0 < k_nat && k_nat < S.order in (v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = (is_sk_valid && is_nonce_valid) /\ as_nat h1 d_a == (if is_sk_valid then d_a_nat else 1) /\ as_nat h1 k_q == (if is_nonce_valid then k_nat else 1))) let ecdsa_sign_load d_a k_q private_key nonce =
true
null
false
let is_sk_valid = load_qelem_conditional d_a private_key in let is_nonce_valid = load_qelem_conditional k_q nonce in let m = is_sk_valid &. is_nonce_valid in logand_lemma is_sk_valid is_nonce_valid; m
{ "checked_file": "Hacl.Impl.P256.Sign.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Scalar.fsti.checked", "Hacl.Impl.P256.Qinv.fsti.checked", "Hacl.Impl.P256.PointMul.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Sign.fst" }
[]
[ "Hacl.Impl.P256.Bignum.felem", "Hacl.Impl.P256.Sign.lbytes", "FStar.UInt32.__uint_to_t", "Prims.unit", "Lib.IntTypes.logand_lemma", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.uint64", "Hacl.Impl.P256.Scalar.load_qelem_conditional" ]
[]
module Hacl.Impl.P256.Sign open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Scalar open Hacl.Impl.P256.Point open Hacl.Impl.P256.PointMul module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module QI = Hacl.Impl.P256.Qinv module BB = Hacl.Bignum.Base module BSeq = Lib.ByteSequence #set-options "--z3rlimit 50 --ifuel 0 --fuel 0" inline_for_extraction noextract let lbytes len = lbuffer uint8 len inline_for_extraction noextract val ecdsa_sign_r (r k:felem) : Stack unit (requires fun h -> live h r /\ live h k /\ disjoint r k /\ as_nat h k < S.order) (ensures fun h0 _ h1 -> modifies (loc r) h0 h1 /\ (let x, _ = S.to_aff_point (S.point_mul_g (as_nat h0 k)) in as_nat h1 r == x % S.order)) let ecdsa_sign_r r k = push_frame (); let p = create_point () in point_mul_g p k; // p = [k]G to_aff_point_x r p; qmod_short r r; pop_frame () inline_for_extraction noextract val ecdsa_sign_s (s k r d_a m:felem) : Stack unit (requires fun h -> live h s /\ live h m /\ live h d_a /\ live h k /\ live h r /\ disjoint s r /\ disjoint s k /\ disjoint r k /\ disjoint s d_a /\ disjoint r d_a /\ disjoint m s /\ 0 < as_nat h k /\ as_nat h k < S.order /\ as_nat h r < S.order /\ as_nat h m < S.order /\ 0 < as_nat h d_a /\ as_nat h d_a < S.order) (ensures fun h0 _ h1 -> modifies (loc s |+| loc m) h0 h1 /\ (let kinv = S.qinv (as_nat h0 k) in as_nat h1 s == S.qmul kinv (S.qadd (as_nat h0 m) (S.qmul (as_nat h0 r) (as_nat h0 d_a))))) let ecdsa_sign_s s k r d_a m = push_frame (); let h0 = ST.get () in let kinv = create_felem () in QI.qinv kinv k; let h1 = ST.get () in assert (qmont_as_nat h1 kinv == S.qinv (qmont_as_nat h0 k)); SM.qmont_inv_lemma (as_nat h0 k); assert (qmont_as_nat h1 kinv == S.qinv (as_nat h0 k) * SM.qmont_R % S.order); qmul s r d_a; // s = r * d_a let h2 = ST.get () in assert (as_nat h2 s == (as_nat h0 r * as_nat h0 d_a * SM.qmont_R_inv) % S.order); from_qmont m m; let h3 = ST.get () in assert (as_nat h3 m == as_nat h2 m * SM.qmont_R_inv % S.order); qadd s m s; // s = z + s let h4 = ST.get () in assert (as_nat h4 s == (as_nat h3 m + as_nat h2 s) % S.order); qmul s kinv s; // s = kinv * s let h5 = ST.get () in assert (as_nat h5 s == (as_nat h1 kinv * as_nat h4 s * SM.qmont_R_inv) % S.order); SM.lemma_ecdsa_sign_s (as_nat h0 k) (as_nat h1 kinv) (as_nat h0 r) (as_nat h0 d_a) (as_nat h0 m); pop_frame () inline_for_extraction noextract val ecdsa_sign_load (d_a k_q:felem) (private_key nonce:lbytes 32ul) : Stack uint64 (requires fun h -> live h private_key /\ live h nonce /\ live h d_a /\ live h k_q /\ disjoint d_a k_q /\ disjoint d_a private_key /\ disjoint d_a nonce /\ disjoint k_q private_key /\ disjoint k_q nonce) (ensures fun h0 m h1 -> modifies (loc d_a |+| loc k_q) h0 h1 /\ (let d_a_nat = BSeq.nat_from_bytes_be (as_seq h0 private_key) in let k_nat = BSeq.nat_from_bytes_be (as_seq h0 nonce) in let is_sk_valid = 0 < d_a_nat && d_a_nat < S.order in let is_nonce_valid = 0 < k_nat && k_nat < S.order in (v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = (is_sk_valid && is_nonce_valid) /\ as_nat h1 d_a == (if is_sk_valid then d_a_nat else 1) /\ as_nat h1 k_q == (if is_nonce_valid then k_nat else 1)))
false
false
Hacl.Impl.P256.Sign.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ecdsa_sign_load (d_a k_q:felem) (private_key nonce:lbytes 32ul) : Stack uint64 (requires fun h -> live h private_key /\ live h nonce /\ live h d_a /\ live h k_q /\ disjoint d_a k_q /\ disjoint d_a private_key /\ disjoint d_a nonce /\ disjoint k_q private_key /\ disjoint k_q nonce) (ensures fun h0 m h1 -> modifies (loc d_a |+| loc k_q) h0 h1 /\ (let d_a_nat = BSeq.nat_from_bytes_be (as_seq h0 private_key) in let k_nat = BSeq.nat_from_bytes_be (as_seq h0 nonce) in let is_sk_valid = 0 < d_a_nat && d_a_nat < S.order in let is_nonce_valid = 0 < k_nat && k_nat < S.order in (v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = (is_sk_valid && is_nonce_valid) /\ as_nat h1 d_a == (if is_sk_valid then d_a_nat else 1) /\ as_nat h1 k_q == (if is_nonce_valid then k_nat else 1)))
[]
Hacl.Impl.P256.Sign.ecdsa_sign_load
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Sign.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
d_a: Hacl.Impl.P256.Bignum.felem -> k_q: Hacl.Impl.P256.Bignum.felem -> private_key: Hacl.Impl.P256.Sign.lbytes 32ul -> nonce: Hacl.Impl.P256.Sign.lbytes 32ul -> FStar.HyperStack.ST.Stack Lib.IntTypes.uint64
{ "end_col": 3, "end_line": 108, "start_col": 47, "start_line": 103 }
FStar.HyperStack.ST.Stack
val ecdsa_sign_r (r k:felem) : Stack unit (requires fun h -> live h r /\ live h k /\ disjoint r k /\ as_nat h k < S.order) (ensures fun h0 _ h1 -> modifies (loc r) h0 h1 /\ (let x, _ = S.to_aff_point (S.point_mul_g (as_nat h0 k)) in as_nat h1 r == x % S.order))
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Impl.P256.Qinv", "short_module": "QI" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.PointMul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Scalar", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ecdsa_sign_r r k = push_frame (); let p = create_point () in point_mul_g p k; // p = [k]G to_aff_point_x r p; qmod_short r r; pop_frame ()
val ecdsa_sign_r (r k:felem) : Stack unit (requires fun h -> live h r /\ live h k /\ disjoint r k /\ as_nat h k < S.order) (ensures fun h0 _ h1 -> modifies (loc r) h0 h1 /\ (let x, _ = S.to_aff_point (S.point_mul_g (as_nat h0 k)) in as_nat h1 r == x % S.order)) let ecdsa_sign_r r k =
true
null
false
push_frame (); let p = create_point () in point_mul_g p k; to_aff_point_x r p; qmod_short r r; pop_frame ()
{ "checked_file": "Hacl.Impl.P256.Sign.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Scalar.fsti.checked", "Hacl.Impl.P256.Qinv.fsti.checked", "Hacl.Impl.P256.PointMul.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Sign.fst" }
[]
[ "Hacl.Impl.P256.Bignum.felem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.P256.Scalar.qmod_short", "Hacl.Impl.P256.Point.to_aff_point_x", "Hacl.Impl.P256.PointMul.point_mul_g", "Hacl.Impl.P256.Point.point", "Hacl.Impl.P256.Point.create_point", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.P256.Sign open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Scalar open Hacl.Impl.P256.Point open Hacl.Impl.P256.PointMul module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module QI = Hacl.Impl.P256.Qinv module BB = Hacl.Bignum.Base module BSeq = Lib.ByteSequence #set-options "--z3rlimit 50 --ifuel 0 --fuel 0" inline_for_extraction noextract let lbytes len = lbuffer uint8 len inline_for_extraction noextract val ecdsa_sign_r (r k:felem) : Stack unit (requires fun h -> live h r /\ live h k /\ disjoint r k /\ as_nat h k < S.order) (ensures fun h0 _ h1 -> modifies (loc r) h0 h1 /\ (let x, _ = S.to_aff_point (S.point_mul_g (as_nat h0 k)) in as_nat h1 r == x % S.order))
false
false
Hacl.Impl.P256.Sign.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ecdsa_sign_r (r k:felem) : Stack unit (requires fun h -> live h r /\ live h k /\ disjoint r k /\ as_nat h k < S.order) (ensures fun h0 _ h1 -> modifies (loc r) h0 h1 /\ (let x, _ = S.to_aff_point (S.point_mul_g (as_nat h0 k)) in as_nat h1 r == x % S.order))
[]
Hacl.Impl.P256.Sign.ecdsa_sign_r
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Sign.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r: Hacl.Impl.P256.Bignum.felem -> k: Hacl.Impl.P256.Bignum.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 43, "start_col": 2, "start_line": 38 }
FStar.HyperStack.ST.Stack
val ecdsa_sign_s (s k r d_a m:felem) : Stack unit (requires fun h -> live h s /\ live h m /\ live h d_a /\ live h k /\ live h r /\ disjoint s r /\ disjoint s k /\ disjoint r k /\ disjoint s d_a /\ disjoint r d_a /\ disjoint m s /\ 0 < as_nat h k /\ as_nat h k < S.order /\ as_nat h r < S.order /\ as_nat h m < S.order /\ 0 < as_nat h d_a /\ as_nat h d_a < S.order) (ensures fun h0 _ h1 -> modifies (loc s |+| loc m) h0 h1 /\ (let kinv = S.qinv (as_nat h0 k) in as_nat h1 s == S.qmul kinv (S.qadd (as_nat h0 m) (S.qmul (as_nat h0 r) (as_nat h0 d_a)))))
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Impl.P256.Qinv", "short_module": "QI" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.PointMul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Scalar", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ecdsa_sign_s s k r d_a m = push_frame (); let h0 = ST.get () in let kinv = create_felem () in QI.qinv kinv k; let h1 = ST.get () in assert (qmont_as_nat h1 kinv == S.qinv (qmont_as_nat h0 k)); SM.qmont_inv_lemma (as_nat h0 k); assert (qmont_as_nat h1 kinv == S.qinv (as_nat h0 k) * SM.qmont_R % S.order); qmul s r d_a; // s = r * d_a let h2 = ST.get () in assert (as_nat h2 s == (as_nat h0 r * as_nat h0 d_a * SM.qmont_R_inv) % S.order); from_qmont m m; let h3 = ST.get () in assert (as_nat h3 m == as_nat h2 m * SM.qmont_R_inv % S.order); qadd s m s; // s = z + s let h4 = ST.get () in assert (as_nat h4 s == (as_nat h3 m + as_nat h2 s) % S.order); qmul s kinv s; // s = kinv * s let h5 = ST.get () in assert (as_nat h5 s == (as_nat h1 kinv * as_nat h4 s * SM.qmont_R_inv) % S.order); SM.lemma_ecdsa_sign_s (as_nat h0 k) (as_nat h1 kinv) (as_nat h0 r) (as_nat h0 d_a) (as_nat h0 m); pop_frame ()
val ecdsa_sign_s (s k r d_a m:felem) : Stack unit (requires fun h -> live h s /\ live h m /\ live h d_a /\ live h k /\ live h r /\ disjoint s r /\ disjoint s k /\ disjoint r k /\ disjoint s d_a /\ disjoint r d_a /\ disjoint m s /\ 0 < as_nat h k /\ as_nat h k < S.order /\ as_nat h r < S.order /\ as_nat h m < S.order /\ 0 < as_nat h d_a /\ as_nat h d_a < S.order) (ensures fun h0 _ h1 -> modifies (loc s |+| loc m) h0 h1 /\ (let kinv = S.qinv (as_nat h0 k) in as_nat h1 s == S.qmul kinv (S.qadd (as_nat h0 m) (S.qmul (as_nat h0 r) (as_nat h0 d_a))))) let ecdsa_sign_s s k r d_a m =
true
null
false
push_frame (); let h0 = ST.get () in let kinv = create_felem () in QI.qinv kinv k; let h1 = ST.get () in assert (qmont_as_nat h1 kinv == S.qinv (qmont_as_nat h0 k)); SM.qmont_inv_lemma (as_nat h0 k); assert (qmont_as_nat h1 kinv == S.qinv (as_nat h0 k) * SM.qmont_R % S.order); qmul s r d_a; let h2 = ST.get () in assert (as_nat h2 s == ((as_nat h0 r * as_nat h0 d_a) * SM.qmont_R_inv) % S.order); from_qmont m m; let h3 = ST.get () in assert (as_nat h3 m == as_nat h2 m * SM.qmont_R_inv % S.order); qadd s m s; let h4 = ST.get () in assert (as_nat h4 s == (as_nat h3 m + as_nat h2 s) % S.order); qmul s kinv s; let h5 = ST.get () in assert (as_nat h5 s == ((as_nat h1 kinv * as_nat h4 s) * SM.qmont_R_inv) % S.order); SM.lemma_ecdsa_sign_s (as_nat h0 k) (as_nat h1 kinv) (as_nat h0 r) (as_nat h0 d_a) (as_nat h0 m); pop_frame ()
{ "checked_file": "Hacl.Impl.P256.Sign.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Scalar.fsti.checked", "Hacl.Impl.P256.Qinv.fsti.checked", "Hacl.Impl.P256.PointMul.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Sign.fst" }
[]
[ "Hacl.Impl.P256.Bignum.felem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Spec.P256.Montgomery.lemma_ecdsa_sign_s", "Hacl.Impl.P256.Bignum.as_nat", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Mul.op_Star", "Hacl.Spec.P256.Montgomery.qmont_R_inv", "Spec.P256.PointOps.order", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.P256.Scalar.qmul", "Prims.op_Addition", "Hacl.Impl.P256.Scalar.qadd", "Hacl.Impl.P256.Scalar.from_qmont", "Hacl.Impl.P256.Scalar.qmont_as_nat", "Spec.P256.PointOps.qinv", "Hacl.Spec.P256.Montgomery.qmont_R", "Hacl.Spec.P256.Montgomery.qmont_inv_lemma", "Spec.P256.PointOps.qelem", "Hacl.Impl.P256.Qinv.qinv", "Hacl.Impl.P256.Bignum.create_felem", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.P256.Sign open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Scalar open Hacl.Impl.P256.Point open Hacl.Impl.P256.PointMul module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module QI = Hacl.Impl.P256.Qinv module BB = Hacl.Bignum.Base module BSeq = Lib.ByteSequence #set-options "--z3rlimit 50 --ifuel 0 --fuel 0" inline_for_extraction noextract let lbytes len = lbuffer uint8 len inline_for_extraction noextract val ecdsa_sign_r (r k:felem) : Stack unit (requires fun h -> live h r /\ live h k /\ disjoint r k /\ as_nat h k < S.order) (ensures fun h0 _ h1 -> modifies (loc r) h0 h1 /\ (let x, _ = S.to_aff_point (S.point_mul_g (as_nat h0 k)) in as_nat h1 r == x % S.order)) let ecdsa_sign_r r k = push_frame (); let p = create_point () in point_mul_g p k; // p = [k]G to_aff_point_x r p; qmod_short r r; pop_frame () inline_for_extraction noextract val ecdsa_sign_s (s k r d_a m:felem) : Stack unit (requires fun h -> live h s /\ live h m /\ live h d_a /\ live h k /\ live h r /\ disjoint s r /\ disjoint s k /\ disjoint r k /\ disjoint s d_a /\ disjoint r d_a /\ disjoint m s /\ 0 < as_nat h k /\ as_nat h k < S.order /\ as_nat h r < S.order /\ as_nat h m < S.order /\ 0 < as_nat h d_a /\ as_nat h d_a < S.order) (ensures fun h0 _ h1 -> modifies (loc s |+| loc m) h0 h1 /\ (let kinv = S.qinv (as_nat h0 k) in as_nat h1 s == S.qmul kinv (S.qadd (as_nat h0 m) (S.qmul (as_nat h0 r) (as_nat h0 d_a)))))
false
false
Hacl.Impl.P256.Sign.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ecdsa_sign_s (s k r d_a m:felem) : Stack unit (requires fun h -> live h s /\ live h m /\ live h d_a /\ live h k /\ live h r /\ disjoint s r /\ disjoint s k /\ disjoint r k /\ disjoint s d_a /\ disjoint r d_a /\ disjoint m s /\ 0 < as_nat h k /\ as_nat h k < S.order /\ as_nat h r < S.order /\ as_nat h m < S.order /\ 0 < as_nat h d_a /\ as_nat h d_a < S.order) (ensures fun h0 _ h1 -> modifies (loc s |+| loc m) h0 h1 /\ (let kinv = S.qinv (as_nat h0 k) in as_nat h1 s == S.qmul kinv (S.qadd (as_nat h0 m) (S.qmul (as_nat h0 r) (as_nat h0 d_a)))))
[]
Hacl.Impl.P256.Sign.ecdsa_sign_s
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Sign.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Hacl.Impl.P256.Bignum.felem -> k: Hacl.Impl.P256.Bignum.felem -> r: Hacl.Impl.P256.Bignum.felem -> d_a: Hacl.Impl.P256.Bignum.felem -> m: Hacl.Impl.P256.Bignum.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 84, "start_col": 2, "start_line": 61 }
FStar.HyperStack.ST.Stack
val ecdsa_sign_msg_as_qelem: signature:lbuffer uint8 64ul -> m_q:felem -> private_key:lbuffer uint8 32ul -> nonce:lbuffer uint8 32ul -> Stack bool (requires fun h -> live h signature /\ live h m_q /\ live h private_key /\ live h nonce /\ disjoint signature m_q /\ disjoint signature private_key /\ disjoint signature nonce /\ disjoint m_q private_key /\ disjoint m_q nonce /\ as_nat h m_q < S.order) (ensures fun h0 flag h1 -> modifies (loc signature |+| loc m_q) h0 h1 /\ (let sgnt = S.ecdsa_sign_msg_as_qelem (as_nat h0 m_q) (as_seq h0 private_key) (as_seq h0 nonce) in (flag <==> Some? sgnt) /\ (flag ==> (as_seq h1 signature == Some?.v sgnt))))
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Impl.P256.Qinv", "short_module": "QI" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.PointMul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Scalar", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ecdsa_sign_msg_as_qelem signature m_q private_key nonce = push_frame (); let rsdk_q = create 16ul (u64 0) in let r_q = sub rsdk_q 0ul 4ul in let s_q = sub rsdk_q 4ul 4ul in let d_a = sub rsdk_q 8ul 4ul in let k_q = sub rsdk_q 12ul 4ul in let are_sk_nonce_valid = ecdsa_sign_load d_a k_q private_key nonce in ecdsa_sign_r r_q k_q; ecdsa_sign_s s_q k_q r_q d_a m_q; bn2_to_bytes_be4 signature r_q s_q; let res = check_signature are_sk_nonce_valid r_q s_q in pop_frame (); res
val ecdsa_sign_msg_as_qelem: signature:lbuffer uint8 64ul -> m_q:felem -> private_key:lbuffer uint8 32ul -> nonce:lbuffer uint8 32ul -> Stack bool (requires fun h -> live h signature /\ live h m_q /\ live h private_key /\ live h nonce /\ disjoint signature m_q /\ disjoint signature private_key /\ disjoint signature nonce /\ disjoint m_q private_key /\ disjoint m_q nonce /\ as_nat h m_q < S.order) (ensures fun h0 flag h1 -> modifies (loc signature |+| loc m_q) h0 h1 /\ (let sgnt = S.ecdsa_sign_msg_as_qelem (as_nat h0 m_q) (as_seq h0 private_key) (as_seq h0 nonce) in (flag <==> Some? sgnt) /\ (flag ==> (as_seq h1 signature == Some?.v sgnt)))) let ecdsa_sign_msg_as_qelem signature m_q private_key nonce =
true
null
false
push_frame (); let rsdk_q = create 16ul (u64 0) in let r_q = sub rsdk_q 0ul 4ul in let s_q = sub rsdk_q 4ul 4ul in let d_a = sub rsdk_q 8ul 4ul in let k_q = sub rsdk_q 12ul 4ul in let are_sk_nonce_valid = ecdsa_sign_load d_a k_q private_key nonce in ecdsa_sign_r r_q k_q; ecdsa_sign_s s_q k_q r_q d_a m_q; bn2_to_bytes_be4 signature r_q s_q; let res = check_signature are_sk_nonce_valid r_q s_q in pop_frame (); res
{ "checked_file": "Hacl.Impl.P256.Sign.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Scalar.fsti.checked", "Hacl.Impl.P256.Qinv.fsti.checked", "Hacl.Impl.P256.PointMul.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Bignum.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Sign.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Impl.P256.Bignum.felem", "Prims.bool", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Impl.P256.Sign.check_signature", "Hacl.Impl.P256.Bignum.bn2_to_bytes_be4", "Hacl.Impl.P256.Sign.ecdsa_sign_s", "Hacl.Impl.P256.Sign.ecdsa_sign_r", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.Impl.P256.Sign.ecdsa_sign_load", "Lib.IntTypes.uint64", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "Lib.Buffer.create", "Lib.IntTypes.u64", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.P256.Sign open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Scalar open Hacl.Impl.P256.Point open Hacl.Impl.P256.PointMul module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery module QI = Hacl.Impl.P256.Qinv module BB = Hacl.Bignum.Base module BSeq = Lib.ByteSequence #set-options "--z3rlimit 50 --ifuel 0 --fuel 0" inline_for_extraction noextract let lbytes len = lbuffer uint8 len inline_for_extraction noextract val ecdsa_sign_r (r k:felem) : Stack unit (requires fun h -> live h r /\ live h k /\ disjoint r k /\ as_nat h k < S.order) (ensures fun h0 _ h1 -> modifies (loc r) h0 h1 /\ (let x, _ = S.to_aff_point (S.point_mul_g (as_nat h0 k)) in as_nat h1 r == x % S.order)) let ecdsa_sign_r r k = push_frame (); let p = create_point () in point_mul_g p k; // p = [k]G to_aff_point_x r p; qmod_short r r; pop_frame () inline_for_extraction noextract val ecdsa_sign_s (s k r d_a m:felem) : Stack unit (requires fun h -> live h s /\ live h m /\ live h d_a /\ live h k /\ live h r /\ disjoint s r /\ disjoint s k /\ disjoint r k /\ disjoint s d_a /\ disjoint r d_a /\ disjoint m s /\ 0 < as_nat h k /\ as_nat h k < S.order /\ as_nat h r < S.order /\ as_nat h m < S.order /\ 0 < as_nat h d_a /\ as_nat h d_a < S.order) (ensures fun h0 _ h1 -> modifies (loc s |+| loc m) h0 h1 /\ (let kinv = S.qinv (as_nat h0 k) in as_nat h1 s == S.qmul kinv (S.qadd (as_nat h0 m) (S.qmul (as_nat h0 r) (as_nat h0 d_a))))) let ecdsa_sign_s s k r d_a m = push_frame (); let h0 = ST.get () in let kinv = create_felem () in QI.qinv kinv k; let h1 = ST.get () in assert (qmont_as_nat h1 kinv == S.qinv (qmont_as_nat h0 k)); SM.qmont_inv_lemma (as_nat h0 k); assert (qmont_as_nat h1 kinv == S.qinv (as_nat h0 k) * SM.qmont_R % S.order); qmul s r d_a; // s = r * d_a let h2 = ST.get () in assert (as_nat h2 s == (as_nat h0 r * as_nat h0 d_a * SM.qmont_R_inv) % S.order); from_qmont m m; let h3 = ST.get () in assert (as_nat h3 m == as_nat h2 m * SM.qmont_R_inv % S.order); qadd s m s; // s = z + s let h4 = ST.get () in assert (as_nat h4 s == (as_nat h3 m + as_nat h2 s) % S.order); qmul s kinv s; // s = kinv * s let h5 = ST.get () in assert (as_nat h5 s == (as_nat h1 kinv * as_nat h4 s * SM.qmont_R_inv) % S.order); SM.lemma_ecdsa_sign_s (as_nat h0 k) (as_nat h1 kinv) (as_nat h0 r) (as_nat h0 d_a) (as_nat h0 m); pop_frame () inline_for_extraction noextract val ecdsa_sign_load (d_a k_q:felem) (private_key nonce:lbytes 32ul) : Stack uint64 (requires fun h -> live h private_key /\ live h nonce /\ live h d_a /\ live h k_q /\ disjoint d_a k_q /\ disjoint d_a private_key /\ disjoint d_a nonce /\ disjoint k_q private_key /\ disjoint k_q nonce) (ensures fun h0 m h1 -> modifies (loc d_a |+| loc k_q) h0 h1 /\ (let d_a_nat = BSeq.nat_from_bytes_be (as_seq h0 private_key) in let k_nat = BSeq.nat_from_bytes_be (as_seq h0 nonce) in let is_sk_valid = 0 < d_a_nat && d_a_nat < S.order in let is_nonce_valid = 0 < k_nat && k_nat < S.order in (v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = (is_sk_valid && is_nonce_valid) /\ as_nat h1 d_a == (if is_sk_valid then d_a_nat else 1) /\ as_nat h1 k_q == (if is_nonce_valid then k_nat else 1))) let ecdsa_sign_load d_a k_q private_key nonce = let is_sk_valid = load_qelem_conditional d_a private_key in let is_nonce_valid = load_qelem_conditional k_q nonce in let m = is_sk_valid &. is_nonce_valid in logand_lemma is_sk_valid is_nonce_valid; m inline_for_extraction noextract val check_signature: are_sk_nonce_valid:uint64 -> r_q:felem -> s_q:felem -> Stack bool (requires fun h -> live h r_q /\ live h s_q /\ disjoint r_q s_q /\ (v are_sk_nonce_valid = ones_v U64 \/ v are_sk_nonce_valid = 0)) (ensures fun h0 res h1 -> modifies0 h0 h1 /\ res == ((v are_sk_nonce_valid = ones_v U64) && (0 < as_nat h0 r_q) && (0 < as_nat h0 s_q))) let check_signature are_sk_nonce_valid r_q s_q = let h0 = ST.get () in let is_r_zero = bn_is_zero_mask4 r_q in let is_s_zero = bn_is_zero_mask4 s_q in [@inline_let] let m0 = lognot is_r_zero in [@inline_let] let m1 = lognot is_s_zero in [@inline_let] let m2 = m0 &. m1 in lognot_lemma is_r_zero; lognot_lemma is_s_zero; logand_lemma m0 m1; let m = are_sk_nonce_valid &. m2 in logand_lemma are_sk_nonce_valid m2; assert ((v m = ones_v U64) <==> ((v are_sk_nonce_valid = ones_v U64) && (0 < as_nat h0 r_q) && (0 < as_nat h0 s_q))); BB.unsafe_bool_of_limb m val ecdsa_sign_msg_as_qelem: signature:lbuffer uint8 64ul -> m_q:felem -> private_key:lbuffer uint8 32ul -> nonce:lbuffer uint8 32ul -> Stack bool (requires fun h -> live h signature /\ live h m_q /\ live h private_key /\ live h nonce /\ disjoint signature m_q /\ disjoint signature private_key /\ disjoint signature nonce /\ disjoint m_q private_key /\ disjoint m_q nonce /\ as_nat h m_q < S.order) (ensures fun h0 flag h1 -> modifies (loc signature |+| loc m_q) h0 h1 /\ (let sgnt = S.ecdsa_sign_msg_as_qelem (as_nat h0 m_q) (as_seq h0 private_key) (as_seq h0 nonce) in (flag <==> Some? sgnt) /\ (flag ==> (as_seq h1 signature == Some?.v sgnt)))) [@CInline]
false
false
Hacl.Impl.P256.Sign.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ecdsa_sign_msg_as_qelem: signature:lbuffer uint8 64ul -> m_q:felem -> private_key:lbuffer uint8 32ul -> nonce:lbuffer uint8 32ul -> Stack bool (requires fun h -> live h signature /\ live h m_q /\ live h private_key /\ live h nonce /\ disjoint signature m_q /\ disjoint signature private_key /\ disjoint signature nonce /\ disjoint m_q private_key /\ disjoint m_q nonce /\ as_nat h m_q < S.order) (ensures fun h0 flag h1 -> modifies (loc signature |+| loc m_q) h0 h1 /\ (let sgnt = S.ecdsa_sign_msg_as_qelem (as_nat h0 m_q) (as_seq h0 private_key) (as_seq h0 nonce) in (flag <==> Some? sgnt) /\ (flag ==> (as_seq h1 signature == Some?.v sgnt))))
[]
Hacl.Impl.P256.Sign.ecdsa_sign_msg_as_qelem
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Sign.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
signature: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> m_q: Hacl.Impl.P256.Bignum.felem -> private_key: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> nonce: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Prims.bool
{ "end_col": 5, "end_line": 166, "start_col": 2, "start_line": 154 }
Prims.Tot
val parse32_empty:parser32 parse_empty
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_empty : parser32 parse_empty = parse32_ret ()
val parse32_empty:parser32 parse_empty let parse32_empty:parser32 parse_empty =
false
null
false
parse32_ret ()
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.SLow.Combinators.parse32_ret", "Prims.unit" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } )))
false
true
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_empty:parser32 parse_empty
[]
LowParse.SLow.Combinators.parse32_empty
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.parser32 LowParse.Spec.Combinators.parse_empty
{ "end_col": 57, "end_line": 18, "start_col": 43, "start_line": 18 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u
let serialize32_synth' (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (s1: serializer p1) (s1': serializer32 s1) (g1: (t2 -> Tot t1)) (u: unit{synth_inverse f2 g1 /\ synth_injective f2}) =
false
null
false
serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "Prims.unit", "Prims.l_and", "LowParse.Spec.Combinators.synth_inverse", "LowParse.Spec.Combinators.synth_injective", "LowParse.SLow.Combinators.serialize32_synth", "Prims.eq2", "LowParse.Spec.Combinators.parse_synth", "LowParse.Spec.Combinators.serialize_synth" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_synth' : p1: LowParse.Spec.Base.parser k t1 -> f2: (_: t1 -> Prims.GTot t2) -> s1: LowParse.Spec.Base.serializer p1 -> s1': LowParse.SLow.Base.serializer32 s1 -> g1: (_: t2 -> t1) -> u103: u106: Prims.unit { LowParse.Spec.Combinators.synth_inverse f2 g1 /\ LowParse.Spec.Combinators.synth_injective f2 } -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Combinators.serialize_synth p1 f2 s1 g1 u103)
[]
LowParse.SLow.Combinators.serialize32_synth'
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1: LowParse.Spec.Base.parser k t1 -> f2: (_: t1 -> Prims.GTot t2) -> s1: LowParse.Spec.Base.serializer p1 -> s1': LowParse.SLow.Base.serializer32 s1 -> g1: (_: t2 -> t1) -> u103: u106: Prims.unit { LowParse.Spec.Combinators.synth_inverse f2 g1 /\ LowParse.Spec.Combinators.synth_injective f2 } -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Combinators.serialize_synth p1 f2 s1 g1 u103)
{ "end_col": 53, "end_line": 288, "start_col": 2, "start_line": 288 }
Prims.Tot
val parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (p32: (k: kt1 -> Tot (parser32 (p k)))) (k: kt2) : Tot (parser32 (p (f k)))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (p32: ((k: kt1) -> Tot (parser32 (p k)))) (k: kt2) : Tot (parser32 (p (f k))) = fun input -> p32 (f k) input
val parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (p32: (k: kt1 -> Tot (parser32 (p k)))) (k: kt2) : Tot (parser32 (p (f k))) let parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (p32: (k: kt1 -> Tot (parser32 (p k)))) (k: kt2) : Tot (parser32 (p (f k))) =
false
null
false
fun input -> p32 (f k) input
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.SLow.Base.bytes32", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "FStar.UInt32.t", "LowParse.SLow.Base.parser32_correct" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } )) inline_for_extraction let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x))) : Tot (size32 (serialize_dtuple2 s1 s2)) = fun x -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_dtuple2 s1 s2) x z } )) inline_for_extraction let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun x -> s32 x inline_for_extraction let size32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in [@inline_let] let x = g1' input in [@inline_let] let y = s1' x in (y <: (res: U32.t { size32_postcond (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let size32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = size32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (p32: ((k: kt1) -> Tot (parser32 (p k)))) (k: kt2)
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (p32: (k: kt1 -> Tot (parser32 (p k)))) (k: kt2) : Tot (parser32 (p (f k)))
[]
LowParse.SLow.Combinators.parse32_compose_context
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
f: (_: kt2 -> kt1) -> t: (_: kt1 -> Type) -> p: (k: kt1 -> LowParse.Spec.Base.parser pk (t k)) -> p32: (k: kt1 -> LowParse.SLow.Base.parser32 (p k)) -> k: kt2 -> LowParse.SLow.Base.parser32 (p (f k))
{ "end_col": 30, "end_line": 470, "start_col": 2, "start_line": 470 }
Prims.Tot
val serialize32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (s: (k: kt1 -> Tot (serializer (p k)))) (s32: (k: kt1 -> Tot (serializer32 (s k)))) (k: kt2) : Tot (serializer32 (s (f k)))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (serializer32 (s k)))) (k: kt2) : Tot (serializer32 (s (f k))) = fun input -> s32 (f k) input
val serialize32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (s: (k: kt1 -> Tot (serializer (p k)))) (s32: (k: kt1 -> Tot (serializer32 (s k)))) (k: kt2) : Tot (serializer32 (s (f k))) let serialize32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (s: (k: kt1 -> Tot (serializer (p k)))) (s32: (k: kt1 -> Tot (serializer32 (s k)))) (k: kt2) : Tot (serializer32 (s (f k))) =
false
null
false
fun input -> s32 (f k) input
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } )) inline_for_extraction let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x))) : Tot (size32 (serialize_dtuple2 s1 s2)) = fun x -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_dtuple2 s1 s2) x z } )) inline_for_extraction let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun x -> s32 x inline_for_extraction let size32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in [@inline_let] let x = g1' input in [@inline_let] let y = s1' x in (y <: (res: U32.t { size32_postcond (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let size32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = size32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (p32: ((k: kt1) -> Tot (parser32 (p k)))) (k: kt2) : Tot (parser32 (p (f k))) = fun input -> p32 (f k) input inline_for_extraction let serialize32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (serializer32 (s k)))) (k: kt2)
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (s: (k: kt1 -> Tot (serializer (p k)))) (s32: (k: kt1 -> Tot (serializer32 (s k)))) (k: kt2) : Tot (serializer32 (s (f k)))
[]
LowParse.SLow.Combinators.serialize32_compose_context
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
f: (_: kt2 -> kt1) -> t: (_: kt1 -> Type) -> p: (k: kt1 -> LowParse.Spec.Base.parser pk (t k)) -> s: (k: kt1 -> LowParse.Spec.Base.serializer (p k)) -> s32: (k: kt1 -> LowParse.SLow.Base.serializer32 (s k)) -> k: kt2 -> LowParse.SLow.Base.serializer32 (s (f k))
{ "end_col": 30, "end_line": 483, "start_col": 2, "start_line": 483 }
Prims.Tot
val size32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (s: (k: kt1 -> Tot (serializer (p k)))) (s32: (k: kt1 -> Tot (size32 (s k)))) (k: kt2) : Tot (size32 (s (f k)))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (size32 (s k)))) (k: kt2) : Tot (size32 (s (f k))) = fun input -> s32 (f k) input
val size32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (s: (k: kt1 -> Tot (serializer (p k)))) (s32: (k: kt1 -> Tot (size32 (s k)))) (k: kt2) : Tot (size32 (s (f k))) let size32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (s: (k: kt1 -> Tot (serializer (p k)))) (s32: (k: kt1 -> Tot (size32 (s k)))) (k: kt2) : Tot (size32 (s (f k))) =
false
null
false
fun input -> s32 (f k) input
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "FStar.UInt32.t", "LowParse.SLow.Base.size32_postcond" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } )) inline_for_extraction let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x))) : Tot (size32 (serialize_dtuple2 s1 s2)) = fun x -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_dtuple2 s1 s2) x z } )) inline_for_extraction let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun x -> s32 x inline_for_extraction let size32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in [@inline_let] let x = g1' input in [@inline_let] let y = s1' x in (y <: (res: U32.t { size32_postcond (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let size32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = size32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (p32: ((k: kt1) -> Tot (parser32 (p k)))) (k: kt2) : Tot (parser32 (p (f k))) = fun input -> p32 (f k) input inline_for_extraction let serialize32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (serializer32 (s k)))) (k: kt2) : Tot (serializer32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let size32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (size32 (s k)))) (k: kt2)
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (s: (k: kt1 -> Tot (serializer (p k)))) (s32: (k: kt1 -> Tot (size32 (s k)))) (k: kt2) : Tot (size32 (s (f k)))
[]
LowParse.SLow.Combinators.size32_compose_context
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
f: (_: kt2 -> kt1) -> t: (_: kt1 -> Type) -> p: (k: kt1 -> LowParse.Spec.Base.parser pk (t k)) -> s: (k: kt1 -> LowParse.Spec.Base.serializer (p k)) -> s32: (k: kt1 -> LowParse.SLow.Base.size32 (s k)) -> k: kt2 -> LowParse.SLow.Base.size32 (s (f k))
{ "end_col": 30, "end_line": 496, "start_col": 2, "start_line": 496 }
Prims.GTot
val serialize32_kind_precond (k1 k2: parser_kind) : GTot bool
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296
val serialize32_kind_precond (k1 k2: parser_kind) : GTot bool let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool =
false
null
false
Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "sometrivial" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.op_AmpAmp", "FStar.Pervasives.Native.uu___is_Some", "Prims.nat", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "Prims.op_LessThan", "Prims.op_Addition", "FStar.Pervasives.Native.__proj__Some__item__v", "Prims.bool" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind)
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_kind_precond (k1 k2: parser_kind) : GTot bool
[]
LowParse.SLow.Combinators.serialize32_kind_precond
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
k1: LowParse.Spec.Base.parser_kind -> k2: LowParse.Spec.Base.parser_kind -> Prims.GTot Prims.bool
{ "end_col": 72, "end_line": 113, "start_col": 2, "start_line": 111 }
Prims.Tot
val size32_false:size32 #_ #_ #parse_false serialize_false
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul
val size32_false:size32 #_ #_ #parse_false serialize_false let size32_false:size32 #_ #_ #parse_false serialize_false =
false
null
false
fun input -> 0ul
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "Prims.squash", "Prims.l_False", "FStar.UInt32.__uint_to_t", "FStar.UInt32.t", "LowParse.SLow.Base.size32_postcond", "LowParse.Spec.Combinators.parse_false_kind", "LowParse.Spec.Combinators.parse_false", "LowParse.Spec.Combinators.serialize_false" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes
false
true
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_false:size32 #_ #_ #parse_false serialize_false
[]
LowParse.SLow.Combinators.size32_false
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.size32 LowParse.Spec.Combinators.serialize_false
{ "end_col": 79, "end_line": 55, "start_col": 63, "start_line": 55 }
Prims.Tot
val serialize32_empty:serializer32 #_ #_ #parse_empty serialize_empty
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ())
val serialize32_empty:serializer32 #_ #_ #parse_empty serialize_empty let serialize32_empty:serializer32 #_ #_ #parse_empty serialize_empty =
false
null
false
serialize32_ret () (fun _ -> ())
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.SLow.Combinators.serialize32_ret", "Prims.unit" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction
false
true
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_empty:serializer32 #_ #_ #parse_empty serialize_empty
[]
LowParse.SLow.Combinators.serialize32_empty
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.serializer32 LowParse.Spec.Combinators.serialize_empty
{ "end_col": 34, "end_line": 34, "start_col": 2, "start_line": 34 }
Prims.Tot
val serialize32_false:serializer32 #_ #_ #parse_false serialize_false
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes
val serialize32_false:serializer32 #_ #_ #parse_false serialize_false let serialize32_false:serializer32 #_ #_ #parse_false serialize_false =
false
null
false
fun input -> B32.empty_bytes
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "Prims.squash", "Prims.l_False", "FStar.Bytes.empty_bytes", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.Combinators.parse_false_kind", "LowParse.Spec.Combinators.parse_false", "LowParse.Spec.Combinators.serialize_false" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None
false
true
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_false:serializer32 #_ #_ #parse_false serialize_false
[]
LowParse.SLow.Combinators.serialize32_false
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.serializer32 LowParse.Spec.Combinators.serialize_false
{ "end_col": 102, "end_line": 52, "start_col": 74, "start_line": 52 }
Prims.Tot
val parse32_false:parser32 parse_false
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_false : parser32 parse_false = fun _ -> None
val parse32_false:parser32 parse_false let parse32_false:parser32 parse_false =
false
null
false
fun _ -> None
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.SLow.Base.bytes32", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple2", "Prims.squash", "Prims.l_False", "FStar.UInt32.t", "FStar.Pervasives.Native.option", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Combinators.parse_false_kind", "LowParse.Spec.Combinators.parse_false" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ())
false
true
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_false:parser32 parse_false
[]
LowParse.SLow.Combinators.parse32_false
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.parser32 LowParse.Spec.Combinators.parse_false
{ "end_col": 56, "end_line": 49, "start_col": 43, "start_line": 49 }
Prims.Tot
val size32_empty:size32 #_ #_ #parse_empty serialize_empty
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ())
val size32_empty:size32 #_ #_ #parse_empty serialize_empty let size32_empty:size32 #_ #_ #parse_empty serialize_empty =
false
null
false
size32_ret () (fun _ -> ())
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.SLow.Combinators.size32_ret", "Prims.unit" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction
false
true
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_empty:size32 #_ #_ #parse_empty serialize_empty
[]
LowParse.SLow.Combinators.size32_empty
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.size32 LowParse.Spec.Combinators.serialize_empty
{ "end_col": 29, "end_line": 46, "start_col": 2, "start_line": 46 }
Prims.Tot
val serialize32_ret (#t: Type) (v: t) (v_unique: (v': t -> Lemma (v == v'))) : Tot (serializer32 (serialize_ret v v_unique))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } ))
val serialize32_ret (#t: Type) (v: t) (v_unique: (v': t -> Lemma (v == v'))) : Tot (serializer32 (serialize_ret v v_unique)) let serialize32_ret (#t: Type) (v: t) (v_unique: (v': t -> Lemma (v == v'))) : Tot (serializer32 (serialize_ret v v_unique)) =
false
null
false
fun input -> [@@ inline_let ]let b = B32.empty_bytes in assert ((B32.reveal b) `Seq.equal` Seq.empty); (b <: (b: bytes32{serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b}))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.Combinators.parse_ret_kind", "LowParse.Spec.Combinators.parse_ret", "LowParse.Spec.Combinators.serialize_ret", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Bytes.byte", "FStar.Bytes.reveal", "FStar.Seq.Base.empty", "FStar.Bytes.lbytes", "FStar.Bytes.empty_bytes", "LowParse.SLow.Base.serializer32" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v'))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_ret (#t: Type) (v: t) (v_unique: (v': t -> Lemma (v == v'))) : Tot (serializer32 (serialize_ret v v_unique))
[]
LowParse.SLow.Combinators.serialize32_ret
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v: t -> v_unique: (v': t -> FStar.Pervasives.Lemma (ensures v == v')) -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Combinators.serialize_ret v v_unique)
{ "end_col": 103, "end_line": 30, "start_col": 2, "start_line": 26 }
Prims.Tot
val size32_ret (#t: Type) (v: t) (v_unique: (v': t -> Lemma (v == v'))) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul ()
val size32_ret (#t: Type) (v: t) (v_unique: (v': t -> Lemma (v == v'))) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) let size32_ret (#t: Type) (v: t) (v_unique: (v': t -> Lemma (v == v'))) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) =
false
null
false
size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul ()
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern", "LowParse.SLow.Base.size32_constant", "LowParse.Spec.Combinators.parse_ret_kind", "LowParse.Spec.Combinators.parse_ret", "LowParse.Spec.Combinators.serialize_ret", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.size32" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v'))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_ret (#t: Type) (v: t) (v_unique: (v': t -> Lemma (v == v'))) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique))
[]
LowParse.SLow.Combinators.size32_ret
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v: t -> v_unique: (v': t -> FStar.Pervasives.Lemma (ensures v == v')) -> LowParse.SLow.Base.size32 (LowParse.Spec.Combinators.serialize_ret v v_unique)
{ "end_col": 72, "end_line": 42, "start_col": 2, "start_line": 42 }
Prims.Tot
val parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } )))
val parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) =
false
null
false
(fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) {parser32_correct (parse_ret x) input res})))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.SLow.Base.bytes32", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.UInt32.t", "FStar.Pervasives.Native.Mktuple2", "FStar.UInt32.__uint_to_t", "FStar.Pervasives.Native.option", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Combinators.parse_ret_kind", "LowParse.Spec.Combinators.parse_ret", "LowParse.SLow.Base.parser32" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t)
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x))
[]
LowParse.SLow.Combinators.parse32_ret
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
x: t -> LowParse.SLow.Base.parser32 (LowParse.Spec.Combinators.parse_ret x)
{ "end_col": 109, "end_line": 15, "start_col": 2, "start_line": 15 }
Prims.Tot
val serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input
val serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) =
false
null
false
fun (input: t{f input == true}) -> s32 input
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "Prims.bool", "Prims.eq2", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.Combinators.serialize_filter" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f))
[]
LowParse.SLow.Combinators.serialize32_filter
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s32: LowParse.SLow.Base.serializer32 s -> f: (_: t -> Prims.GTot Prims.bool) -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Combinators.serialize_filter s f)
{ "end_col": 50, "end_line": 323, "start_col": 2, "start_line": 323 }
Prims.Tot
val size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun x -> s32 x
val size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) =
false
null
false
fun x -> s32 x
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "Prims.bool", "LowParse.Spec.Combinators.parse_filter_refine", "FStar.UInt32.t", "LowParse.SLow.Base.size32_postcond", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.Combinators.serialize_filter" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } )) inline_for_extraction let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x))) : Tot (size32 (serialize_dtuple2 s1 s2)) = fun x -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_dtuple2 s1 s2) x z } )) inline_for_extraction let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f))
[]
LowParse.SLow.Combinators.size32_filter
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s32: LowParse.SLow.Base.size32 s -> f: (_: t -> Prims.GTot Prims.bool) -> LowParse.SLow.Base.size32 (LowParse.Spec.Combinators.serialize_filter s f)
{ "end_col": 16, "end_line": 419, "start_col": 2, "start_line": 419 }
Prims.Tot
val lift_parser32 (#k: parser_kind) (#t: Type) (f: (unit -> GTot (parser k t))) (f32: parser32 (f ())) : Tot (parser32 (lift_parser f))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lift_parser32 (#k: parser_kind) (#t: Type) (f: unit -> GTot (parser k t)) (f32: parser32 (f ())) : Tot (parser32 (lift_parser f)) = fun x -> f32 x
val lift_parser32 (#k: parser_kind) (#t: Type) (f: (unit -> GTot (parser k t))) (f32: parser32 (f ())) : Tot (parser32 (lift_parser f)) let lift_parser32 (#k: parser_kind) (#t: Type) (f: (unit -> GTot (parser k t))) (f32: parser32 (f ())) : Tot (parser32 (lift_parser f)) =
false
null
false
fun x -> f32 x
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.unit", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.SLow.Base.bytes32", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "FStar.UInt32.t", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Combinators.lift_parser" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } )) inline_for_extraction let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x))) : Tot (size32 (serialize_dtuple2 s1 s2)) = fun x -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_dtuple2 s1 s2) x z } )) inline_for_extraction let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun x -> s32 x inline_for_extraction let size32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in [@inline_let] let x = g1' input in [@inline_let] let y = s1' x in (y <: (res: U32.t { size32_postcond (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let size32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = size32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (p32: ((k: kt1) -> Tot (parser32 (p k)))) (k: kt2) : Tot (parser32 (p (f k))) = fun input -> p32 (f k) input inline_for_extraction let serialize32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (serializer32 (s k)))) (k: kt2) : Tot (serializer32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let size32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (size32 (s k)))) (k: kt2) : Tot (size32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let parse32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (p2' : parser32 p2 { k1 `is_weaker_than` k2 }) : Tot (parser32 (weaken k1 p2)) = fun x -> p2' x inline_for_extraction let serialize32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2' : serializer32 s2 { k1 `is_weaker_than` k2 }) : Tot (serializer32 (serialize_weaken k1 s2)) = fun x -> s2' x inline_for_extraction let size32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2' : size32 s2 { k1 `is_weaker_than` k2 }) : Tot (size32 (serialize_weaken k1 s2)) = fun x -> s2' x inline_for_extraction let lift_parser32 (#k: parser_kind) (#t: Type) (f: unit -> GTot (parser k t)) (f32: parser32 (f ()))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lift_parser32 (#k: parser_kind) (#t: Type) (f: (unit -> GTot (parser k t))) (f32: parser32 (f ())) : Tot (parser32 (lift_parser f))
[]
LowParse.SLow.Combinators.lift_parser32
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
f: (_: Prims.unit -> Prims.GTot (LowParse.Spec.Base.parser k t)) -> f32: LowParse.SLow.Base.parser32 (f ()) -> LowParse.SLow.Base.parser32 (LowParse.Spec.Combinators.lift_parser f)
{ "end_col": 16, "end_line": 537, "start_col": 2, "start_line": 537 }
Prims.Tot
val size32_synth' (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (s1: serializer p1) (s1': size32 s1) (g1: (t2 -> Tot t1)) (u: unit{synth_inverse f2 g1 /\ synth_injective f2}) : Tot (size32 (serialize_synth p1 f2 s1 g1 u))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = size32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u
val size32_synth' (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (s1: serializer p1) (s1': size32 s1) (g1: (t2 -> Tot t1)) (u: unit{synth_inverse f2 g1 /\ synth_injective f2}) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) let size32_synth' (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (s1: serializer p1) (s1': size32 s1) (g1: (t2 -> Tot t1)) (u: unit{synth_inverse f2 g1 /\ synth_injective f2}) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) =
false
null
false
size32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "Prims.unit", "Prims.l_and", "LowParse.Spec.Combinators.synth_inverse", "LowParse.Spec.Combinators.synth_injective", "LowParse.SLow.Combinators.size32_synth", "Prims.eq2", "LowParse.Spec.Combinators.parse_synth", "LowParse.Spec.Combinators.serialize_synth" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } )) inline_for_extraction let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x))) : Tot (size32 (serialize_dtuple2 s1 s2)) = fun x -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_dtuple2 s1 s2) x z } )) inline_for_extraction let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun x -> s32 x inline_for_extraction let size32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in [@inline_let] let x = g1' input in [@inline_let] let y = s1' x in (y <: (res: U32.t { size32_postcond (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let size32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 })
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_synth' (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (s1: serializer p1) (s1': size32 s1) (g1: (t2 -> Tot t1)) (u: unit{synth_inverse f2 g1 /\ synth_injective f2}) : Tot (size32 (serialize_synth p1 f2 s1 g1 u))
[]
LowParse.SLow.Combinators.size32_synth'
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1: LowParse.Spec.Base.parser k t1 -> f2: (_: t1 -> Prims.GTot t2) -> s1: LowParse.Spec.Base.serializer p1 -> s1': LowParse.SLow.Base.size32 s1 -> g1: (_: t2 -> t1) -> u172: u175: Prims.unit { LowParse.Spec.Combinators.synth_inverse f2 g1 /\ LowParse.Spec.Combinators.synth_injective f2 } -> LowParse.SLow.Base.size32 (LowParse.Spec.Combinators.serialize_synth p1 f2 s1 g1 u172)
{ "end_col": 48, "end_line": 458, "start_col": 2, "start_line": 458 }
Prims.Tot
val parse32_synth (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (f2': (x: t1 -> Tot (y: t2{y == f2 x}))) (p1': parser32 p1) (u: unit{synth_injective f2}) : Tot (parser32 (parse_synth p1 f2))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } ))
val parse32_synth (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (f2': (x: t1 -> Tot (y: t2{y == f2 x}))) (p1': parser32 p1) (u: unit{synth_injective f2}) : Tot (parser32 (parse_synth p1 f2)) let parse32_synth (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (f2': (x: t1 -> Tot (y: t2{y == f2 x}))) (p1': parser32 p1) (u: unit{synth_injective f2}) : Tot (parser32 (parse_synth p1 f2)) =
false
null
false
fun (input: bytes32) -> (([@@ inline_let ]let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None) <: (res: option (t2 * U32.t) {parser32_correct (parse_synth p1 f2) input res}))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "Prims.eq2", "LowParse.SLow.Base.parser32", "Prims.unit", "LowParse.Spec.Combinators.synth_injective", "LowParse.SLow.Base.bytes32", "FStar.UInt32.t", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.None", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Combinators.parse_synth", "LowParse.Spec.Combinators.parse_synth_eq", "FStar.Bytes.reveal" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 })
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_synth (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (f2': (x: t1 -> Tot (y: t2{y == f2 x}))) (p1': parser32 p1) (u: unit{synth_injective f2}) : Tot (parser32 (parse_synth p1 f2))
[]
LowParse.SLow.Combinators.parse32_synth
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1: LowParse.Spec.Base.parser k t1 -> f2: (_: t1 -> Prims.GTot t2) -> f2': (x: t1 -> y: t2{y == f2 x}) -> p1': LowParse.SLow.Base.parser32 p1 -> u76: u80: Prims.unit{LowParse.Spec.Combinators.synth_injective f2} -> LowParse.SLow.Base.parser32 (LowParse.Spec.Combinators.parse_synth p1 f2)
{ "end_col": 87, "end_line": 237, "start_col": 2, "start_line": 231 }
Prims.Tot
val parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: (x: t -> Tot (b: bool{b == f x}))) : Tot (parser32 (parse_filter p f))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } ))
val parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: (x: t -> Tot (b: bool{b == f x}))) : Tot (parser32 (parse_filter p f)) let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: (x: t -> Tot (b: bool{b == f x}))) : Tot (parser32 (parse_filter p f)) =
false
null
false
fun (input: bytes32) -> (([@@ inline_let ]let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@@ inline_let ]let v':v': t{f v' == true} = v in Some (v', consumed) else None | _ -> None) <: (res: option ((v': t{f v' == true}) * U32.t) {parser32_correct (parse_filter p f) input res}))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "Prims.bool", "Prims.eq2", "LowParse.SLow.Base.bytes32", "FStar.UInt32.t", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.Combinators.parse_filter", "Prims.unit", "LowParse.Spec.Combinators.parse_filter_eq", "FStar.Bytes.reveal" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } )))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: (x: t -> Tot (b: bool{b == f x}))) : Tot (parser32 (parse_filter p f))
[]
LowParse.SLow.Combinators.parse32_filter
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p32: LowParse.SLow.Base.parser32 p -> f: (_: t -> Prims.GTot Prims.bool) -> g: (x: t -> b: Prims.bool{b == f x}) -> LowParse.SLow.Base.parser32 (LowParse.Spec.Combinators.parse_filter p f)
{ "end_col": 108, "end_line": 312, "start_col": 2, "start_line": 299 }
Prims.Tot
val parse32_synth' (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> Tot t2)) (p1': parser32 p1) (u: unit{synth_injective f2}) : Tot (parser32 (parse_synth p1 f2))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u
val parse32_synth' (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> Tot t2)) (p1': parser32 p1) (u: unit{synth_injective f2}) : Tot (parser32 (parse_synth p1 f2)) let parse32_synth' (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> Tot t2)) (p1': parser32 p1) (u: unit{synth_injective f2}) : Tot (parser32 (parse_synth p1 f2)) =
false
null
false
parse32_synth p1 f2 (fun x -> f2 x) p1' u
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "Prims.unit", "LowParse.Spec.Combinators.synth_injective", "LowParse.SLow.Combinators.parse32_synth", "Prims.eq2", "LowParse.Spec.Combinators.parse_synth" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 })
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_synth' (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> Tot t2)) (p1': parser32 p1) (u: unit{synth_injective f2}) : Tot (parser32 (parse_synth p1 f2))
[]
LowParse.SLow.Combinators.parse32_synth'
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1: LowParse.Spec.Base.parser k t1 -> f2: (_: t1 -> t2) -> p1': LowParse.SLow.Base.parser32 p1 -> u82: u84: Prims.unit{LowParse.Spec.Combinators.synth_injective f2} -> LowParse.SLow.Base.parser32 (LowParse.Spec.Combinators.parse_synth p1 f2)
{ "end_col": 43, "end_line": 251, "start_col": 2, "start_line": 251 }
Prims.Tot
val serialize32_synth (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (s1: serializer p1) (s1': serializer32 s1) (g1: (t2 -> GTot t1)) (g1': (x: t2 -> Tot (y: t1{y == g1 x}))) (u: unit{synth_inverse f2 g1 /\ synth_injective f2}) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } ))
val serialize32_synth (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (s1: serializer p1) (s1': serializer32 s1) (g1: (t2 -> GTot t1)) (g1': (x: t2 -> Tot (y: t1{y == g1 x}))) (u: unit{synth_inverse f2 g1 /\ synth_injective f2}) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) let serialize32_synth (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (s1: serializer p1) (s1': serializer32 s1) (g1: (t2 -> GTot t1)) (g1': (x: t2 -> Tot (y: t1{y == g1 x}))) (u: unit{synth_inverse f2 g1 /\ synth_injective f2}) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) =
false
null
false
fun (input: t2) -> [@@ inline_let ]let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32{serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res}))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "Prims.eq2", "Prims.unit", "Prims.l_and", "LowParse.Spec.Combinators.synth_inverse", "LowParse.Spec.Combinators.synth_injective", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.Combinators.parse_synth", "LowParse.Spec.Combinators.serialize_synth", "LowParse.Spec.Combinators.serialize_synth_eq" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 })
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_synth (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (s1: serializer p1) (s1': serializer32 s1) (g1: (t2 -> GTot t1)) (g1': (x: t2 -> Tot (y: t1{y == g1 x}))) (u: unit{synth_inverse f2 g1 /\ synth_injective f2}) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u))
[]
LowParse.SLow.Combinators.serialize32_synth
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1: LowParse.Spec.Base.parser k t1 -> f2: (_: t1 -> Prims.GTot t2) -> s1: LowParse.Spec.Base.serializer p1 -> s1': LowParse.SLow.Base.serializer32 s1 -> g1: (_: t2 -> Prims.GTot t1) -> g1': (x: t2 -> y: t1{y == g1 x}) -> u95: u100: Prims.unit { LowParse.Spec.Combinators.synth_inverse f2 g1 /\ LowParse.Spec.Combinators.synth_injective f2 } -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Combinators.serialize_synth p1 f2 s1 g1 u95)
{ "end_col": 97, "end_line": 272, "start_col": 2, "start_line": 269 }
Prims.Tot
val serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': serializer32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2': serializer32 s2 {serialize32_kind_precond k1 k2}) : Tot (serializer32 (serialize_nondep_then s1 s2))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } ))
val serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': serializer32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2': serializer32 s2 {serialize32_kind_precond k1 k2}) : Tot (serializer32 (serialize_nondep_then s1 s2)) let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': serializer32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2': serializer32 s2 {serialize32_kind_precond k1 k2}) : Tot (serializer32 (serialize_nondep_then s1 s2)) =
false
null
false
fun (input: t1 * t2) -> [@@ inline_let ]let _ = serialize_nondep_then_eq s1 s2 input in match input with | fs, sn -> let output1 = s1' fs in let output2 = s2' sn in [@@ inline_let ]let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@@ inline_let ]let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32{serializer32_correct (serialize_nondep_then s1 s2) input res}))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.b2t", "LowParse.SLow.Combinators.serialize32_kind_precond", "FStar.Pervasives.Native.tuple2", "FStar.Bytes.append", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.nondep_then", "LowParse.Spec.Combinators.serialize_nondep_then", "Prims.unit", "Prims._assert", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.Bytes.length", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "LowParse.Spec.Base.serialize", "LowParse.Spec.Combinators.serialize_nondep_then_eq" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 })
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': serializer32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2': serializer32 s2 {serialize32_kind_precond k1 k2}) : Tot (serializer32 (serialize_nondep_then s1 s2))
[]
LowParse.SLow.Combinators.serialize32_nondep_then
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s1': LowParse.SLow.Base.serializer32 s1 { Mkparser_kind'?.parser_kind_subkind k1 == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> s2': LowParse.SLow.Base.serializer32 s2 {LowParse.SLow.Combinators.serialize32_kind_precond k1 k2} -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Combinators.serialize_nondep_then s1 s2)
{ "end_col": 85, "end_line": 142, "start_col": 2, "start_line": 130 }
Prims.Tot
val lift_serializer32 (#k: parser_kind) (#t: Type) (f: (unit -> GTot (parser k t))) (s: (unit -> GTot (serializer (f ())))) (s32: serializer32 (s ())) : Tot (serializer32 (lift_serializer #k #t #f s))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lift_serializer32 (#k: parser_kind) (#t: Type) (f: unit -> GTot (parser k t)) (s: unit -> GTot (serializer (f ()))) (s32: serializer32 (s ())) : Tot (serializer32 (lift_serializer #k #t #f s)) = fun x -> s32 x
val lift_serializer32 (#k: parser_kind) (#t: Type) (f: (unit -> GTot (parser k t))) (s: (unit -> GTot (serializer (f ())))) (s32: serializer32 (s ())) : Tot (serializer32 (lift_serializer #k #t #f s)) let lift_serializer32 (#k: parser_kind) (#t: Type) (f: (unit -> GTot (parser k t))) (s: (unit -> GTot (serializer (f ())))) (s32: serializer32 (s ())) : Tot (serializer32 (lift_serializer #k #t #f s)) =
false
null
false
fun x -> s32 x
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.unit", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.Combinators.lift_parser", "LowParse.Spec.Combinators.lift_serializer" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } )) inline_for_extraction let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x))) : Tot (size32 (serialize_dtuple2 s1 s2)) = fun x -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_dtuple2 s1 s2) x z } )) inline_for_extraction let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun x -> s32 x inline_for_extraction let size32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in [@inline_let] let x = g1' input in [@inline_let] let y = s1' x in (y <: (res: U32.t { size32_postcond (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let size32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = size32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (p32: ((k: kt1) -> Tot (parser32 (p k)))) (k: kt2) : Tot (parser32 (p (f k))) = fun input -> p32 (f k) input inline_for_extraction let serialize32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (serializer32 (s k)))) (k: kt2) : Tot (serializer32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let size32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (size32 (s k)))) (k: kt2) : Tot (size32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let parse32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (p2' : parser32 p2 { k1 `is_weaker_than` k2 }) : Tot (parser32 (weaken k1 p2)) = fun x -> p2' x inline_for_extraction let serialize32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2' : serializer32 s2 { k1 `is_weaker_than` k2 }) : Tot (serializer32 (serialize_weaken k1 s2)) = fun x -> s2' x inline_for_extraction let size32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2' : size32 s2 { k1 `is_weaker_than` k2 }) : Tot (size32 (serialize_weaken k1 s2)) = fun x -> s2' x inline_for_extraction let lift_parser32 (#k: parser_kind) (#t: Type) (f: unit -> GTot (parser k t)) (f32: parser32 (f ())) : Tot (parser32 (lift_parser f)) = fun x -> f32 x inline_for_extraction let lift_serializer32 (#k: parser_kind) (#t: Type) (f: unit -> GTot (parser k t)) (s: unit -> GTot (serializer (f ()))) (s32: serializer32 (s ()))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lift_serializer32 (#k: parser_kind) (#t: Type) (f: (unit -> GTot (parser k t))) (s: (unit -> GTot (serializer (f ())))) (s32: serializer32 (s ())) : Tot (serializer32 (lift_serializer #k #t #f s))
[]
LowParse.SLow.Combinators.lift_serializer32
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
f: (_: Prims.unit -> Prims.GTot (LowParse.Spec.Base.parser k t)) -> s: (_: Prims.unit -> Prims.GTot (LowParse.Spec.Base.serializer (f ()))) -> s32: LowParse.SLow.Base.serializer32 (s ()) -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Combinators.lift_serializer s)
{ "end_col": 16, "end_line": 547, "start_col": 2, "start_line": 547 }
Prims.Tot
val serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': serializer32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind{serialize32_kind_precond k1 k2}) (#t2: (t1 -> Tot Type)) (#p2: (x: t1 -> Tot (parser k2 (t2 x)))) (#s2: (x: t1 -> Tot (serializer (p2 x)))) (s2': (x: t1 -> serializer32 (s2 x))) : Tot (serializer32 (serialize_dtuple2 s1 s2))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } ))
val serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': serializer32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind{serialize32_kind_precond k1 k2}) (#t2: (t1 -> Tot Type)) (#p2: (x: t1 -> Tot (parser k2 (t2 x)))) (#s2: (x: t1 -> Tot (serializer (p2 x)))) (s2': (x: t1 -> serializer32 (s2 x))) : Tot (serializer32 (serialize_dtuple2 s1 s2)) let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': serializer32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind{serialize32_kind_precond k1 k2}) (#t2: (t1 -> Tot Type)) (#p2: (x: t1 -> Tot (parser k2 (t2 x)))) (#s2: (x: t1 -> Tot (serializer (p2 x)))) (s2': (x: t1 -> serializer32 (s2 x))) : Tot (serializer32 (serialize_dtuple2 s1 s2)) =
false
null
false
fun (input: dtuple2 t1 t2) -> [@@ inline_let ]let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs , sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@@ inline_let ]let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@@ inline_let ]let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32{serializer32_correct (serialize_dtuple2 s1 s2) input res}))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.b2t", "LowParse.SLow.Combinators.serialize32_kind_precond", "Prims.dtuple2", "FStar.Bytes.append", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.parse_dtuple2", "LowParse.Spec.Combinators.serialize_dtuple2", "Prims.unit", "Prims._assert", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.Bytes.length", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "LowParse.Spec.Base.serialize", "LowParse.Spec.Combinators.serialize_dtuple2_eq" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': serializer32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind{serialize32_kind_precond k1 k2}) (#t2: (t1 -> Tot Type)) (#p2: (x: t1 -> Tot (parser k2 (t2 x)))) (#s2: (x: t1 -> Tot (serializer (p2 x)))) (s2': (x: t1 -> serializer32 (s2 x))) : Tot (serializer32 (serialize_dtuple2 s1 s2))
[]
LowParse.SLow.Combinators.serialize32_dtuple2
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s1': LowParse.SLow.Base.serializer32 s1 { Mkparser_kind'?.parser_kind_subkind k1 == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> s2': (x: t1 -> LowParse.SLow.Base.serializer32 (s2 x)) -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Combinators.serialize_dtuple2 s1 s2)
{ "end_col": 81, "end_line": 196, "start_col": 2, "start_line": 184 }
Prims.Tot
val parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1': parser32 p1) (p2: (t1 -> GTot Type0)) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } ))
val parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1': parser32 p1) (p2: (t1 -> GTot Type0)) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1': parser32 p1) (p2: (t1 -> GTot Type0)) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) =
false
null
false
fun (xbytes: bytes32) -> ((match p1' xbytes with | Some (x, consumed) -> [@@ inline_let ]let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@@ inline_let ]let x':x': t1{p2 x'} = x in Some (x', consumed) | _ -> None) <: (res: option ((x: t1{p2 x}) * U32.t) {parser32_correct (parse_strengthen p1 p2 prf) xbytes res}) )
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.Spec.Combinators.parse_strengthen_prf", "LowParse.SLow.Base.bytes32", "FStar.UInt32.t", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "FStar.Bytes.reveal", "FStar.UInt32.v", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.None", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Combinators.parse_strengthen" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2)
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1': parser32 p1) (p2: (t1 -> GTot Type0)) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf))
[]
LowParse.SLow.Combinators.parse32_strengthen
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1': LowParse.SLow.Base.parser32 p1 -> p2: (_: t1 -> Prims.GTot Type0) -> prf: LowParse.Spec.Combinators.parse_strengthen_prf p1 p2 -> LowParse.SLow.Base.parser32 (LowParse.Spec.Combinators.parse_strengthen p1 p2 prf)
{ "end_col": 109, "end_line": 216, "start_col": 2, "start_line": 207 }
Prims.Tot
val size32_synth (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (s1: serializer p1) (s1': size32 s1) (g1: (t2 -> GTot t1)) (g1': (x: t2 -> Tot (y: t1{y == g1 x}))) (u: unit{synth_inverse f2 g1 /\ synth_injective f2}) : Tot (size32 (serialize_synth p1 f2 s1 g1 u))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in [@inline_let] let x = g1' input in [@inline_let] let y = s1' x in (y <: (res: U32.t { size32_postcond (serialize_synth p1 f2 s1 g1 u) input res } ))
val size32_synth (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (s1: serializer p1) (s1': size32 s1) (g1: (t2 -> GTot t1)) (g1': (x: t2 -> Tot (y: t1{y == g1 x}))) (u: unit{synth_inverse f2 g1 /\ synth_injective f2}) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) let size32_synth (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (s1: serializer p1) (s1': size32 s1) (g1: (t2 -> GTot t1)) (g1': (x: t2 -> Tot (y: t1{y == g1 x}))) (u: unit{synth_inverse f2 g1 /\ synth_injective f2}) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) =
false
null
false
fun (input: t2) -> [@@ inline_let ]let _ = serialize_synth_eq p1 f2 s1 g1 u input in [@@ inline_let ]let x = g1' input in [@@ inline_let ]let y = s1' x in (y <: (res: U32.t{size32_postcond (serialize_synth p1 f2 s1 g1 u) input res}))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "Prims.eq2", "Prims.unit", "Prims.l_and", "LowParse.Spec.Combinators.synth_inverse", "LowParse.Spec.Combinators.synth_injective", "FStar.UInt32.t", "LowParse.SLow.Base.size32_postcond", "LowParse.Spec.Combinators.parse_synth", "LowParse.Spec.Combinators.serialize_synth", "LowParse.Spec.Combinators.serialize_synth_eq" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } )) inline_for_extraction let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x))) : Tot (size32 (serialize_dtuple2 s1 s2)) = fun x -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_dtuple2 s1 s2) x z } )) inline_for_extraction let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun x -> s32 x inline_for_extraction let size32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 })
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_synth (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (s1: serializer p1) (s1': size32 s1) (g1: (t2 -> GTot t1)) (g1': (x: t2 -> Tot (y: t1{y == g1 x}))) (u: unit{synth_inverse f2 g1 /\ synth_injective f2}) : Tot (size32 (serialize_synth p1 f2 s1 g1 u))
[]
LowParse.SLow.Combinators.size32_synth
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1: LowParse.Spec.Base.parser k t1 -> f2: (_: t1 -> Prims.GTot t2) -> s1: LowParse.Spec.Base.serializer p1 -> s1': LowParse.SLow.Base.size32 s1 -> g1: (_: t2 -> Prims.GTot t1) -> g1': (x: t2 -> y: t1{y == g1 x}) -> u164: u169: Prims.unit { LowParse.Spec.Combinators.synth_inverse f2 g1 /\ LowParse.Spec.Combinators.synth_injective f2 } -> LowParse.SLow.Base.size32 (LowParse.Spec.Combinators.serialize_synth p1 f2 s1 g1 u164)
{ "end_col": 86, "end_line": 441, "start_col": 2, "start_line": 437 }
Prims.Tot
val size32_weaken (k1 #k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2': size32 s2 {k1 `is_weaker_than` k2}) : Tot (size32 (serialize_weaken k1 s2))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2' : size32 s2 { k1 `is_weaker_than` k2 }) : Tot (size32 (serialize_weaken k1 s2)) = fun x -> s2' x
val size32_weaken (k1 #k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2': size32 s2 {k1 `is_weaker_than` k2}) : Tot (size32 (serialize_weaken k1 s2)) let size32_weaken (k1 #k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2': size32 s2 {k1 `is_weaker_than` k2}) : Tot (size32 (serialize_weaken k1 s2)) =
false
null
false
fun x -> s2' x
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "LowParse.Spec.Base.is_weaker_than", "FStar.UInt32.t", "LowParse.SLow.Base.size32_postcond", "LowParse.Spec.Base.weaken", "LowParse.Spec.Combinators.serialize_weaken" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } )) inline_for_extraction let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x))) : Tot (size32 (serialize_dtuple2 s1 s2)) = fun x -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_dtuple2 s1 s2) x z } )) inline_for_extraction let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun x -> s32 x inline_for_extraction let size32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in [@inline_let] let x = g1' input in [@inline_let] let y = s1' x in (y <: (res: U32.t { size32_postcond (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let size32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = size32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (p32: ((k: kt1) -> Tot (parser32 (p k)))) (k: kt2) : Tot (parser32 (p (f k))) = fun input -> p32 (f k) input inline_for_extraction let serialize32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (serializer32 (s k)))) (k: kt2) : Tot (serializer32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let size32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (size32 (s k)))) (k: kt2) : Tot (size32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let parse32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (p2' : parser32 p2 { k1 `is_weaker_than` k2 }) : Tot (parser32 (weaken k1 p2)) = fun x -> p2' x inline_for_extraction let serialize32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2' : serializer32 s2 { k1 `is_weaker_than` k2 }) : Tot (serializer32 (serialize_weaken k1 s2)) = fun x -> s2' x inline_for_extraction let size32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2' : size32 s2 { k1 `is_weaker_than` k2 })
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_weaken (k1 #k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2': size32 s2 {k1 `is_weaker_than` k2}) : Tot (size32 (serialize_weaken k1 s2))
[]
LowParse.SLow.Combinators.size32_weaken
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
k1: LowParse.Spec.Base.parser_kind -> s2': LowParse.SLow.Base.size32 s2 {LowParse.Spec.Base.is_weaker_than k1 k2} -> LowParse.SLow.Base.size32 (LowParse.Spec.Combinators.serialize_weaken k1 s2)
{ "end_col": 16, "end_line": 528, "start_col": 2, "start_line": 528 }
Prims.Tot
val size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': size32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1 -> Tot (parser k2 (t2 x)))) (#s2: (x: t1 -> Tot (serializer (p2 x)))) (s2': (x: t1 -> Tot (size32 (s2 x)))) : Tot (size32 (serialize_dtuple2 s1 s2))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x))) : Tot (size32 (serialize_dtuple2 s1 s2)) = fun x -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_dtuple2 s1 s2) x z } ))
val size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': size32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1 -> Tot (parser k2 (t2 x)))) (#s2: (x: t1 -> Tot (serializer (p2 x)))) (s2': (x: t1 -> Tot (size32 (s2 x)))) : Tot (size32 (serialize_dtuple2 s1 s2)) let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': size32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1 -> Tot (parser k2 (t2 x)))) (#s2: (x: t1 -> Tot (serializer (p2 x)))) (s2': (x: t1 -> Tot (size32 (s2 x)))) : Tot (size32 (serialize_dtuple2 s1 s2)) =
false
null
false
fun x -> [@@ inline_let ]let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1 , x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z: U32.t{size32_postcond (serialize_dtuple2 s1 s2) x z}))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.dtuple2", "FStar.UInt32.t", "LowParse.SLow.Base.size32_postcond", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.parse_dtuple2", "LowParse.Spec.Combinators.serialize_dtuple2", "LowParse.SLow.Base.add_overflow", "Prims.unit", "LowParse.Spec.Combinators.serialize_dtuple2_eq" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } )) inline_for_extraction let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x)))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': size32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1 -> Tot (parser k2 (t2 x)))) (#s2: (x: t1 -> Tot (serializer (p2 x)))) (s2': (x: t1 -> Tot (size32 (s2 x)))) : Tot (size32 (serialize_dtuple2 s1 s2))
[]
LowParse.SLow.Combinators.size32_dtuple2
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s1': LowParse.SLow.Base.size32 s1 { Mkparser_kind'?.parser_kind_subkind k1 == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> s2': (x: t1 -> LowParse.SLow.Base.size32 (s2 x)) -> LowParse.SLow.Base.size32 (LowParse.Spec.Combinators.serialize_dtuple2 s1 s2)
{ "end_col": 75, "end_line": 408, "start_col": 2, "start_line": 401 }
Prims.Tot
val parse32_weaken (k1 #k2: parser_kind) (#t: Type) (#p2: parser k2 t) (p2': parser32 p2 {k1 `is_weaker_than` k2}) : Tot (parser32 (weaken k1 p2))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (p2' : parser32 p2 { k1 `is_weaker_than` k2 }) : Tot (parser32 (weaken k1 p2)) = fun x -> p2' x
val parse32_weaken (k1 #k2: parser_kind) (#t: Type) (#p2: parser k2 t) (p2': parser32 p2 {k1 `is_weaker_than` k2}) : Tot (parser32 (weaken k1 p2)) let parse32_weaken (k1 #k2: parser_kind) (#t: Type) (#p2: parser k2 t) (p2': parser32 p2 {k1 `is_weaker_than` k2}) : Tot (parser32 (weaken k1 p2)) =
false
null
false
fun x -> p2' x
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.Spec.Base.is_weaker_than", "LowParse.SLow.Base.bytes32", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "FStar.UInt32.t", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Base.weaken" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } )) inline_for_extraction let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x))) : Tot (size32 (serialize_dtuple2 s1 s2)) = fun x -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_dtuple2 s1 s2) x z } )) inline_for_extraction let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun x -> s32 x inline_for_extraction let size32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in [@inline_let] let x = g1' input in [@inline_let] let y = s1' x in (y <: (res: U32.t { size32_postcond (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let size32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = size32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (p32: ((k: kt1) -> Tot (parser32 (p k)))) (k: kt2) : Tot (parser32 (p (f k))) = fun input -> p32 (f k) input inline_for_extraction let serialize32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (serializer32 (s k)))) (k: kt2) : Tot (serializer32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let size32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (size32 (s k)))) (k: kt2) : Tot (size32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let parse32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (p2' : parser32 p2 { k1 `is_weaker_than` k2 })
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_weaken (k1 #k2: parser_kind) (#t: Type) (#p2: parser k2 t) (p2': parser32 p2 {k1 `is_weaker_than` k2}) : Tot (parser32 (weaken k1 p2))
[]
LowParse.SLow.Combinators.parse32_weaken
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
k1: LowParse.Spec.Base.parser_kind -> p2': LowParse.SLow.Base.parser32 p2 {LowParse.Spec.Base.is_weaker_than k1 k2} -> LowParse.SLow.Base.parser32 (LowParse.Spec.Base.weaken k1 p2)
{ "end_col": 16, "end_line": 506, "start_col": 2, "start_line": 506 }
Prims.Tot
val serialize32_weaken (k1 #k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2': serializer32 s2 {k1 `is_weaker_than` k2}) : Tot (serializer32 (serialize_weaken k1 s2))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2' : serializer32 s2 { k1 `is_weaker_than` k2 }) : Tot (serializer32 (serialize_weaken k1 s2)) = fun x -> s2' x
val serialize32_weaken (k1 #k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2': serializer32 s2 {k1 `is_weaker_than` k2}) : Tot (serializer32 (serialize_weaken k1 s2)) let serialize32_weaken (k1 #k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2': serializer32 s2 {k1 `is_weaker_than` k2}) : Tot (serializer32 (serialize_weaken k1 s2)) =
false
null
false
fun x -> s2' x
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "LowParse.Spec.Base.is_weaker_than", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.Base.weaken", "LowParse.Spec.Combinators.serialize_weaken" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } )) inline_for_extraction let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x))) : Tot (size32 (serialize_dtuple2 s1 s2)) = fun x -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_dtuple2 s1 s2) x z } )) inline_for_extraction let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun x -> s32 x inline_for_extraction let size32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in [@inline_let] let x = g1' input in [@inline_let] let y = s1' x in (y <: (res: U32.t { size32_postcond (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let size32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = size32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (p32: ((k: kt1) -> Tot (parser32 (p k)))) (k: kt2) : Tot (parser32 (p (f k))) = fun input -> p32 (f k) input inline_for_extraction let serialize32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (serializer32 (s k)))) (k: kt2) : Tot (serializer32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let size32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (size32 (s k)))) (k: kt2) : Tot (size32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let parse32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (p2' : parser32 p2 { k1 `is_weaker_than` k2 }) : Tot (parser32 (weaken k1 p2)) = fun x -> p2' x inline_for_extraction let serialize32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2' : serializer32 s2 { k1 `is_weaker_than` k2 })
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_weaken (k1 #k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2': serializer32 s2 {k1 `is_weaker_than` k2}) : Tot (serializer32 (serialize_weaken k1 s2))
[]
LowParse.SLow.Combinators.serialize32_weaken
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
k1: LowParse.Spec.Base.parser_kind -> s2': LowParse.SLow.Base.serializer32 s2 {LowParse.Spec.Base.is_weaker_than k1 k2} -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Combinators.serialize_weaken k1 s2)
{ "end_col": 16, "end_line": 517, "start_col": 2, "start_line": 517 }
Prims.Tot
val size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': size32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2': size32 s2) : Tot (size32 (serialize_nondep_then s1 s2))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } ))
val size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': size32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2': size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': size32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2': size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) =
false
null
false
fun x -> [@@ inline_let ]let _ = serialize_nondep_then_eq s1 s2 x in match x with | x1, x2 -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z: U32.t{size32_postcond (serialize_nondep_then s1 s2) x z}))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "FStar.Pervasives.Native.tuple2", "FStar.UInt32.t", "LowParse.SLow.Base.size32_postcond", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.nondep_then", "LowParse.Spec.Combinators.serialize_nondep_then", "LowParse.SLow.Base.add_overflow", "Prims.unit", "LowParse.Spec.Combinators.serialize_nondep_then_eq" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2)
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1': size32 s1 {k1.parser_kind_subkind == Some ParserStrong}) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2': size32 s2) : Tot (size32 (serialize_nondep_then s1 s2))
[]
LowParse.SLow.Combinators.size32_nondep_then
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s1': LowParse.SLow.Base.size32 s1 { Mkparser_kind'?.parser_kind_subkind k1 == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> s2': LowParse.SLow.Base.size32 s2 -> LowParse.SLow.Base.size32 (LowParse.Spec.Combinators.serialize_nondep_then s1 s2)
{ "end_col": 79, "end_line": 386, "start_col": 2, "start_line": 379 }
Prims.Tot
val serialize32_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (#st: serializer pt) (st32: serializer32 st) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (tag_of_data': (x: data_t -> Tot (y: tag_t{y == tag_of_data x}))) (#k: parser_kind) (#p: (t: tag_t -> Tot (parser k (refine_with_tag tag_of_data t)))) (#s: (t: tag_t -> Tot (serializer (p t)))) (s32: (t: tag_t -> Tot (serializer32 (s t)))) (x: squash (kt.parser_kind_subkind == Some ParserStrong /\ (match kt.parser_kind_high, k.parser_kind_high with | Some max1, Some max2 -> max1 + max2 < 4294967296 | _ -> False))) : Tot (serializer32 (serialize_tagged_union st tag_of_data s))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (#st: serializer pt) (st32: serializer32 st) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (tag_of_data' : ((x: data_t) -> Tot (y: tag_t { y == tag_of_data x }))) (#k: parser_kind) (#p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t))) (#s: (t: tag_t) -> Tot (serializer (p t))) (s32: (t: tag_t) -> Tot (serializer32 (s t))) (x: squash ( kt.parser_kind_subkind == Some ParserStrong /\ begin match kt.parser_kind_high, k.parser_kind_high with | Some max1, Some max2 -> max1 + max2 < 4294967296 | _ -> False end )) : Tot (serializer32 (serialize_tagged_union st tag_of_data s)) = fun x -> serialize_tagged_union_eq st tag_of_data s x; let tg = tag_of_data' x in st32 tg `B32.append` s32 tg x
val serialize32_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (#st: serializer pt) (st32: serializer32 st) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (tag_of_data': (x: data_t -> Tot (y: tag_t{y == tag_of_data x}))) (#k: parser_kind) (#p: (t: tag_t -> Tot (parser k (refine_with_tag tag_of_data t)))) (#s: (t: tag_t -> Tot (serializer (p t)))) (s32: (t: tag_t -> Tot (serializer32 (s t)))) (x: squash (kt.parser_kind_subkind == Some ParserStrong /\ (match kt.parser_kind_high, k.parser_kind_high with | Some max1, Some max2 -> max1 + max2 < 4294967296 | _ -> False))) : Tot (serializer32 (serialize_tagged_union st tag_of_data s)) let serialize32_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (#st: serializer pt) (st32: serializer32 st) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (tag_of_data': (x: data_t -> Tot (y: tag_t{y == tag_of_data x}))) (#k: parser_kind) (#p: (t: tag_t -> Tot (parser k (refine_with_tag tag_of_data t)))) (#s: (t: tag_t -> Tot (serializer (p t)))) (s32: (t: tag_t -> Tot (serializer32 (s t)))) (x: squash (kt.parser_kind_subkind == Some ParserStrong /\ (match kt.parser_kind_high, k.parser_kind_high with | Some max1, Some max2 -> max1 + max2 < 4294967296 | _ -> False))) : Tot (serializer32 (serialize_tagged_union st tag_of_data s)) =
false
null
false
fun x -> serialize_tagged_union_eq st tag_of_data s x; let tg = tag_of_data' x in (st32 tg) `B32.append` (s32 tg x)
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "Prims.eq2", "LowParse.Spec.Base.refine_with_tag", "Prims.squash", "Prims.l_and", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "FStar.Pervasives.Native.Mktuple2", "Prims.nat", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Addition", "FStar.Pervasives.Native.tuple2", "Prims.l_False", "Prims.logical", "FStar.Bytes.append", "Prims.unit", "LowParse.Spec.Combinators.serialize_tagged_union_eq", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.parse_tagged_union", "LowParse.Spec.Combinators.serialize_tagged_union" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } )) inline_for_extraction let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x))) : Tot (size32 (serialize_dtuple2 s1 s2)) = fun x -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_dtuple2 s1 s2) x z } )) inline_for_extraction let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun x -> s32 x inline_for_extraction let size32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in [@inline_let] let x = g1' input in [@inline_let] let y = s1' x in (y <: (res: U32.t { size32_postcond (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let size32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = size32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (p32: ((k: kt1) -> Tot (parser32 (p k)))) (k: kt2) : Tot (parser32 (p (f k))) = fun input -> p32 (f k) input inline_for_extraction let serialize32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (serializer32 (s k)))) (k: kt2) : Tot (serializer32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let size32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (size32 (s k)))) (k: kt2) : Tot (size32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let parse32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (p2' : parser32 p2 { k1 `is_weaker_than` k2 }) : Tot (parser32 (weaken k1 p2)) = fun x -> p2' x inline_for_extraction let serialize32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2' : serializer32 s2 { k1 `is_weaker_than` k2 }) : Tot (serializer32 (serialize_weaken k1 s2)) = fun x -> s2' x inline_for_extraction let size32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2' : size32 s2 { k1 `is_weaker_than` k2 }) : Tot (size32 (serialize_weaken k1 s2)) = fun x -> s2' x inline_for_extraction let lift_parser32 (#k: parser_kind) (#t: Type) (f: unit -> GTot (parser k t)) (f32: parser32 (f ())) : Tot (parser32 (lift_parser f)) = fun x -> f32 x inline_for_extraction let lift_serializer32 (#k: parser_kind) (#t: Type) (f: unit -> GTot (parser k t)) (s: unit -> GTot (serializer (f ()))) (s32: serializer32 (s ())) : Tot (serializer32 (lift_serializer #k #t #f s)) = fun x -> s32 x inline_for_extraction let parse32_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (pt32: parser32 pt) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (#p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t))) (p32: (t: tag_t) -> Tot (parser32 (p t))) : Tot (parser32 (parse_tagged_union pt tag_of_data p)) = fun input -> parse_tagged_union_eq pt tag_of_data p (B32.reveal input); match pt32 input with | None -> None | Some (tg, consumed_tg) -> let input_tg = B32.slice input consumed_tg (B32.len input) in begin match p32 tg input_tg with | None -> None | Some (x, consumed_x) -> Some ((x <: data_t), consumed_tg `U32.add` consumed_x) end inline_for_extraction let serialize32_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (#st: serializer pt) (st32: serializer32 st) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (tag_of_data' : ((x: data_t) -> Tot (y: tag_t { y == tag_of_data x }))) (#k: parser_kind) (#p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t))) (#s: (t: tag_t) -> Tot (serializer (p t))) (s32: (t: tag_t) -> Tot (serializer32 (s t))) (x: squash ( kt.parser_kind_subkind == Some ParserStrong /\ begin match kt.parser_kind_high, k.parser_kind_high with | Some max1, Some max2 -> max1 + max2 < 4294967296 | _ -> False end )) : Tot (serializer32 (serialize_tagged_union st tag_of_data s))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (#st: serializer pt) (st32: serializer32 st) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (tag_of_data': (x: data_t -> Tot (y: tag_t{y == tag_of_data x}))) (#k: parser_kind) (#p: (t: tag_t -> Tot (parser k (refine_with_tag tag_of_data t)))) (#s: (t: tag_t -> Tot (serializer (p t)))) (s32: (t: tag_t -> Tot (serializer32 (s t)))) (x: squash (kt.parser_kind_subkind == Some ParserStrong /\ (match kt.parser_kind_high, k.parser_kind_high with | Some max1, Some max2 -> max1 + max2 < 4294967296 | _ -> False))) : Tot (serializer32 (serialize_tagged_union st tag_of_data s))
[]
LowParse.SLow.Combinators.serialize32_tagged_union
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
st32: LowParse.SLow.Base.serializer32 st -> tag_of_data: (_: data_t -> Prims.GTot tag_t) -> tag_of_data': (x: data_t -> y: tag_t{y == tag_of_data x}) -> s32: (t: tag_t -> LowParse.SLow.Base.serializer32 (s t)) -> x: Prims.squash (Mkparser_kind'?.parser_kind_subkind kt == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\ (match Mkparser_kind'?.parser_kind_high kt, Mkparser_kind'?.parser_kind_high k with | FStar.Pervasives.Native.Mktuple2 #_ #_ (FStar.Pervasives.Native.Some #_ max1) (FStar.Pervasives.Native.Some #_ max2) -> max1 + max2 < 4294967296 | _ -> Prims.l_False)) -> LowParse.SLow.Base.serializer32 (LowParse.Spec.Combinators.serialize_tagged_union st tag_of_data s)
{ "end_col": 33, "end_line": 599, "start_col": 2, "start_line": 596 }
Prims.Tot
val make_total_constant_size_parser32 (sz: nat) (sz': U32.t{U32.v sz' == sz}) (#t: Type) (f: (s: bytes{Seq.length s == sz} -> GTot (t))) (u: unit{make_total_constant_size_parser_precond sz t f}) (f': (s: B32.lbytes sz -> Tot (y: t{y == f (B32.reveal s)}))) : Tot (parser32 (make_total_constant_size_parser sz t f))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } ))
val make_total_constant_size_parser32 (sz: nat) (sz': U32.t{U32.v sz' == sz}) (#t: Type) (f: (s: bytes{Seq.length s == sz} -> GTot (t))) (u: unit{make_total_constant_size_parser_precond sz t f}) (f': (s: B32.lbytes sz -> Tot (y: t{y == f (B32.reveal s)}))) : Tot (parser32 (make_total_constant_size_parser sz t f)) let make_total_constant_size_parser32 (sz: nat) (sz': U32.t{U32.v sz' == sz}) (#t: Type) (f: (s: bytes{Seq.length s == sz} -> GTot (t))) (u: unit{make_total_constant_size_parser_precond sz t f}) (f': (s: B32.lbytes sz -> Tot (y: t{y == f (B32.reveal s)}))) : Tot (parser32 (make_total_constant_size_parser sz t f)) =
false
null
false
fun (input: bytes32) -> ((if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz')) <: (res: option (t * U32.t) {parser32_correct (make_total_constant_size_parser sz t f) input res}))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "LowParse.Bytes.bytes", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.unit", "LowParse.Spec.Combinators.make_total_constant_size_parser_precond", "FStar.Bytes.lbytes", "FStar.Bytes.reveal", "LowParse.SLow.Base.bytes32", "FStar.UInt32.lt", "FStar.Bytes.len", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple2", "Prims.bool", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "FStar.Bytes.bytes", "FStar.Seq.Base.seq", "FStar.UInt8.t", "FStar.Seq.Base.slice", "FStar.UInt32.uint_to_t", "FStar.Bytes.slice", "FStar.UInt32.__uint_to_t", "FStar.Pervasives.Native.option", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Base.total_constant_size_parser_kind", "LowParse.Spec.Combinators.make_total_constant_size_parser", "LowParse.SLow.Base.parser32" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } )))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val make_total_constant_size_parser32 (sz: nat) (sz': U32.t{U32.v sz' == sz}) (#t: Type) (f: (s: bytes{Seq.length s == sz} -> GTot (t))) (u: unit{make_total_constant_size_parser_precond sz t f}) (f': (s: B32.lbytes sz -> Tot (y: t{y == f (B32.reveal s)}))) : Tot (parser32 (make_total_constant_size_parser sz t f))
[]
LowParse.SLow.Combinators.make_total_constant_size_parser32
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: Prims.nat -> sz': FStar.UInt32.t{FStar.UInt32.v sz' == sz} -> f: (s: LowParse.Bytes.bytes{FStar.Seq.Base.length s == sz} -> Prims.GTot t) -> u123: u128: Prims.unit{LowParse.Spec.Combinators.make_total_constant_size_parser_precond sz t f} -> f': (s: FStar.Bytes.lbytes sz -> y: t{y == f (FStar.Bytes.reveal s)}) -> LowParse.SLow.Base.parser32 (LowParse.Spec.Combinators.make_total_constant_size_parser sz t f)
{ "end_col": 106, "end_line": 364, "start_col": 2, "start_line": 358 }
Prims.Tot
val make_constant_size_parser32 (sz: nat) (sz': U32.t{U32.v sz' == sz}) (#t: Type) (f: (s: bytes{Seq.length s == sz} -> GTot (option t))) (u: unit{make_constant_size_parser_precond sz t f}) (f': (s: B32.lbytes sz -> Tot (y: option t {y == f (B32.reveal s)}))) : Tot (parser32 (make_constant_size_parser sz t f))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } ))
val make_constant_size_parser32 (sz: nat) (sz': U32.t{U32.v sz' == sz}) (#t: Type) (f: (s: bytes{Seq.length s == sz} -> GTot (option t))) (u: unit{make_constant_size_parser_precond sz t f}) (f': (s: B32.lbytes sz -> Tot (y: option t {y == f (B32.reveal s)}))) : Tot (parser32 (make_constant_size_parser sz t f)) let make_constant_size_parser32 (sz: nat) (sz': U32.t{U32.v sz' == sz}) (#t: Type) (f: (s: bytes{Seq.length s == sz} -> GTot (option t))) (u: unit{make_constant_size_parser_precond sz t f}) (f': (s: B32.lbytes sz -> Tot (y: option t {y == f (B32.reveal s)}))) : Tot (parser32 (make_constant_size_parser sz t f)) =
false
null
false
fun (input: bytes32) -> ((if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz')) <: (res: option (t * U32.t) {parser32_correct (make_constant_size_parser sz t f) input res}))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "Prims.nat", "FStar.UInt32.t", "Prims.eq2", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v", "LowParse.Bytes.bytes", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "FStar.Pervasives.Native.option", "Prims.unit", "LowParse.Spec.Combinators.make_constant_size_parser_precond", "FStar.Bytes.lbytes", "FStar.Bytes.reveal", "LowParse.SLow.Base.bytes32", "FStar.UInt32.lt", "FStar.Bytes.len", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple2", "Prims.bool", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Combinators.constant_size_parser_kind", "LowParse.Spec.Combinators.make_constant_size_parser", "FStar.Bytes.bytes", "FStar.Seq.Base.seq", "FStar.UInt8.t", "FStar.Seq.Base.slice", "FStar.UInt32.uint_to_t", "FStar.Bytes.slice", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.parser32" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } )))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val make_constant_size_parser32 (sz: nat) (sz': U32.t{U32.v sz' == sz}) (#t: Type) (f: (s: bytes{Seq.length s == sz} -> GTot (option t))) (u: unit{make_constant_size_parser_precond sz t f}) (f': (s: B32.lbytes sz -> Tot (y: option t {y == f (B32.reveal s)}))) : Tot (parser32 (make_constant_size_parser sz t f))
[]
LowParse.SLow.Combinators.make_constant_size_parser32
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: Prims.nat -> sz': FStar.UInt32.t{FStar.UInt32.v sz' == sz} -> f: (s: LowParse.Bytes.bytes{FStar.Seq.Base.length s == sz} -> Prims.GTot (FStar.Pervasives.Native.option t)) -> u117: u122: Prims.unit{LowParse.Spec.Combinators.make_constant_size_parser_precond sz t f} -> f': (s: FStar.Bytes.lbytes sz -> y: FStar.Pervasives.Native.option t {y == f (FStar.Bytes.reveal s)}) -> LowParse.SLow.Base.parser32 (LowParse.Spec.Combinators.make_constant_size_parser sz t f)
{ "end_col": 100, "end_line": 345, "start_col": 2, "start_line": 336 }
Prims.Tot
val parse32_and_then (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (#k': parser_kind) (#t': Type) (p': (t -> Tot (parser k' t'))) (u: unit{and_then_cases_injective p'}) (p32': (x: t -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p'))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } ))
val parse32_and_then (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (#k': parser_kind) (#t': Type) (p': (t -> Tot (parser k' t'))) (u: unit{and_then_cases_injective p'}) (p32': (x: t -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) let parse32_and_then (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (#k': parser_kind) (#t': Type) (p': (t -> Tot (parser k' t'))) (u: unit{and_then_cases_injective p'}) (p32': (x: t -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) =
false
null
false
fun (input: bytes32) -> (([@@ inline_let ]let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in (match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None) | _ -> None) <: (res: option (t' * U32.t) {parser32_correct (p `and_then` p') input res}))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "Prims.unit", "LowParse.Spec.Combinators.and_then_cases_injective", "LowParse.SLow.Base.bytes32", "FStar.UInt32.t", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "FStar.UInt32.add", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.None", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.and_then", "FStar.Bytes.bytes", "Prims.eq2", "FStar.Seq.Base.seq", "FStar.UInt8.t", "FStar.Bytes.reveal", "FStar.Seq.Base.slice", "FStar.UInt32.v", "FStar.Bytes.len", "FStar.Bytes.slice", "LowParse.Spec.Combinators.and_then_eq" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x))))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_and_then (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (#k': parser_kind) (#t': Type) (p': (t -> Tot (parser k' t'))) (u: unit{and_then_cases_injective p'}) (p32': (x: t -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p'))
[]
LowParse.SLow.Combinators.parse32_and_then
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p32: LowParse.SLow.Base.parser32 p -> p': (_: t -> LowParse.Spec.Base.parser k' t') -> u24: u27: Prims.unit{LowParse.Spec.Combinators.and_then_cases_injective p'} -> p32': (x: t -> LowParse.SLow.Base.parser32 (p' x)) -> LowParse.SLow.Base.parser32 (LowParse.Spec.Combinators.and_then p p')
{ "end_col": 84, "end_line": 81, "start_col": 2, "start_line": 69 }
Prims.Tot
val parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1': parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2': parser32 p2) : Tot (parser32 (nondep_then p1 p2))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } ))
val parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1': parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2': parser32 p2) : Tot (parser32 (nondep_then p1 p2)) let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1': parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2': parser32 p2) : Tot (parser32 (nondep_then p1 p2)) =
false
null
false
fun (input: bytes32) -> (([@@ inline_let ]let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in (match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None) | _ -> None) <: (res: option ((t1 * t2) * U32.t) {parser32_correct (p1 `nondep_then` p2) input res}))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.SLow.Base.bytes32", "FStar.UInt32.t", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "FStar.UInt32.add", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.None", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.nondep_then", "FStar.Bytes.bytes", "Prims.eq2", "FStar.Seq.Base.seq", "FStar.UInt8.t", "FStar.Bytes.reveal", "FStar.Seq.Base.slice", "FStar.UInt32.v", "FStar.Bytes.len", "FStar.Bytes.slice", "Prims.unit", "LowParse.Spec.Combinators.nondep_then_eq" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2)
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1': parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2': parser32 p2) : Tot (parser32 (nondep_then p1 p2))
[]
LowParse.SLow.Combinators.parse32_nondep_then
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1': LowParse.SLow.Base.parser32 p1 -> p2': LowParse.SLow.Base.parser32 p2 -> LowParse.SLow.Base.parser32 (LowParse.Spec.Combinators.nondep_then p1 p2)
{ "end_col": 95, "end_line": 106, "start_col": 2, "start_line": 94 }
Prims.Tot
val parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1': parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1 -> Tot (parser k2 (t2 x)))) (p2': (x: t1 -> Tot (parser32 (p2 x)))) : Tot (parser32 (parse_dtuple2 p1 p2))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } ))
val parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1': parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1 -> Tot (parser k2 (t2 x)))) (p2': (x: t1 -> Tot (parser32 (p2 x)))) : Tot (parser32 (parse_dtuple2 p1 p2)) let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1': parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1 -> Tot (parser k2 (t2 x)))) (p2': (x: t1 -> Tot (parser32 (p2 x)))) : Tot (parser32 (parse_dtuple2 p1 p2)) =
false
null
false
fun (input: bytes32) -> (([@@ inline_let ]let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in (match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None) | _ -> None) <: (res: option (dtuple2 t1 t2 * U32.t) {parser32_correct (parse_dtuple2 p1 p2) input res}))
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.SLow.Base.bytes32", "FStar.UInt32.t", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.tuple2", "Prims.dtuple2", "FStar.Pervasives.Native.Mktuple2", "Prims.Mkdtuple2", "FStar.UInt32.add", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.None", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.parse_dtuple2", "FStar.Bytes.bytes", "Prims.eq2", "FStar.Seq.Base.seq", "FStar.UInt8.t", "FStar.Bytes.reveal", "FStar.Seq.Base.slice", "FStar.UInt32.v", "FStar.Bytes.len", "FStar.Bytes.slice", "Prims.unit", "LowParse.Spec.Combinators.parse_dtuple2_eq" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x)))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1': parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1 -> Tot (parser k2 (t2 x)))) (p2': (x: t1 -> Tot (parser32 (p2 x)))) : Tot (parser32 (parse_dtuple2 p1 p2))
[]
LowParse.SLow.Combinators.parse32_dtuple2
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1': LowParse.SLow.Base.parser32 p1 -> p2': (x: t1 -> LowParse.SLow.Base.parser32 (p2 x)) -> LowParse.SLow.Base.parser32 (LowParse.Spec.Combinators.parse_dtuple2 p1 p2)
{ "end_col": 99, "end_line": 167, "start_col": 2, "start_line": 155 }
Prims.Tot
val parse32_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (pt32: parser32 pt) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (#p: (t: tag_t -> Tot (parser k (refine_with_tag tag_of_data t)))) (p32: (t: tag_t -> Tot (parser32 (p t)))) : Tot (parser32 (parse_tagged_union pt tag_of_data p))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (pt32: parser32 pt) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (#p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t))) (p32: (t: tag_t) -> Tot (parser32 (p t))) : Tot (parser32 (parse_tagged_union pt tag_of_data p)) = fun input -> parse_tagged_union_eq pt tag_of_data p (B32.reveal input); match pt32 input with | None -> None | Some (tg, consumed_tg) -> let input_tg = B32.slice input consumed_tg (B32.len input) in begin match p32 tg input_tg with | None -> None | Some (x, consumed_x) -> Some ((x <: data_t), consumed_tg `U32.add` consumed_x) end
val parse32_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (pt32: parser32 pt) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (#p: (t: tag_t -> Tot (parser k (refine_with_tag tag_of_data t)))) (p32: (t: tag_t -> Tot (parser32 (p t)))) : Tot (parser32 (parse_tagged_union pt tag_of_data p)) let parse32_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (pt32: parser32 pt) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (#p: (t: tag_t -> Tot (parser k (refine_with_tag tag_of_data t)))) (p32: (t: tag_t -> Tot (parser32 (p t)))) : Tot (parser32 (parse_tagged_union pt tag_of_data p)) =
false
null
false
fun input -> parse_tagged_union_eq pt tag_of_data p (B32.reveal input); match pt32 input with | None -> None | Some (tg, consumed_tg) -> let input_tg = B32.slice input consumed_tg (B32.len input) in match p32 tg input_tg with | None -> None | Some (x, consumed_x) -> Some ((x <: data_t), consumed_tg `U32.add` consumed_x)
{ "checked_file": "LowParse.SLow.Combinators.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.SLow.Base.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Combinators.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.Spec.Base.refine_with_tag", "LowParse.SLow.Base.bytes32", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple2", "FStar.UInt32.t", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "FStar.UInt32.add", "FStar.Pervasives.Native.option", "LowParse.SLow.Base.parser32_correct", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.parse_tagged_union", "FStar.Bytes.bytes", "Prims.eq2", "FStar.Seq.Base.seq", "FStar.UInt8.t", "FStar.Bytes.reveal", "FStar.Seq.Base.slice", "FStar.UInt32.v", "FStar.Bytes.len", "FStar.Bytes.slice", "Prims.unit", "LowParse.Spec.Combinators.parse_tagged_union_eq" ]
[]
module LowParse.SLow.Combinators include LowParse.SLow.Base include LowParse.Spec.Combinators module B32 = FStar.Bytes module U32 = FStar.UInt32 #reset-options "--z3rlimit 16 --max_fuel 8 --max_ifuel 8" inline_for_extraction let parse32_ret (#t: Type) (x: t) : Tot (parser32 (parse_ret x)) = (fun input -> ((Some (x, 0ul)) <: (res: option (t * U32.t) { parser32_correct (parse_ret x) input res } ))) inline_for_extraction let parse32_empty : parser32 parse_empty = parse32_ret () inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (serializer32 (serialize_ret v v_unique)) = fun input -> [@inline_let] let b = B32.empty_bytes in assert (B32.reveal b `Seq.equal` Seq.empty); (b <: (b: bytes32 { serializer32_correct #_ #_ #(parse_ret v) (serialize_ret v v_unique) input b } )) inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let size32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v')) : Tot (size32 #_ #_ #(parse_ret v) (serialize_ret v v_unique)) = size32_constant #_ #_ #(parse_ret v) (serialize_ret v v_unique) 0ul () inline_for_extraction let size32_empty : size32 #_ #_ #parse_empty serialize_empty = size32_ret () (fun _ -> ()) inline_for_extraction let parse32_false : parser32 parse_false = fun _ -> None inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun input -> B32.empty_bytes inline_for_extraction let size32_false : size32 #_ #_ #parse_false serialize_false = fun input -> 0ul inline_for_extraction let parse32_and_then (#k: parser_kind) (#t:Type) (#p:parser k t) (p32: parser32 p) (#k': parser_kind) (#t':Type) (p': (t -> Tot (parser k' t'))) (u: unit { and_then_cases_injective p' } ) (p32' : ((x: t) -> Tot (parser32 (p' x)))) : Tot (parser32 (p `and_then` p')) = fun (input: bytes32) -> (( [@inline_let] let _ = and_then_eq p p' (B32.reveal input) in match p32 input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p32' v input' with | Some (v', l') -> Some (v', U32.add l l') | _ -> None end | _ -> None ) <: (res: option (t' * U32.t) { parser32_correct (p `and_then` p') input res } )) inline_for_extraction let parse32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : parser32 p2) : Tot (parser32 (nondep_then p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = nondep_then_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' input' with | Some (v', l') -> Some ((v, v'), U32.add l l') | _ -> None end | _ -> None ) <: (res: option ((t1 * t2) * U32.t) { parser32_correct (p1 `nondep_then` p2) input res } )) let serialize32_kind_precond (k1 k2: parser_kind) : GTot bool = Some? k1.parser_kind_high && Some? k2.parser_kind_high && Some?.v k1.parser_kind_high + Some?.v k2.parser_kind_high < 4294967296 inline_for_extraction let serialize32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2 { serialize32_kind_precond k1 k2 }) : Tot (serializer32 (serialize_nondep_then s1 s2)) = fun (input: t1 * t2) -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 input in match input with | (fs, sn) -> let output1 = s1' fs in let output2 = s2' sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize s2 sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_nondep_then s1 s2) input res } )) inline_for_extraction let parse32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : parser32 p1) (#k2: parser_kind) (#t2: (t1 -> Tot Type)) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (p2' : (x: t1) -> Tot (parser32 (p2 x))) : Tot (parser32 (parse_dtuple2 p1 p2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_dtuple2_eq p1 p2 (B32.reveal input) in match p1' input with | Some (v, l) -> let input' = B32.slice input l (B32.len input) in begin match p2' v input' with | Some (v', l') -> Some ((| v, v' |), U32.add l l') | _ -> None end | _ -> None ) <: (res: option (dtuple2 t1 t2 * U32.t) { parser32_correct (parse_dtuple2 p1 p2) input res } )) inline_for_extraction let serialize32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind { serialize32_kind_precond k1 k2 }) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> serializer32 (s2 x)) : Tot (serializer32 (serialize_dtuple2 s1 s2)) = fun (input: dtuple2 t1 t2) -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 input in match input with | (| fs, sn |) -> let output1 = s1' fs in let output2 = s2' fs sn in [@inline_let] let _ = assert (B32.length output1 == Seq.length (serialize s1 fs)) in [@inline_let] let _ = assert (B32.length output2 == Seq.length (serialize (s2 fs) sn)) in ((B32.append output1 output2) <: (res: bytes32 { serializer32_correct (serialize_dtuple2 s1 s2) input res } )) inline_for_extraction let parse32_strengthen (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (p1' : parser32 p1) (p2: t1 -> GTot Type0) (prf: parse_strengthen_prf p1 p2) : Tot (parser32 (parse_strengthen p1 p2 prf)) = fun (xbytes: bytes32) -> (( match p1' xbytes with | Some (x, consumed) -> [@inline_let] let _ = prf (B32.reveal xbytes) (U32.v consumed) x in [@inline_let] let (x' : t1 { p2 x' } ) = x in Some (x', consumed) | _ -> None ) <: (res: option ((x: t1 { p2 x}) * U32.t) { parser32_correct (parse_strengthen p1 p2 prf) xbytes res } )) inline_for_extraction let parse32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (f2': (x: t1) -> Tot (y: t2 { y == f2 x } )) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_synth_eq p1 f2 (B32.reveal input) in match p1' input with | Some (v1, consumed) -> Some (f2' v1, consumed) | _ -> None ) <: (res: option (t2 * U32.t) { parser32_correct (parse_synth p1 f2) input res } )) inline_for_extraction let parse32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : parser32 p1) (u: unit { synth_injective f2 }) : Tot (parser32 (parse_synth p1 f2)) = parse32_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in let x = g1' input in (s1' x <: (res: bytes32 { serializer32_correct (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let serialize32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : serializer32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) = serialize32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (f: (t -> GTot bool)) (g: ((x: t) -> Tot (b: bool { b == f x } ))) : Tot (parser32 (parse_filter p f)) = fun (input: bytes32) -> (( [@inline_let] let _ = parse_filter_eq p f (B32.reveal input) in match p32 input with | Some (v, consumed) -> if g v then [@inline_let] let (v' : t { f v' == true } ) = v in Some (v', consumed) else None | _ -> None ) <: (res: option ((v': t { f v' == true } ) * U32.t) { parser32_correct (parse_filter p f) input res } )) inline_for_extraction let serialize32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (f: (t -> GTot bool)) : Tot (serializer32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun (input: t { f input == true } ) -> s32 input inline_for_extraction let make_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (option t))) (u: unit { make_constant_size_parser_precond sz t f } ) (f' : ((s: B32.lbytes sz) -> Tot (y: option t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else begin let s' = B32.slice input 0ul sz' in match f' s' with | None -> None | Some v -> Some (v, sz') end ) <: (res: option (t * U32.t) { parser32_correct (make_constant_size_parser sz t f) input res } )) inline_for_extraction let make_total_constant_size_parser32 (sz: nat) (sz' : U32.t { U32.v sz' == sz } ) (#t: Type) (f: ((s: bytes {Seq.length s == sz}) -> GTot (t))) (u: unit { make_total_constant_size_parser_precond sz t f }) (f' : ((s: B32.lbytes sz) -> Tot (y: t { y == f (B32.reveal s) } ))) : Tot (parser32 (make_total_constant_size_parser sz t f)) = fun (input: bytes32) -> (( if U32.lt (B32.len input) sz' then None else let s' = B32.slice input 0ul sz' in Some (f' s', sz') ) <: (res: option (t * U32.t) { parser32_correct (make_total_constant_size_parser sz t f) input res } )) inline_for_extraction let size32_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : size32 s2) : Tot (size32 (serialize_nondep_then s1 s2)) = fun x -> [@inline_let] let _ = serialize_nondep_then_eq s1 s2 x in match x with | (x1, x2) -> let v1 = s1' x1 in let v2 = s2' x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_nondep_then s1 s2) x z } )) inline_for_extraction let size32_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : size32 s1 { k1.parser_kind_subkind == Some ParserStrong } ) (#k2: parser_kind) (#t2: t1 -> Tot Type) (#p2: (x: t1) -> Tot (parser k2 (t2 x))) (#s2: (x: t1) -> Tot (serializer (p2 x))) (s2' : (x: t1) -> Tot (size32 (s2 x))) : Tot (size32 (serialize_dtuple2 s1 s2)) = fun x -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> let v1 = s1' x1 in let v2 = s2' x1 x2 in let res = add_overflow v1 v2 in (res <: (z : U32.t { size32_postcond (serialize_dtuple2 s1 s2) x z } )) inline_for_extraction let size32_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: size32 s) (f: (t -> GTot bool)) : Tot (size32 #_ #_ #(parse_filter p f) (serialize_filter s f)) = fun x -> s32 x inline_for_extraction let size32_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> GTot t1) (g1': (x: t2) -> Tot (y: t1 { y == g1 x } ) ) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = fun (input: t2) -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 u input in [@inline_let] let x = g1' input in [@inline_let] let y = s1' x in (y <: (res: U32.t { size32_postcond (serialize_synth p1 f2 s1 g1 u) input res } )) inline_for_extraction let size32_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (s1: serializer p1) (s1' : size32 s1) (g1: t2 -> Tot t1) (u: unit { synth_inverse f2 g1 /\ synth_injective f2 }) : Tot (size32 (serialize_synth p1 f2 s1 g1 u)) = size32_synth p1 f2 s1 s1' g1 (fun x -> g1 x) u inline_for_extraction let parse32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (p32: ((k: kt1) -> Tot (parser32 (p k)))) (k: kt2) : Tot (parser32 (p (f k))) = fun input -> p32 (f k) input inline_for_extraction let serialize32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (serializer32 (s k)))) (k: kt2) : Tot (serializer32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let size32_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (s: ((k: kt1) -> Tot (serializer (p k)))) (s32: ((k: kt1) -> Tot (size32 (s k)))) (k: kt2) : Tot (size32 (s (f k))) = fun input -> s32 (f k) input inline_for_extraction let parse32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (p2' : parser32 p2 { k1 `is_weaker_than` k2 }) : Tot (parser32 (weaken k1 p2)) = fun x -> p2' x inline_for_extraction let serialize32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2' : serializer32 s2 { k1 `is_weaker_than` k2 }) : Tot (serializer32 (serialize_weaken k1 s2)) = fun x -> s2' x inline_for_extraction let size32_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (#s2: serializer p2) (s2' : size32 s2 { k1 `is_weaker_than` k2 }) : Tot (size32 (serialize_weaken k1 s2)) = fun x -> s2' x inline_for_extraction let lift_parser32 (#k: parser_kind) (#t: Type) (f: unit -> GTot (parser k t)) (f32: parser32 (f ())) : Tot (parser32 (lift_parser f)) = fun x -> f32 x inline_for_extraction let lift_serializer32 (#k: parser_kind) (#t: Type) (f: unit -> GTot (parser k t)) (s: unit -> GTot (serializer (f ()))) (s32: serializer32 (s ())) : Tot (serializer32 (lift_serializer #k #t #f s)) = fun x -> s32 x inline_for_extraction let parse32_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (pt32: parser32 pt) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (#p: (t: tag_t) -> Tot (parser k (refine_with_tag tag_of_data t))) (p32: (t: tag_t) -> Tot (parser32 (p t))) : Tot (parser32 (parse_tagged_union pt tag_of_data p))
false
false
LowParse.SLow.Combinators.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 8, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_tagged_union (#kt: parser_kind) (#tag_t: Type) (#pt: parser kt tag_t) (pt32: parser32 pt) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) (#k: parser_kind) (#p: (t: tag_t -> Tot (parser k (refine_with_tag tag_of_data t)))) (p32: (t: tag_t -> Tot (parser32 (p t)))) : Tot (parser32 (parse_tagged_union pt tag_of_data p))
[]
LowParse.SLow.Combinators.parse32_tagged_union
{ "file_name": "src/lowparse/LowParse.SLow.Combinators.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
pt32: LowParse.SLow.Base.parser32 pt -> tag_of_data: (_: data_t -> Prims.GTot tag_t) -> p32: (t: tag_t -> LowParse.SLow.Base.parser32 (p t)) -> LowParse.SLow.Base.parser32 (LowParse.Spec.Combinators.parse_tagged_union pt tag_of_data p)
{ "end_col": 9, "end_line": 571, "start_col": 2, "start_line": 562 }
Prims.Tot
val calc_chain_compatible (#t: Type) (rs: list (relation t)) (p: relation t) : Tot Type0
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let calc_chain_compatible (#t:Type) (rs:list (relation t)) (p:relation t) : Tot Type0 = forall (x y:t). calc_chain_related rs x y ==> p x y
val calc_chain_compatible (#t: Type) (rs: list (relation t)) (p: relation t) : Tot Type0 let calc_chain_compatible (#t: Type) (rs: list (relation t)) (p: relation t) : Tot Type0 =
false
null
false
forall (x: t) (y: t). calc_chain_related rs x y ==> p x y
{ "checked_file": "FStar.Calc.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Calc.fsti" }
[ "total" ]
[ "Prims.list", "FStar.Preorder.relation", "Prims.l_Forall", "Prims.l_imp", "FStar.Calc.calc_chain_related" ]
[]
(* 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: Guido Martinez, Aseem Rastogi, Nikhil Swamy *) module FStar.Calc open FStar.Preorder /// This module provides calculational proofs support /// /// Client programs need not use it directly, /// instead F* provides convenient syntax for writing calculational proofs /// /// See examples/calc for some examples /// The main type for the calc proof chain val calc_chain (#a:Type u#a) (rs:list (relation a)) (x y:a) : Type u#(max 1 a) /// Definition of when a calc chain is sound [@@"opaque_to_smt"] let rec calc_chain_related (#a:Type) (rs:list (relation a)) (x y:a) : Tot Type0 = match rs with | [] -> x == y (* GM: The `:t` annotation below matters a lot for compactness of the formula! *) | r1::rs -> exists (w:a). calc_chain_related rs x w /\ r1 w y [@@"opaque_to_smt"] let calc_chain_compatible (#t:Type) (rs:list (relation t)) (p:relation t)
false
false
FStar.Calc.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val calc_chain_compatible (#t: Type) (rs: list (relation t)) (p: relation t) : Tot Type0
[]
FStar.Calc.calc_chain_compatible
{ "file_name": "ulib/FStar.Calc.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
rs: Prims.list (FStar.Preorder.relation t) -> p: FStar.Preorder.relation t -> Type0
{ "end_col": 55, "end_line": 47, "start_col": 4, "start_line": 47 }
Prims.Tot
val calc_chain_related (#a: Type) (rs: list (relation a)) (x y: a) : Tot Type0
[ { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec calc_chain_related (#a:Type) (rs:list (relation a)) (x y:a) : Tot Type0 = match rs with | [] -> x == y (* GM: The `:t` annotation below matters a lot for compactness of the formula! *) | r1::rs -> exists (w:a). calc_chain_related rs x w /\ r1 w y
val calc_chain_related (#a: Type) (rs: list (relation a)) (x y: a) : Tot Type0 let rec calc_chain_related (#a: Type) (rs: list (relation a)) (x y: a) : Tot Type0 =
false
null
false
match rs with | [] -> x == y | r1 :: rs -> exists (w: a). calc_chain_related rs x w /\ r1 w y
{ "checked_file": "FStar.Calc.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Range.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Calc.fsti" }
[ "total" ]
[ "Prims.list", "FStar.Preorder.relation", "Prims.eq2", "Prims.l_Exists", "Prims.l_and", "FStar.Calc.calc_chain_related" ]
[]
(* 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: Guido Martinez, Aseem Rastogi, Nikhil Swamy *) module FStar.Calc open FStar.Preorder /// This module provides calculational proofs support /// /// Client programs need not use it directly, /// instead F* provides convenient syntax for writing calculational proofs /// /// See examples/calc for some examples /// The main type for the calc proof chain val calc_chain (#a:Type u#a) (rs:list (relation a)) (x y:a) : Type u#(max 1 a) /// Definition of when a calc chain is sound [@@"opaque_to_smt"] let rec calc_chain_related (#a:Type) (rs:list (relation a)) (x y:a)
false
false
FStar.Calc.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val calc_chain_related (#a: Type) (rs: list (relation a)) (x y: a) : Tot Type0
[ "recursion" ]
FStar.Calc.calc_chain_related
{ "file_name": "ulib/FStar.Calc.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
rs: Prims.list (FStar.Preorder.relation a) -> x: a -> y: a -> Type0
{ "end_col": 65, "end_line": 42, "start_col": 4, "start_line": 39 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gst_post (a:Type) = st_post_h heap a
let gst_post (a: Type) =
false
null
false
st_post_h heap a
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "FStar.Pervasives.st_post_h", "FStar.Monotonic.Heap.heap" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap
false
true
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gst_post : a: Type -> Type
[]
FStar.ST.gst_post
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> Type
{ "end_col": 41, "end_line": 30, "start_col": 25, "start_line": 30 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let contains_pred (#a:Type0) (#rel:preorder a) (r:mref a rel) = fun h -> h `contains` r
let contains_pred (#a: Type0) (#rel: preorder a) (r: mref a rel) =
false
null
false
fun h -> h `contains` r
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "FStar.Preorder.preorder", "FStar.Monotonic.Heap.mref", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.Heap.contains" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q (***** ST effect *****) let st_pre = gst_pre let st_post' = gst_post' let st_post = gst_post let st_wp = gst_wp new_effect STATE = GST unfold let lift_gst_state (a:Type) (wp:gst_wp a) = wp sub_effect GST ~> STATE = lift_gst_state effect State (a:Type) (wp:st_wp a) = STATE a wp effect ST (a:Type) (pre:st_pre) (post: (h:heap -> Tot (st_post' a (pre h)))) = STATE a (fun (p:st_post a) (h:heap) -> pre h /\ (forall a h1. post h a h1 ==> p a h1)) effect St (a:Type) = ST a (fun h -> True) (fun h0 r h1 -> True)
false
false
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val contains_pred : r: FStar.Monotonic.Heap.mref a rel -> h: FStar.Monotonic.Heap.heap -> Type0
[]
FStar.ST.contains_pred
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.Monotonic.Heap.mref a rel -> h: FStar.Monotonic.Heap.heap -> Type0
{ "end_col": 87, "end_line": 79, "start_col": 64, "start_line": 79 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gst_pre = st_pre_h heap
let gst_pre =
false
null
false
st_pre_h heap
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "FStar.Pervasives.st_pre_h", "FStar.Monotonic.Heap.heap" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap
false
true
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gst_pre : Type
[]
FStar.ST.gst_pre
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Type
{ "end_col": 37, "end_line": 28, "start_col": 24, "start_line": 28 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre
let gst_post' (a pre: Type) =
false
null
false
st_post_h' heap a pre
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "FStar.Pervasives.st_post_h'", "FStar.Monotonic.Heap.heap" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap
false
true
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gst_post' : a: Type -> pre: Type -> Type
[]
FStar.ST.gst_post'
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> pre: Type -> Type
{ "end_col": 57, "end_line": 29, "start_col": 36, "start_line": 29 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let st_pre = gst_pre
let st_pre =
false
null
false
gst_pre
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "FStar.ST.gst_pre" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q (***** ST effect *****)
false
true
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val st_pre : Type
[]
FStar.ST.st_pre
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Type
{ "end_col": 22, "end_line": 63, "start_col": 15, "start_line": 63 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gst_wp (a:Type) = st_wp_h heap a
let gst_wp (a: Type) =
false
null
false
st_wp_h heap a
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "FStar.Pervasives.st_wp_h", "FStar.Monotonic.Heap.heap" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre
false
true
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gst_wp : a: Type -> Type
[]
FStar.ST.gst_wp
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> Type
{ "end_col": 38, "end_line": 31, "start_col": 24, "start_line": 31 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r))
let heap_rel (h1 h2: heap) =
false
null
false
forall (a: Type0) (rel: preorder a) (r: mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r))
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "FStar.Monotonic.Heap.heap", "Prims.l_Forall", "FStar.Preorder.preorder", "FStar.Monotonic.Heap.mref", "Prims.l_imp", "FStar.Monotonic.Heap.contains", "Prims.l_and", "FStar.Monotonic.Heap.sel", "Prims.logical" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst
false
true
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val heap_rel : h1: FStar.Monotonic.Heap.heap -> h2: FStar.Monotonic.Heap.heap -> Prims.logical
[]
FStar.ST.heap_rel
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
h1: FStar.Monotonic.Heap.heap -> h2: FStar.Monotonic.Heap.heap -> Prims.logical
{ "end_col": 93, "end_line": 38, "start_col": 2, "start_line": 37 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let st_post' = gst_post'
let st_post' =
false
null
false
gst_post'
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "FStar.ST.gst_post'" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q (***** ST effect *****)
false
true
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val st_post' : a: Type -> pre: Type -> Type
[]
FStar.ST.st_post'
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> pre: Type -> Type
{ "end_col": 24, "end_line": 64, "start_col": 15, "start_line": 64 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h)
let lift_div_gst (a: Type) (wp: pure_wp a) (p: gst_post a) (h: heap) =
false
null
false
wp (fun a -> p a h)
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "Prims.pure_wp", "FStar.ST.gst_post", "FStar.Monotonic.Heap.heap", "Prims.l_True", "Prims.pure_pre" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a
false
false
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lift_div_gst : a: Type -> wp: Prims.pure_wp a -> p: FStar.ST.gst_post a -> h: FStar.Monotonic.Heap.heap -> Prims.pure_pre
[]
FStar.ST.lift_div_gst
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> wp: Prims.pure_wp a -> p: FStar.ST.gst_post a -> h: FStar.Monotonic.Heap.heap -> Prims.pure_pre
{ "end_col": 93, "end_line": 33, "start_col": 74, "start_line": 33 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let st_wp = gst_wp
let st_wp =
false
null
false
gst_wp
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "FStar.ST.gst_wp" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q (***** ST effect *****) let st_pre = gst_pre let st_post' = gst_post'
false
true
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val st_wp : a: Type -> Type
[]
FStar.ST.st_wp
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> Type
{ "end_col": 21, "end_line": 66, "start_col": 15, "start_line": 66 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2
let stable (p: heap_predicate) =
false
null
false
forall (h1: heap) (h2: heap). (p h1 /\ heap_rel h1 h2) ==> p h2
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "FStar.ST.heap_predicate", "Prims.l_Forall", "FStar.Monotonic.Heap.heap", "Prims.l_imp", "Prims.l_and", "FStar.ST.heap_rel", "Prims.logical" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0
false
true
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val stable : p: FStar.ST.heap_predicate -> Prims.logical
[]
FStar.ST.stable
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
p: FStar.ST.heap_predicate -> Prims.logical
{ "end_col": 63, "end_line": 46, "start_col": 2, "start_line": 46 }
FStar.ST.STATE
val op_Bang (#a: Type) (#rel: preorder a) (r: mref a rel) : STATE a (fun p h -> p (sel h r) h)
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let op_Bang (#a:Type) (#rel:preorder a) (r:mref a rel) : STATE a (fun p h -> p (sel h r) h) = read #a #rel r
val op_Bang (#a: Type) (#rel: preorder a) (r: mref a rel) : STATE a (fun p h -> p (sel h r) h) let op_Bang (#a: Type) (#rel: preorder a) (r: mref a rel) : STATE a (fun p h -> p (sel h r) h) =
true
null
false
read #a #rel r
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[]
[ "FStar.Preorder.preorder", "FStar.ST.mref", "FStar.ST.read", "FStar.Pervasives.st_post_h", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.Heap.sel" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q (***** ST effect *****) let st_pre = gst_pre let st_post' = gst_post' let st_post = gst_post let st_wp = gst_wp new_effect STATE = GST unfold let lift_gst_state (a:Type) (wp:gst_wp a) = wp sub_effect GST ~> STATE = lift_gst_state effect State (a:Type) (wp:st_wp a) = STATE a wp effect ST (a:Type) (pre:st_pre) (post: (h:heap -> Tot (st_post' a (pre h)))) = STATE a (fun (p:st_post a) (h:heap) -> pre h /\ (forall a h1. post h a h1 ==> p a h1)) effect St (a:Type) = ST a (fun h -> True) (fun h0 r h1 -> True) let contains_pred (#a:Type0) (#rel:preorder a) (r:mref a rel) = fun h -> h `contains` r type mref (a:Type0) (rel:preorder a) = r:Heap.mref a rel{is_mm r = false /\ witnessed (contains_pred r)} let recall (#a:Type) (#rel:preorder a) (r:mref a rel) :STATE unit (fun p h -> Heap.contains h r ==> p () h) = gst_recall (contains_pred r) let alloc (#a:Type) (#rel:preorder a) (init:a) :ST (mref a rel) (fun h -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init) = let h0 = gst_get () in let r, h1 = alloc rel h0 init false in gst_put h1; gst_witness (contains_pred r); r let read (#a:Type) (#rel:preorder a) (r:mref a rel) :STATE a (fun p h -> p (sel h r) h) = let h0 = gst_get () in gst_recall (contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs h0 r; sel_tot h0 r let write (#a:Type) (#rel:preorder a) (r:mref a rel) (v:a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) = let h0 = gst_get () in gst_recall (contains_pred r); let h1 = upd_tot h0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs h0 r v; gst_put h1 let get (u:unit) :ST heap (fun h -> True) (fun h0 h h1 -> h0==h1 /\ h==h1) = gst_get () let op_Bang (#a:Type) (#rel:preorder a) (r:mref a rel)
false
false
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_Bang (#a: Type) (#rel: preorder a) (r: mref a rel) : STATE a (fun p h -> p (sel h r) h)
[]
FStar.ST.op_Bang
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.ST.mref a rel -> FStar.ST.STATE a
{ "end_col": 16, "end_line": 120, "start_col": 2, "start_line": 120 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let st_post = gst_post
let st_post =
false
null
false
gst_post
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "FStar.ST.gst_post" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q (***** ST effect *****) let st_pre = gst_pre
false
true
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val st_post : a: Type -> Type
[]
FStar.ST.st_post
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> Type
{ "end_col": 23, "end_line": 65, "start_col": 15, "start_line": 65 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lift_gst_state (a:Type) (wp:gst_wp a) = wp
let lift_gst_state (a: Type) (wp: gst_wp a) =
false
null
false
wp
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "FStar.ST.gst_wp" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q (***** ST effect *****) let st_pre = gst_pre let st_post' = gst_post' let st_post = gst_post let st_wp = gst_wp new_effect STATE = GST
false
false
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lift_gst_state : a: Type -> wp: FStar.ST.gst_wp a -> FStar.ST.gst_wp a
[]
FStar.ST.lift_gst_state
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> wp: FStar.ST.gst_wp a -> FStar.ST.gst_wp a
{ "end_col": 53, "end_line": 70, "start_col": 51, "start_line": 70 }
Prims.Tot
val witnessed (p: heap_predicate{stable p}) : Type0
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p
val witnessed (p: heap_predicate{stable p}) : Type0 let witnessed (p: heap_predicate{stable p}) : Type0 =
false
null
false
W.witnessed heap_rel p
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "FStar.ST.heap_predicate", "FStar.ST.stable", "FStar.Monotonic.Witnessed.witnessed", "FStar.Monotonic.Heap.heap", "FStar.ST.heap_rel" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2
false
false
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val witnessed (p: heap_predicate{stable p}) : Type0
[]
FStar.ST.witnessed
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
p: FStar.ST.heap_predicate{FStar.ST.stable p} -> Type0
{ "end_col": 75, "end_line": 49, "start_col": 53, "start_line": 49 }
FStar.ST.STATE
val recall (#a: Type) (#rel: preorder a) (r: mref a rel) : STATE unit (fun p h -> Heap.contains h r ==> p () h)
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let recall (#a:Type) (#rel:preorder a) (r:mref a rel) :STATE unit (fun p h -> Heap.contains h r ==> p () h) = gst_recall (contains_pred r)
val recall (#a: Type) (#rel: preorder a) (r: mref a rel) : STATE unit (fun p h -> Heap.contains h r ==> p () h) let recall (#a: Type) (#rel: preorder a) (r: mref a rel) : STATE unit (fun p h -> Heap.contains h r ==> p () h) =
true
null
false
gst_recall (contains_pred r)
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[]
[ "FStar.Preorder.preorder", "FStar.ST.mref", "FStar.ST.gst_recall", "FStar.ST.contains_pred", "Prims.unit", "FStar.Pervasives.st_post_h", "FStar.Monotonic.Heap.heap", "Prims.l_imp", "FStar.Monotonic.Heap.contains" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q (***** ST effect *****) let st_pre = gst_pre let st_post' = gst_post' let st_post = gst_post let st_wp = gst_wp new_effect STATE = GST unfold let lift_gst_state (a:Type) (wp:gst_wp a) = wp sub_effect GST ~> STATE = lift_gst_state effect State (a:Type) (wp:st_wp a) = STATE a wp effect ST (a:Type) (pre:st_pre) (post: (h:heap -> Tot (st_post' a (pre h)))) = STATE a (fun (p:st_post a) (h:heap) -> pre h /\ (forall a h1. post h a h1 ==> p a h1)) effect St (a:Type) = ST a (fun h -> True) (fun h0 r h1 -> True) let contains_pred (#a:Type0) (#rel:preorder a) (r:mref a rel) = fun h -> h `contains` r type mref (a:Type0) (rel:preorder a) = r:Heap.mref a rel{is_mm r = false /\ witnessed (contains_pred r)}
false
false
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val recall (#a: Type) (#rel: preorder a) (r: mref a rel) : STATE unit (fun p h -> Heap.contains h r ==> p () h)
[]
FStar.ST.recall
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.ST.mref a rel -> FStar.ST.STATE Prims.unit
{ "end_col": 32, "end_line": 84, "start_col": 4, "start_line": 84 }
FStar.ST.ST
val get (u: unit) : ST heap (fun h -> True) (fun h0 h h1 -> h0 == h1 /\ h == h1)
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get (u:unit) :ST heap (fun h -> True) (fun h0 h h1 -> h0==h1 /\ h==h1) = gst_get ()
val get (u: unit) : ST heap (fun h -> True) (fun h0 h h1 -> h0 == h1 /\ h == h1) let get (u: unit) : ST heap (fun h -> True) (fun h0 h h1 -> h0 == h1 /\ h == h1) =
true
null
false
gst_get ()
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[]
[ "Prims.unit", "FStar.ST.gst_get", "FStar.Monotonic.Heap.heap", "Prims.l_True", "Prims.l_and", "Prims.eq2" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q (***** ST effect *****) let st_pre = gst_pre let st_post' = gst_post' let st_post = gst_post let st_wp = gst_wp new_effect STATE = GST unfold let lift_gst_state (a:Type) (wp:gst_wp a) = wp sub_effect GST ~> STATE = lift_gst_state effect State (a:Type) (wp:st_wp a) = STATE a wp effect ST (a:Type) (pre:st_pre) (post: (h:heap -> Tot (st_post' a (pre h)))) = STATE a (fun (p:st_post a) (h:heap) -> pre h /\ (forall a h1. post h a h1 ==> p a h1)) effect St (a:Type) = ST a (fun h -> True) (fun h0 r h1 -> True) let contains_pred (#a:Type0) (#rel:preorder a) (r:mref a rel) = fun h -> h `contains` r type mref (a:Type0) (rel:preorder a) = r:Heap.mref a rel{is_mm r = false /\ witnessed (contains_pred r)} let recall (#a:Type) (#rel:preorder a) (r:mref a rel) :STATE unit (fun p h -> Heap.contains h r ==> p () h) = gst_recall (contains_pred r) let alloc (#a:Type) (#rel:preorder a) (init:a) :ST (mref a rel) (fun h -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init) = let h0 = gst_get () in let r, h1 = alloc rel h0 init false in gst_put h1; gst_witness (contains_pred r); r let read (#a:Type) (#rel:preorder a) (r:mref a rel) :STATE a (fun p h -> p (sel h r) h) = let h0 = gst_get () in gst_recall (contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs h0 r; sel_tot h0 r let write (#a:Type) (#rel:preorder a) (r:mref a rel) (v:a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) = let h0 = gst_get () in gst_recall (contains_pred r); let h1 = upd_tot h0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs h0 r v; gst_put h1
false
false
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get (u: unit) : ST heap (fun h -> True) (fun h0 h h1 -> h0 == h1 /\ h == h1)
[]
FStar.ST.get
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
u40: Prims.unit -> FStar.ST.ST FStar.Monotonic.Heap.heap
{ "end_col": 87, "end_line": 116, "start_col": 77, "start_line": 116 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let modifies_none (h0:heap) (h1:heap) = modifies !{} h0 h1
let modifies_none (h0 h1: heap) =
false
null
false
modifies FStar.Set.empty h0 h1
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "total" ]
[ "FStar.Monotonic.Heap.heap", "FStar.Monotonic.Heap.modifies", "FStar.Set.empty", "Prims.nat", "Prims.logical" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q (***** ST effect *****) let st_pre = gst_pre let st_post' = gst_post' let st_post = gst_post let st_wp = gst_wp new_effect STATE = GST unfold let lift_gst_state (a:Type) (wp:gst_wp a) = wp sub_effect GST ~> STATE = lift_gst_state effect State (a:Type) (wp:st_wp a) = STATE a wp effect ST (a:Type) (pre:st_pre) (post: (h:heap -> Tot (st_post' a (pre h)))) = STATE a (fun (p:st_post a) (h:heap) -> pre h /\ (forall a h1. post h a h1 ==> p a h1)) effect St (a:Type) = ST a (fun h -> True) (fun h0 r h1 -> True) let contains_pred (#a:Type0) (#rel:preorder a) (r:mref a rel) = fun h -> h `contains` r type mref (a:Type0) (rel:preorder a) = r:Heap.mref a rel{is_mm r = false /\ witnessed (contains_pred r)} let recall (#a:Type) (#rel:preorder a) (r:mref a rel) :STATE unit (fun p h -> Heap.contains h r ==> p () h) = gst_recall (contains_pred r) let alloc (#a:Type) (#rel:preorder a) (init:a) :ST (mref a rel) (fun h -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init) = let h0 = gst_get () in let r, h1 = alloc rel h0 init false in gst_put h1; gst_witness (contains_pred r); r let read (#a:Type) (#rel:preorder a) (r:mref a rel) :STATE a (fun p h -> p (sel h r) h) = let h0 = gst_get () in gst_recall (contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs h0 r; sel_tot h0 r let write (#a:Type) (#rel:preorder a) (r:mref a rel) (v:a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) = let h0 = gst_get () in gst_recall (contains_pred r); let h1 = upd_tot h0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs h0 r v; gst_put h1 let get (u:unit) :ST heap (fun h -> True) (fun h0 h h1 -> h0==h1 /\ h==h1) = gst_get () let op_Bang (#a:Type) (#rel:preorder a) (r:mref a rel) : STATE a (fun p h -> p (sel h r) h) = read #a #rel r let op_Colon_Equals (#a:Type) (#rel:preorder a) (r:mref a rel) (v:a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) = write #a #rel r v type ref (a:Type0) = mref a (trivial_preorder a)
false
true
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val modifies_none : h0: FStar.Monotonic.Heap.heap -> h1: FStar.Monotonic.Heap.heap -> Prims.logical
[]
FStar.ST.modifies_none
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
h0: FStar.Monotonic.Heap.heap -> h1: FStar.Monotonic.Heap.heap -> Prims.logical
{ "end_col": 58, "end_line": 132, "start_col": 40, "start_line": 132 }
FStar.Pervasives.Lemma
val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q))
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q
val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q =
false
null
true
reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[ "lemma" ]
[ "FStar.ST.heap_predicate", "Prims.l_and", "FStar.ST.stable", "FStar.ST.witnessed", "Prims.l_Forall", "FStar.Monotonic.Heap.heap", "Prims.l_imp", "FStar.Monotonic.Witnessed.lemma_witnessed_weakening", "FStar.ST.heap_rel", "Prims.unit", "FStar.Pervasives.reveal_opaque" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q))
false
false
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q))
[]
FStar.ST.lemma_functoriality
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
p: FStar.ST.heap_predicate{FStar.ST.stable p /\ FStar.ST.witnessed p} -> q: FStar.ST.heap_predicate {FStar.ST.stable q /\ (forall (h: FStar.Monotonic.Heap.heap). p h ==> q h)} -> FStar.Pervasives.Lemma (ensures FStar.ST.witnessed q)
{ "end_col": 42, "end_line": 59, "start_col": 2, "start_line": 58 }
FStar.ST.STATE
val read (#a: Type) (#rel: preorder a) (r: mref a rel) : STATE a (fun p h -> p (sel h r) h)
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let read (#a:Type) (#rel:preorder a) (r:mref a rel) :STATE a (fun p h -> p (sel h r) h) = let h0 = gst_get () in gst_recall (contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs h0 r; sel_tot h0 r
val read (#a: Type) (#rel: preorder a) (r: mref a rel) : STATE a (fun p h -> p (sel h r) h) let read (#a: Type) (#rel: preorder a) (r: mref a rel) : STATE a (fun p h -> p (sel h r) h) =
true
null
false
let h0 = gst_get () in gst_recall (contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs h0 r; sel_tot h0 r
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[]
[ "FStar.Preorder.preorder", "FStar.ST.mref", "FStar.Monotonic.Heap.sel_tot", "Prims.unit", "FStar.Monotonic.Heap.lemma_sel_equals_sel_tot_for_contained_refs", "FStar.ST.gst_recall", "FStar.ST.contains_pred", "FStar.Monotonic.Heap.heap", "FStar.ST.gst_get", "FStar.Pervasives.st_post_h", "FStar.Monotonic.Heap.sel" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q (***** ST effect *****) let st_pre = gst_pre let st_post' = gst_post' let st_post = gst_post let st_wp = gst_wp new_effect STATE = GST unfold let lift_gst_state (a:Type) (wp:gst_wp a) = wp sub_effect GST ~> STATE = lift_gst_state effect State (a:Type) (wp:st_wp a) = STATE a wp effect ST (a:Type) (pre:st_pre) (post: (h:heap -> Tot (st_post' a (pre h)))) = STATE a (fun (p:st_post a) (h:heap) -> pre h /\ (forall a h1. post h a h1 ==> p a h1)) effect St (a:Type) = ST a (fun h -> True) (fun h0 r h1 -> True) let contains_pred (#a:Type0) (#rel:preorder a) (r:mref a rel) = fun h -> h `contains` r type mref (a:Type0) (rel:preorder a) = r:Heap.mref a rel{is_mm r = false /\ witnessed (contains_pred r)} let recall (#a:Type) (#rel:preorder a) (r:mref a rel) :STATE unit (fun p h -> Heap.contains h r ==> p () h) = gst_recall (contains_pred r) let alloc (#a:Type) (#rel:preorder a) (init:a) :ST (mref a rel) (fun h -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init) = let h0 = gst_get () in let r, h1 = alloc rel h0 init false in gst_put h1; gst_witness (contains_pred r); r
false
false
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val read (#a: Type) (#rel: preorder a) (r: mref a rel) : STATE a (fun p h -> p (sel h r) h)
[]
FStar.ST.read
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.ST.mref a rel -> FStar.ST.STATE a
{ "end_col": 16, "end_line": 100, "start_col": 3, "start_line": 97 }
FStar.ST.ST
val op_Colon_Equals (#a: Type) (#rel: preorder a) (r: mref a rel) (v: a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v)
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let op_Colon_Equals (#a:Type) (#rel:preorder a) (r:mref a rel) (v:a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) = write #a #rel r v
val op_Colon_Equals (#a: Type) (#rel: preorder a) (r: mref a rel) (v: a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) let op_Colon_Equals (#a: Type) (#rel: preorder a) (r: mref a rel) (v: a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) =
true
null
false
write #a #rel r v
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[]
[ "FStar.Preorder.preorder", "FStar.ST.mref", "FStar.ST.write", "Prims.unit", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.Heap.sel", "Prims.l_and", "FStar.Monotonic.Heap.contains", "FStar.Monotonic.Heap.modifies", "FStar.Set.singleton", "Prims.nat", "FStar.Monotonic.Heap.addr_of", "FStar.Monotonic.Heap.equal_dom", "Prims.eq2" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q (***** ST effect *****) let st_pre = gst_pre let st_post' = gst_post' let st_post = gst_post let st_wp = gst_wp new_effect STATE = GST unfold let lift_gst_state (a:Type) (wp:gst_wp a) = wp sub_effect GST ~> STATE = lift_gst_state effect State (a:Type) (wp:st_wp a) = STATE a wp effect ST (a:Type) (pre:st_pre) (post: (h:heap -> Tot (st_post' a (pre h)))) = STATE a (fun (p:st_post a) (h:heap) -> pre h /\ (forall a h1. post h a h1 ==> p a h1)) effect St (a:Type) = ST a (fun h -> True) (fun h0 r h1 -> True) let contains_pred (#a:Type0) (#rel:preorder a) (r:mref a rel) = fun h -> h `contains` r type mref (a:Type0) (rel:preorder a) = r:Heap.mref a rel{is_mm r = false /\ witnessed (contains_pred r)} let recall (#a:Type) (#rel:preorder a) (r:mref a rel) :STATE unit (fun p h -> Heap.contains h r ==> p () h) = gst_recall (contains_pred r) let alloc (#a:Type) (#rel:preorder a) (init:a) :ST (mref a rel) (fun h -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init) = let h0 = gst_get () in let r, h1 = alloc rel h0 init false in gst_put h1; gst_witness (contains_pred r); r let read (#a:Type) (#rel:preorder a) (r:mref a rel) :STATE a (fun p h -> p (sel h r) h) = let h0 = gst_get () in gst_recall (contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs h0 r; sel_tot h0 r let write (#a:Type) (#rel:preorder a) (r:mref a rel) (v:a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) = let h0 = gst_get () in gst_recall (contains_pred r); let h1 = upd_tot h0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs h0 r v; gst_put h1 let get (u:unit) :ST heap (fun h -> True) (fun h0 h h1 -> h0==h1 /\ h==h1) = gst_get () let op_Bang (#a:Type) (#rel:preorder a) (r:mref a rel) : STATE a (fun p h -> p (sel h r) h) = read #a #rel r let op_Colon_Equals (#a:Type) (#rel:preorder a) (r:mref a rel) (v:a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\
false
false
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_Colon_Equals (#a: Type) (#rel: preorder a) (r: mref a rel) (v: a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v)
[]
FStar.ST.op_Colon_Equals
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.ST.mref a rel -> v: a -> FStar.ST.ST Prims.unit
{ "end_col": 19, "end_line": 128, "start_col": 2, "start_line": 128 }
FStar.ST.ST
val alloc (#a: Type) (#rel: preorder a) (init: a) : ST (mref a rel) (fun h -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init)
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let alloc (#a:Type) (#rel:preorder a) (init:a) :ST (mref a rel) (fun h -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init) = let h0 = gst_get () in let r, h1 = alloc rel h0 init false in gst_put h1; gst_witness (contains_pred r); r
val alloc (#a: Type) (#rel: preorder a) (init: a) : ST (mref a rel) (fun h -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init) let alloc (#a: Type) (#rel: preorder a) (init: a) : ST (mref a rel) (fun h -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init) =
true
null
false
let h0 = gst_get () in let r, h1 = alloc rel h0 init false in gst_put h1; gst_witness (contains_pred r); r
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[]
[ "FStar.Preorder.preorder", "FStar.Monotonic.Heap.mref", "FStar.Monotonic.Heap.heap", "FStar.ST.mref", "Prims.unit", "FStar.ST.gst_witness", "FStar.ST.contains_pred", "FStar.ST.gst_put", "FStar.Pervasives.Native.tuple2", "FStar.Monotonic.Heap.alloc", "FStar.ST.gst_get", "Prims.l_True", "Prims.l_and", "FStar.Monotonic.Heap.fresh", "FStar.Monotonic.Heap.modifies", "FStar.Set.empty", "Prims.nat", "Prims.eq2", "FStar.Monotonic.Heap.sel" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q (***** ST effect *****) let st_pre = gst_pre let st_post' = gst_post' let st_post = gst_post let st_wp = gst_wp new_effect STATE = GST unfold let lift_gst_state (a:Type) (wp:gst_wp a) = wp sub_effect GST ~> STATE = lift_gst_state effect State (a:Type) (wp:st_wp a) = STATE a wp effect ST (a:Type) (pre:st_pre) (post: (h:heap -> Tot (st_post' a (pre h)))) = STATE a (fun (p:st_post a) (h:heap) -> pre h /\ (forall a h1. post h a h1 ==> p a h1)) effect St (a:Type) = ST a (fun h -> True) (fun h0 r h1 -> True) let contains_pred (#a:Type0) (#rel:preorder a) (r:mref a rel) = fun h -> h `contains` r type mref (a:Type0) (rel:preorder a) = r:Heap.mref a rel{is_mm r = false /\ witnessed (contains_pred r)} let recall (#a:Type) (#rel:preorder a) (r:mref a rel) :STATE unit (fun p h -> Heap.contains h r ==> p () h) = gst_recall (contains_pred r) let alloc (#a:Type) (#rel:preorder a) (init:a) :ST (mref a rel) (fun h -> True)
false
false
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val alloc (#a: Type) (#rel: preorder a) (init: a) : ST (mref a rel) (fun h -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init)
[]
FStar.ST.alloc
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
init: a -> FStar.ST.ST (FStar.ST.mref a rel)
{ "end_col": 5, "end_line": 94, "start_col": 3, "start_line": 90 }
FStar.ST.ST
val write (#a: Type) (#rel: preorder a) (r: mref a rel) (v: a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v)
[ { "abbrev": true, "full_module": "FStar.Monotonic.Witnessed", "short_module": "W" }, { "abbrev": false, "full_module": "FStar.Preorder", "short_module": null }, { "abbrev": false, "full_module": "FStar.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.TSet", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let write (#a:Type) (#rel:preorder a) (r:mref a rel) (v:a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) = let h0 = gst_get () in gst_recall (contains_pred r); let h1 = upd_tot h0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs h0 r v; gst_put h1
val write (#a: Type) (#rel: preorder a) (r: mref a rel) (v: a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) let write (#a: Type) (#rel: preorder a) (r: mref a rel) (v: a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v) =
true
null
false
let h0 = gst_get () in gst_recall (contains_pred r); let h1 = upd_tot h0 r v in Heap.lemma_distinct_addrs_distinct_preorders (); Heap.lemma_distinct_addrs_distinct_mm (); Heap.lemma_upd_equals_upd_tot_for_contained_refs h0 r v; gst_put h1
{ "checked_file": "FStar.ST.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.TSet.fsti.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Witnessed.fsti.checked", "FStar.Heap.fst.checked" ], "interface_file": false, "source_file": "FStar.ST.fst" }
[]
[ "FStar.Preorder.preorder", "FStar.ST.mref", "FStar.ST.gst_put", "Prims.unit", "FStar.Monotonic.Heap.lemma_upd_equals_upd_tot_for_contained_refs", "FStar.Monotonic.Heap.lemma_distinct_addrs_distinct_mm", "FStar.Monotonic.Heap.lemma_distinct_addrs_distinct_preorders", "FStar.Monotonic.Heap.heap", "FStar.Monotonic.Heap.upd_tot", "FStar.ST.gst_recall", "FStar.ST.contains_pred", "FStar.ST.gst_get", "FStar.Monotonic.Heap.sel", "Prims.l_and", "FStar.Monotonic.Heap.contains", "FStar.Monotonic.Heap.modifies", "FStar.Set.singleton", "Prims.nat", "FStar.Monotonic.Heap.addr_of", "FStar.Monotonic.Heap.equal_dom", "Prims.eq2" ]
[]
(* Copyright 2008-2014 Nikhil Swamy, Aseem Rastogi, and Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.ST open FStar.TSet open FStar.Heap open FStar.Preorder module W = FStar.Monotonic.Witnessed (***** Global ST (GST) effect with put, get, witness, and recall *****) new_effect GST = STATE_h heap let gst_pre = st_pre_h heap let gst_post' (a:Type) (pre:Type) = st_post_h' heap a pre let gst_post (a:Type) = st_post_h heap a let gst_wp (a:Type) = st_wp_h heap a unfold let lift_div_gst (a:Type) (wp:pure_wp a) (p:gst_post a) (h:heap) = wp (fun a -> p a h) sub_effect DIV ~> GST = lift_div_gst let heap_rel (h1:heap) (h2:heap) = forall (a:Type0) (rel:preorder a) (r:mref a rel). h1 `contains` r ==> (h2 `contains` r /\ rel (sel h1 r) (sel h2 r)) assume val gst_get: unit -> GST heap (fun p h0 -> p h0 h0) assume val gst_put: h1:heap -> GST unit (fun p h0 -> heap_rel h0 h1 /\ p () h1) type heap_predicate = heap -> Type0 let stable (p:heap_predicate) = forall (h1:heap) (h2:heap). (p h1 /\ heap_rel h1 h2) ==> p h2 [@@"opaque_to_smt"] let witnessed (p:heap_predicate{stable p}) : Type0 = W.witnessed heap_rel p assume val gst_witness: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ p h0 /\ (witnessed p ==> post () h0)) assume val gst_recall: p:heap_predicate -> GST unit (fun post h0 -> stable p /\ witnessed p /\ (p h0 ==> post () h0)) val lemma_functoriality (p:heap_predicate{stable p /\ witnessed p}) (q:heap_predicate{stable q /\ (forall (h:heap). p h ==> q h)}) :Lemma (ensures (witnessed q)) let lemma_functoriality p q = reveal_opaque (`%witnessed) witnessed; W.lemma_witnessed_weakening heap_rel p q (***** ST effect *****) let st_pre = gst_pre let st_post' = gst_post' let st_post = gst_post let st_wp = gst_wp new_effect STATE = GST unfold let lift_gst_state (a:Type) (wp:gst_wp a) = wp sub_effect GST ~> STATE = lift_gst_state effect State (a:Type) (wp:st_wp a) = STATE a wp effect ST (a:Type) (pre:st_pre) (post: (h:heap -> Tot (st_post' a (pre h)))) = STATE a (fun (p:st_post a) (h:heap) -> pre h /\ (forall a h1. post h a h1 ==> p a h1)) effect St (a:Type) = ST a (fun h -> True) (fun h0 r h1 -> True) let contains_pred (#a:Type0) (#rel:preorder a) (r:mref a rel) = fun h -> h `contains` r type mref (a:Type0) (rel:preorder a) = r:Heap.mref a rel{is_mm r = false /\ witnessed (contains_pred r)} let recall (#a:Type) (#rel:preorder a) (r:mref a rel) :STATE unit (fun p h -> Heap.contains h r ==> p () h) = gst_recall (contains_pred r) let alloc (#a:Type) (#rel:preorder a) (init:a) :ST (mref a rel) (fun h -> True) (fun h0 r h1 -> fresh r h0 h1 /\ modifies Set.empty h0 h1 /\ sel h1 r == init) = let h0 = gst_get () in let r, h1 = alloc rel h0 init false in gst_put h1; gst_witness (contains_pred r); r let read (#a:Type) (#rel:preorder a) (r:mref a rel) :STATE a (fun p h -> p (sel h r) h) = let h0 = gst_get () in gst_recall (contains_pred r); Heap.lemma_sel_equals_sel_tot_for_contained_refs h0 r; sel_tot h0 r let write (#a:Type) (#rel:preorder a) (r:mref a rel) (v:a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\
false
false
FStar.ST.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val write (#a: Type) (#rel: preorder a) (r: mref a rel) (v: a) : ST unit (fun h -> rel (sel h r) v) (fun h0 x h1 -> rel (sel h0 r) v /\ h0 `contains` r /\ modifies (Set.singleton (addr_of r)) h0 h1 /\ equal_dom h0 h1 /\ sel h1 r == v)
[]
FStar.ST.write
{ "file_name": "ulib/FStar.ST.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
r: FStar.ST.mref a rel -> v: a -> FStar.ST.ST Prims.unit
{ "end_col": 14, "end_line": 114, "start_col": 3, "start_line": 108 }
Prims.Tot
val counter_mode: a:cipher_alg -> k:key a -> n:nonce a -> plain:bytes { length plain <= max_size_t } -> Tot (cipher:bytes { length cipher = length plain })
[ { "abbrev": false, "full_module": "Spec.Agile.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Cipher", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let counter_mode a k n plain = let stream = ctr_stream a k n (length plain) in map2 ( ^. ) (plain <: lbytes (length plain)) (stream <: lbytes (length plain))
val counter_mode: a:cipher_alg -> k:key a -> n:nonce a -> plain:bytes { length plain <= max_size_t } -> Tot (cipher:bytes { length cipher = length plain }) let counter_mode a k n plain =
false
null
false
let stream = ctr_stream a k n (length plain) in map2 ( ^. ) (plain <: lbytes (length plain)) (stream <: lbytes (length plain))
{ "checked_file": "Spec.Agile.CTR.fst.checked", "dependencies": [ "Spec.Agile.Cipher.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.CTR.fst" }
[ "total" ]
[ "Spec.Agile.Cipher.cipher_alg", "Spec.Agile.Cipher.key", "Spec.Agile.Cipher.nonce", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.max_size_t", "Lib.Sequence.map2", "Lib.IntTypes.op_Hat_Dot", "Lib.ByteSequence.lbytes", "Lib.Sequence.seq", "Lib.IntTypes.int_t", "Prims.op_Equality", "Prims.nat", "Spec.Agile.Cipher.ctr_stream" ]
[]
module Spec.Agile.CTR open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Agile.Cipher #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1" // So that clients don't need to open both modules include Spec.Agile.Cipher val counter_mode: a:cipher_alg -> k:key a -> n:nonce a -> plain:bytes { length plain <= max_size_t } ->
false
false
Spec.Agile.CTR.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val counter_mode: a:cipher_alg -> k:key a -> n:nonce a -> plain:bytes { length plain <= max_size_t } -> Tot (cipher:bytes { length cipher = length plain })
[]
Spec.Agile.CTR.counter_mode
{ "file_name": "specs/Spec.Agile.CTR.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.Cipher.cipher_alg -> k: Spec.Agile.Cipher.key a -> n: Spec.Agile.Cipher.nonce a -> plain: Lib.ByteSequence.bytes{Lib.Sequence.length plain <= Lib.IntTypes.max_size_t} -> cipher: Lib.ByteSequence.bytes{Lib.Sequence.length cipher = Lib.Sequence.length plain}
{ "end_col": 80, "end_line": 22, "start_col": 30, "start_line": 20 }
Prims.Tot
val shift_right64 (x amt: nat64) : nat64
[ { "abbrev": false, "full_module": "Vale.Poly1305.Spec_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let shift_right64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishr x amt
val shift_right64 (x amt: nat64) : nat64 let shift_right64 (x amt: nat64) : nat64 =
false
null
false
Vale.Def.Types_s.ishr x amt
{ "checked_file": "Vale.Poly1305.Math.fsti.checked", "dependencies": [ "Vale.Poly1305.Spec_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Poly1305.Math.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat64", "Vale.Def.Types_s.ishr", "Vale.Def.Words_s.pow2_64" ]
[]
module Vale.Poly1305.Math open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Poly1305.Spec_s unfold let logand64 (x:nat64) (y:nat64) : nat64 = Vale.Def.Types_s.iand x y unfold let logand128 (x:nat128) (y:nat128) : nat128 = Vale.Def.Types_s.iand x y
false
true
Vale.Poly1305.Math.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val shift_right64 (x amt: nat64) : nat64
[]
Vale.Poly1305.Math.shift_right64
{ "file_name": "vale/code/crypto/poly1305/x64/Vale.Poly1305.Math.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Vale.Def.Types_s.nat64 -> amt: Vale.Def.Types_s.nat64 -> Vale.Def.Types_s.nat64
{ "end_col": 84, "end_line": 12, "start_col": 57, "start_line": 12 }
Prims.Tot
val lowerUpper192_def (l: nat128) (u: nat64) : int
[ { "abbrev": false, "full_module": "Vale.Poly1305.Spec_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lowerUpper192_def (l:nat128) (u:nat64) : int = 0x100000000000000000000000000000000 * u + l
val lowerUpper192_def (l: nat128) (u: nat64) : int let lowerUpper192_def (l: nat128) (u: nat64) : int =
false
null
false
0x100000000000000000000000000000000 * u + l
{ "checked_file": "Vale.Poly1305.Math.fsti.checked", "dependencies": [ "Vale.Poly1305.Spec_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Poly1305.Math.fsti" }
[ "total" ]
[ "Vale.Def.Words_s.nat128", "Vale.Def.Types_s.nat64", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.int" ]
[]
module Vale.Poly1305.Math open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Poly1305.Spec_s unfold let logand64 (x:nat64) (y:nat64) : nat64 = Vale.Def.Types_s.iand x y unfold let logand128 (x:nat128) (y:nat128) : nat128 = Vale.Def.Types_s.iand x y unfold let shift_left64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishl x amt unfold let shift_right64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishr x amt let lowerUpper128_def (l:nat64) (u:nat64) : nat128 = 0x10000000000000000 * u + l [@"opaque_to_smt"] let lowerUpper128 = opaque_make lowerUpper128_def irreducible let lowerUpper128_reveal = opaque_revealer (`%lowerUpper128) lowerUpper128 lowerUpper128_def
false
true
Vale.Poly1305.Math.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lowerUpper192_def (l: nat128) (u: nat64) : int
[]
Vale.Poly1305.Math.lowerUpper192_def
{ "file_name": "vale/code/crypto/poly1305/x64/Vale.Poly1305.Math.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Vale.Def.Words_s.nat128 -> u16: Vale.Def.Types_s.nat64 -> Prims.int
{ "end_col": 45, "end_line": 20, "start_col": 2, "start_line": 20 }
FStar.Pervasives.Lemma
[ { "abbrev": false, "full_module": "Vale.Poly1305.Spec_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lowerUpper192_reveal = opaque_revealer (`%lowerUpper192) lowerUpper192 lowerUpper192_def
let lowerUpper192_reveal =
false
null
true
opaque_revealer (`%lowerUpper192) lowerUpper192 lowerUpper192_def
{ "checked_file": "Vale.Poly1305.Math.fsti.checked", "dependencies": [ "Vale.Poly1305.Spec_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Poly1305.Math.fsti" }
[ "lemma" ]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.Def.Words_s.nat128", "Vale.Def.Types_s.nat64", "Prims.int", "Vale.Poly1305.Math.lowerUpper192", "Vale.Poly1305.Math.lowerUpper192_def" ]
[]
module Vale.Poly1305.Math open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Poly1305.Spec_s unfold let logand64 (x:nat64) (y:nat64) : nat64 = Vale.Def.Types_s.iand x y unfold let logand128 (x:nat128) (y:nat128) : nat128 = Vale.Def.Types_s.iand x y unfold let shift_left64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishl x amt unfold let shift_right64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishr x amt let lowerUpper128_def (l:nat64) (u:nat64) : nat128 = 0x10000000000000000 * u + l [@"opaque_to_smt"] let lowerUpper128 = opaque_make lowerUpper128_def irreducible let lowerUpper128_reveal = opaque_revealer (`%lowerUpper128) lowerUpper128 lowerUpper128_def let lowerUpper192_def (l:nat128) (u:nat64) : int = 0x100000000000000000000000000000000 * u + l
false
false
Vale.Poly1305.Math.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lowerUpper192_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.Poly1305.Math.lowerUpper192 == Vale.Poly1305.Math.lowerUpper192_def)
[]
Vale.Poly1305.Math.lowerUpper192_reveal
{ "file_name": "vale/code/crypto/poly1305/x64/Vale.Poly1305.Math.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.Poly1305.Math.lowerUpper192 == Vale.Poly1305.Math.lowerUpper192_def)
{ "end_col": 104, "end_line": 22, "start_col": 39, "start_line": 22 }
FStar.Pervasives.Lemma
[ { "abbrev": false, "full_module": "Vale.Poly1305.Spec_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lowerUpper128_reveal = opaque_revealer (`%lowerUpper128) lowerUpper128 lowerUpper128_def
let lowerUpper128_reveal =
false
null
true
opaque_revealer (`%lowerUpper128) lowerUpper128 lowerUpper128_def
{ "checked_file": "Vale.Poly1305.Math.fsti.checked", "dependencies": [ "Vale.Poly1305.Spec_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Poly1305.Math.fsti" }
[ "lemma" ]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.Def.Types_s.nat64", "Vale.Def.Words_s.nat128", "Vale.Poly1305.Math.lowerUpper128", "Vale.Poly1305.Math.lowerUpper128_def" ]
[]
module Vale.Poly1305.Math open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Poly1305.Spec_s unfold let logand64 (x:nat64) (y:nat64) : nat64 = Vale.Def.Types_s.iand x y unfold let logand128 (x:nat128) (y:nat128) : nat128 = Vale.Def.Types_s.iand x y unfold let shift_left64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishl x amt unfold let shift_right64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishr x amt let lowerUpper128_def (l:nat64) (u:nat64) : nat128 = 0x10000000000000000 * u + l
false
false
Vale.Poly1305.Math.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lowerUpper128_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.Poly1305.Math.lowerUpper128 == Vale.Poly1305.Math.lowerUpper128_def)
[]
Vale.Poly1305.Math.lowerUpper128_reveal
{ "file_name": "vale/code/crypto/poly1305/x64/Vale.Poly1305.Math.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.Poly1305.Math.lowerUpper128 == Vale.Poly1305.Math.lowerUpper128_def)
{ "end_col": 104, "end_line": 17, "start_col": 39, "start_line": 17 }
Prims.Tot
val logand128 (x y: nat128) : nat128
[ { "abbrev": false, "full_module": "Vale.Poly1305.Spec_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let logand128 (x:nat128) (y:nat128) : nat128 = Vale.Def.Types_s.iand x y
val logand128 (x y: nat128) : nat128 let logand128 (x y: nat128) : nat128 =
false
null
false
Vale.Def.Types_s.iand x y
{ "checked_file": "Vale.Poly1305.Math.fsti.checked", "dependencies": [ "Vale.Poly1305.Spec_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Poly1305.Math.fsti" }
[ "total" ]
[ "Vale.Def.Words_s.nat128", "Vale.Def.Types_s.iand", "Vale.Def.Words_s.pow2_128" ]
[]
module Vale.Poly1305.Math open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Poly1305.Spec_s
false
true
Vale.Poly1305.Math.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val logand128 (x y: nat128) : nat128
[]
Vale.Poly1305.Math.logand128
{ "file_name": "vale/code/crypto/poly1305/x64/Vale.Poly1305.Math.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Vale.Def.Words_s.nat128 -> y: Vale.Def.Words_s.nat128 -> Vale.Def.Words_s.nat128
{ "end_col": 79, "end_line": 10, "start_col": 54, "start_line": 10 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Poly1305.Spec_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lowerUpper192 = opaque_make lowerUpper192_def
let lowerUpper192 =
false
null
false
opaque_make lowerUpper192_def
{ "checked_file": "Vale.Poly1305.Math.fsti.checked", "dependencies": [ "Vale.Poly1305.Spec_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Poly1305.Math.fsti" }
[ "total" ]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.Def.Words_s.nat128", "Vale.Def.Types_s.nat64", "Prims.int", "Vale.Poly1305.Math.lowerUpper192_def" ]
[]
module Vale.Poly1305.Math open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Poly1305.Spec_s unfold let logand64 (x:nat64) (y:nat64) : nat64 = Vale.Def.Types_s.iand x y unfold let logand128 (x:nat128) (y:nat128) : nat128 = Vale.Def.Types_s.iand x y unfold let shift_left64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishl x amt unfold let shift_right64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishr x amt let lowerUpper128_def (l:nat64) (u:nat64) : nat128 = 0x10000000000000000 * u + l [@"opaque_to_smt"] let lowerUpper128 = opaque_make lowerUpper128_def irreducible let lowerUpper128_reveal = opaque_revealer (`%lowerUpper128) lowerUpper128 lowerUpper128_def let lowerUpper192_def (l:nat128) (u:nat64) : int =
false
true
Vale.Poly1305.Math.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lowerUpper192 : _: Vale.Def.Words_s.nat128 -> _: Vale.Def.Types_s.nat64 -> Prims.int
[]
Vale.Poly1305.Math.lowerUpper192
{ "file_name": "vale/code/crypto/poly1305/x64/Vale.Poly1305.Math.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Vale.Def.Words_s.nat128 -> _: Vale.Def.Types_s.nat64 -> Prims.int
{ "end_col": 68, "end_line": 21, "start_col": 39, "start_line": 21 }
Prims.Tot
val logand64 (x y: nat64) : nat64
[ { "abbrev": false, "full_module": "Vale.Poly1305.Spec_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let logand64 (x:nat64) (y:nat64) : nat64 = Vale.Def.Types_s.iand x y
val logand64 (x y: nat64) : nat64 let logand64 (x y: nat64) : nat64 =
false
null
false
Vale.Def.Types_s.iand x y
{ "checked_file": "Vale.Poly1305.Math.fsti.checked", "dependencies": [ "Vale.Poly1305.Spec_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Poly1305.Math.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat64", "Vale.Def.Types_s.iand", "Vale.Def.Words_s.pow2_64" ]
[]
module Vale.Poly1305.Math open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Poly1305.Spec_s
false
true
Vale.Poly1305.Math.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val logand64 (x y: nat64) : nat64
[]
Vale.Poly1305.Math.logand64
{ "file_name": "vale/code/crypto/poly1305/x64/Vale.Poly1305.Math.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Vale.Def.Types_s.nat64 -> y: Vale.Def.Types_s.nat64 -> Vale.Def.Types_s.nat64
{ "end_col": 75, "end_line": 9, "start_col": 50, "start_line": 9 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Poly1305.Spec_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lowerUpper128 = opaque_make lowerUpper128_def
let lowerUpper128 =
false
null
false
opaque_make lowerUpper128_def
{ "checked_file": "Vale.Poly1305.Math.fsti.checked", "dependencies": [ "Vale.Poly1305.Spec_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Poly1305.Math.fsti" }
[ "total" ]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.Def.Types_s.nat64", "Vale.Def.Words_s.nat128", "Vale.Poly1305.Math.lowerUpper128_def" ]
[]
module Vale.Poly1305.Math open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Poly1305.Spec_s unfold let logand64 (x:nat64) (y:nat64) : nat64 = Vale.Def.Types_s.iand x y unfold let logand128 (x:nat128) (y:nat128) : nat128 = Vale.Def.Types_s.iand x y unfold let shift_left64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishl x amt unfold let shift_right64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishr x amt let lowerUpper128_def (l:nat64) (u:nat64) : nat128 =
false
true
Vale.Poly1305.Math.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lowerUpper128 : _: Vale.Def.Types_s.nat64 -> _: Vale.Def.Types_s.nat64 -> Vale.Def.Words_s.nat128
[]
Vale.Poly1305.Math.lowerUpper128
{ "file_name": "vale/code/crypto/poly1305/x64/Vale.Poly1305.Math.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Vale.Def.Types_s.nat64 -> _: Vale.Def.Types_s.nat64 -> Vale.Def.Words_s.nat128
{ "end_col": 68, "end_line": 16, "start_col": 39, "start_line": 16 }
Prims.Tot
val bare_r (key_r: nat128) : nat128
[ { "abbrev": false, "full_module": "FStar.Tactics.BV", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Bitvectors", "short_module": null }, { "abbrev": false, "full_module": "FStar.Classical", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.TypesNative_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Lemmas.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.Canon", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Spec_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bare_r (key_r:nat128) : nat128 = iand key_r 0x0ffffffc0ffffffc0ffffffc0fffffff
val bare_r (key_r: nat128) : nat128 let bare_r (key_r: nat128) : nat128 =
false
null
false
iand key_r 0x0ffffffc0ffffffc0ffffffc0fffffff
{ "checked_file": "Vale.Poly1305.Math.fsti.checked", "dependencies": [ "Vale.Poly1305.Spec_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Poly1305.Math.fsti" }
[ "total" ]
[ "Vale.Def.Words_s.nat128", "Vale.Def.Types_s.iand", "Vale.Def.Words_s.pow2_128" ]
[]
module Vale.Poly1305.Math open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Poly1305.Spec_s unfold let logand64 (x:nat64) (y:nat64) : nat64 = Vale.Def.Types_s.iand x y unfold let logand128 (x:nat128) (y:nat128) : nat128 = Vale.Def.Types_s.iand x y unfold let shift_left64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishl x amt unfold let shift_right64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishr x amt let lowerUpper128_def (l:nat64) (u:nat64) : nat128 = 0x10000000000000000 * u + l [@"opaque_to_smt"] let lowerUpper128 = opaque_make lowerUpper128_def irreducible let lowerUpper128_reveal = opaque_revealer (`%lowerUpper128) lowerUpper128 lowerUpper128_def let lowerUpper192_def (l:nat128) (u:nat64) : int = 0x100000000000000000000000000000000 * u + l [@"opaque_to_smt"] let lowerUpper192 = opaque_make lowerUpper192_def irreducible let lowerUpper192_reveal = opaque_revealer (`%lowerUpper192) lowerUpper192 lowerUpper192_def // There are some assumptions here, which will either go away when the library switches to ints everywhere (for division too) // or when we switch to nats (which is doable right away) val lemma_poly_multiply (n:int) (p:int) (r:int) (h:int) (r0:int) (r1:int) (h0:int) (h1:int) (h2:int) (s1:int) (d0:int) (d1:int) (d2:int) (hh:int) : Lemma (requires p > 0 /\ r1 >= 0 /\ n > 0 /\ 4 * (n * n) == p + 5 /\ r == r1 * n + r0 /\ h == h2 * (n * n) + h1 * n + h0 /\ s1 == r1 + (r1 / 4) /\ r1 % 4 == 0 /\ d0 == h0 * r0 + h1 * s1 /\ d1 == h0 * r1 + h1 * r0 + h2 * s1 /\ d2 == h2 * r0 /\ hh == d2 * (n * n) + d1 * n + d0) (ensures (h * r) % p == hh % p) // p used to be a refinement to p > 0 and h a nat. val lemma_poly_reduce (n:int) (p:int) (h:int) (h2:int) (h10:int) (c:int) (hh:int) : Lemma (requires p > 0 /\ n * n > 0 /\ h >= 0 /\ h2 >= 0 /\ // TODO: Shouldn't need to add this 4 * (n * n) == p + 5 /\ h2 == h / (n * n) /\ h10 == h % (n * n) /\ c == (h2 / 4) + (h2 / 4) * 4 /\ hh == h10 + c + (h2 % 4) * (n * n)) (ensures h % p == hh % p) val lemma_poly_bits64 (u:unit) : Lemma (requires True) (ensures (forall (x:nat64).{:pattern (shift_right64 x 2)} shift_right64 x 2 == x / 4) /\ (forall (x:nat64).{:pattern (shift_right64 x 4)} shift_right64 x 4 == x / 16) /\ (forall (x:nat64).{:pattern (logand64 x 3)} logand64 x 3 == x % 4) /\ (forall (x:nat64).{:pattern (logand64 x 15)} logand64 x 15 == x % 16) /\ (forall (x:nat64).{:pattern (logand64 x 0)} logand64 x 0 == 0) /\ (forall (x:nat64).{:pattern (logand64 x 0xffffffffffffffff)} logand64 x 0xffffffffffffffff == x) /\ (forall (x:nat64).{:pattern (logand64 x 0xfffffffffffffffc)} logand64 x 0xfffffffffffffffc == (x / 4) * 4) /\ (forall (x:nat64).{:pattern (logand64 x 0x0ffffffc0fffffff)} logand64 x 0x0ffffffc0fffffff < pow2_64 / 16) /\ (forall (x:nat64).{:pattern (logand64 x 0x0ffffffc0ffffffc)} logand64 x 0x0ffffffc0ffffffc < pow2_64 / 16) /\ (forall (x:nat64).{:pattern (logand64 x 0x0ffffffc0ffffffc)} (logand64 x 0x0ffffffc0ffffffc) % 4 == 0) /\ (forall (x:nat64) (y:nat64).{:pattern (logand64 x y)} logand64 x y == logand64 y x)) val lemma_mul_strict_upper_bound (x:int) (x_bound:int) (y:int) (y_bound:int) : Lemma (requires 0 <= x /\ x < x_bound /\ 0 <= y /\ y < y_bound) (ensures x * y < x_bound * y_bound) val lemma_bytes_shift_power2 (y:nat64) : Lemma (requires y < 8) (ensures shift_left64 y 3 < 64 /\ shift_left64 y 3 == y * 8 /\ pow2 (shift_left64 y 3) == shift_left64 1 (shift_left64 y 3)) val lemma_bytes_and_mod (x:nat64) (y:nat64) : Lemma (requires y < 8) (ensures shift_left64 y 3 < 64 /\ (let z = shift_left64 1 (shift_left64 y 3) in z <> 0 /\ logand64 x (z-1) == x % z)) val lemma_mod_power2_lo (x0:nat64) (x1:nat64) (y:int) (z:int) : Lemma (requires 0 <= y /\ y < 8 /\ z == pow2 (y * 8)) (ensures z > 0 /\ 0 <= x0 % z /\ x0 % z < 0x10000000000000000 /\ (lowerUpper128 x0 x1) % z == (lowerUpper128 (x0 % z) 0)) val lemma_power2_add64 (n:nat) : Lemma (requires True) (ensures pow2(64 + n) == 0x10000000000000000 * pow2(n)) val lemma_mod_hi (x0:nat64) (x1:nat64) (z:nat64) : Lemma (requires z <> 0) (ensures z <> 0 /\ lowerUpper128 0 z <> 0 /\ (lowerUpper128 x0 x1) % (lowerUpper128 0 z) == lowerUpper128 x0 (x1 % z)) val lemma_poly_demod (p:pos) (h:int) (x:int) (r:int) : Lemma (((h % p + x) * r) % p == ((h + x) * r) % p) val lemma_reduce128 (h:int) (h2:nat64) (h1:nat64) (h0:nat64) (g:int) (g2:nat64) (g1:nat64) (g0:nat64) : Lemma (requires h2 < 5 /\ g == h + 5 /\ h == lowerUpper192 (lowerUpper128 h0 h1) h2 /\ g == lowerUpper192 (lowerUpper128 g0 g1) g2) (ensures (g2 < 4 ==> lowerUpper128 h0 h1 == mod2_128 (modp h)) /\ (g2 >= 4 ==> lowerUpper128 g0 g1 == mod2_128 (modp h))) val lemma_add_key (old_h0:nat64) (old_h1:nat64) (h_in:int) (key_s0:nat64) (key_s1:nat64) (key_s:int) (h0:nat64) (h1:nat64) : Lemma (requires ( let c = old_h0 + key_s0 >= pow2_64 in h_in == lowerUpper128 old_h0 old_h1 /\ key_s == lowerUpper128 key_s0 key_s1 /\ h0 == add_wrap old_h0 key_s0 /\ h1 == add_wrap (add_wrap old_h1 key_s1) (if c then 1 else 0))) (ensures lowerUpper128 h0 h1 == mod2_128 (h_in + key_s)) val lemma_lowerUpper128_and (x:nat128) (x0:nat64) (x1:nat64) (y:nat128) (y0:nat64) (y1:nat64) (z:nat128) (z0:nat64) (z1:nat64) : Lemma (requires z0 == logand64 x0 y0 /\ z1 == logand64 x1 y1 /\ x == lowerUpper128 x0 x1 /\ y == lowerUpper128 y0 y1 /\ z == lowerUpper128 z0 z1) (ensures z == logand128 x y) val lemma_add_mod128 (x y :int) : Lemma (requires True) (ensures mod2_128 ((mod2_128 x) + y) == mod2_128 (x + y))
false
true
Vale.Poly1305.Math.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bare_r (key_r: nat128) : nat128
[]
Vale.Poly1305.Math.bare_r
{ "file_name": "vale/code/crypto/poly1305/x64/Vale.Poly1305.Math.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
key_r: Vale.Def.Words_s.nat128 -> Vale.Def.Words_s.nat128
{ "end_col": 82, "end_line": 154, "start_col": 37, "start_line": 154 }
Prims.Tot
val shift_left64 (x amt: nat64) : nat64
[ { "abbrev": false, "full_module": "Vale.Poly1305.Spec_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let shift_left64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishl x amt
val shift_left64 (x amt: nat64) : nat64 let shift_left64 (x amt: nat64) : nat64 =
false
null
false
Vale.Def.Types_s.ishl x amt
{ "checked_file": "Vale.Poly1305.Math.fsti.checked", "dependencies": [ "Vale.Poly1305.Spec_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Poly1305.Math.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat64", "Vale.Def.Types_s.ishl", "Vale.Def.Words_s.pow2_64" ]
[]
module Vale.Poly1305.Math open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Poly1305.Spec_s unfold let logand64 (x:nat64) (y:nat64) : nat64 = Vale.Def.Types_s.iand x y
false
true
Vale.Poly1305.Math.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val shift_left64 (x amt: nat64) : nat64
[]
Vale.Poly1305.Math.shift_left64
{ "file_name": "vale/code/crypto/poly1305/x64/Vale.Poly1305.Math.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Vale.Def.Types_s.nat64 -> amt: Vale.Def.Types_s.nat64 -> Vale.Def.Types_s.nat64
{ "end_col": 83, "end_line": 11, "start_col": 56, "start_line": 11 }
Prims.Tot
val lowerUpper128_def (l u: nat64) : nat128
[ { "abbrev": false, "full_module": "Vale.Poly1305.Spec_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lowerUpper128_def (l:nat64) (u:nat64) : nat128 = 0x10000000000000000 * u + l
val lowerUpper128_def (l u: nat64) : nat128 let lowerUpper128_def (l u: nat64) : nat128 =
false
null
false
0x10000000000000000 * u + l
{ "checked_file": "Vale.Poly1305.Math.fsti.checked", "dependencies": [ "Vale.Poly1305.Spec_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.Poly1305.Math.fsti" }
[ "total" ]
[ "Vale.Def.Types_s.nat64", "Prims.op_Addition", "FStar.Mul.op_Star", "Vale.Def.Words_s.nat128" ]
[]
module Vale.Poly1305.Math open FStar.Mul open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Poly1305.Spec_s unfold let logand64 (x:nat64) (y:nat64) : nat64 = Vale.Def.Types_s.iand x y unfold let logand128 (x:nat128) (y:nat128) : nat128 = Vale.Def.Types_s.iand x y unfold let shift_left64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishl x amt unfold let shift_right64 (x:nat64) (amt:nat64) : nat64 = Vale.Def.Types_s.ishr x amt
false
true
Vale.Poly1305.Math.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lowerUpper128_def (l u: nat64) : nat128
[]
Vale.Poly1305.Math.lowerUpper128_def
{ "file_name": "vale/code/crypto/poly1305/x64/Vale.Poly1305.Math.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Vale.Def.Types_s.nat64 -> u11: Vale.Def.Types_s.nat64 -> Vale.Def.Words_s.nat128
{ "end_col": 29, "end_line": 15, "start_col": 2, "start_line": 15 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "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": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let poly1305_init_st (s:field_spec) = ctx:poly1305_ctx s -> key:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h ctx /\ live h key /\ disjoint ctx key) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ (as_get_acc h1 ctx, as_get_r h1 ctx) == S.poly1305_init (as_seq h0 key))
let poly1305_init_st (s: field_spec) =
false
null
false
ctx: poly1305_ctx s -> key: lbuffer uint8 32ul -> Stack unit (requires fun h -> live h ctx /\ live h key /\ disjoint ctx key) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ (as_get_acc h1 ctx, as_get_r h1 ctx) == S.poly1305_init (as_seq h0 key))
{ "checked_file": "Hacl.Impl.Poly1305.fsti.checked", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Poly1305.fsti" }
[ "total" ]
[ "Hacl.Impl.Poly1305.Fields.field_spec", "Hacl.Impl.Poly1305.poly1305_ctx", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Impl.Poly1305.Fields.limb", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Hacl.Impl.Poly1305.state_inv_t", "Prims.eq2", "FStar.Pervasives.Native.tuple2", "Spec.Poly1305.felem", "FStar.Pervasives.Native.Mktuple2", "Hacl.Impl.Poly1305.as_get_acc", "Hacl.Impl.Poly1305.as_get_r", "Spec.Poly1305.poly1305_init", "Lib.Buffer.as_seq" ]
[]
module Hacl.Impl.Poly1305 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Poly1305.Fields module S = Spec.Poly1305 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 1" inline_for_extraction noextract let poly1305_ctx (s:field_spec) = lbuffer (limb s) (nlimb s +! precomplen s) noextract val as_get_acc: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> GTot S.felem noextract val as_get_r: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> GTot S.felem noextract val state_inv_t: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> Type0 // If the ctx is not modified, all the components and invariants are preserved val reveal_ctx_inv': #s:field_spec -> ctx:poly1305_ctx s -> ctx':poly1305_ctx s -> h0:mem -> h1:mem -> Lemma (requires Seq.equal (as_seq h0 ctx) (as_seq h1 ctx') /\ state_inv_t h0 ctx) (ensures as_get_r h0 ctx == as_get_r h1 ctx' /\ as_get_acc h0 ctx == as_get_acc h1 ctx' /\ state_inv_t h1 ctx') let reveal_ctx_inv #s ctx h0 h1: Lemma (requires Seq.equal (as_seq h0 ctx) (as_seq h1 ctx) /\ state_inv_t h0 ctx) (ensures as_get_r h0 ctx == as_get_r h1 ctx /\ as_get_acc h0 ctx == as_get_acc h1 ctx /\ state_inv_t h1 ctx) = reveal_ctx_inv' #s ctx ctx h0 h1 val ctx_inv_zeros: #s:field_spec -> ctx:poly1305_ctx s -> h:mem -> Lemma (requires as_seq h ctx == Lib.Sequence.create (v (nlimb s +! precomplen s)) (limb_zero s)) (ensures state_inv_t #s h ctx) inline_for_extraction noextract
false
true
Hacl.Impl.Poly1305.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val poly1305_init_st : s: Hacl.Impl.Poly1305.Fields.field_spec -> Type0
[]
Hacl.Impl.Poly1305.poly1305_init_st
{ "file_name": "code/poly1305/Hacl.Impl.Poly1305.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Hacl.Impl.Poly1305.Fields.field_spec -> Type0
{ "end_col": 76, "end_line": 65, "start_col": 4, "start_line": 57 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "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": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let poly1305_update_st (s:field_spec) = ctx:poly1305_ctx s -> len:size_t -> text:lbuffer uint8 len -> Stack unit (requires fun h -> live h text /\ live h ctx /\ disjoint ctx text /\ state_inv_t #s h ctx) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ as_get_r h0 ctx == as_get_r h1 ctx /\ as_get_acc h1 ctx == S.poly1305_update (as_seq h0 text) (as_get_acc h0 ctx) (as_get_r h0 ctx))
let poly1305_update_st (s: field_spec) =
false
null
false
ctx: poly1305_ctx s -> len: size_t -> text: lbuffer uint8 len -> Stack unit (requires fun h -> live h text /\ live h ctx /\ disjoint ctx text /\ state_inv_t #s h ctx) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ as_get_r h0 ctx == as_get_r h1 ctx /\ as_get_acc h1 ctx == S.poly1305_update (as_seq h0 text) (as_get_acc h0 ctx) (as_get_r h0 ctx))
{ "checked_file": "Hacl.Impl.Poly1305.fsti.checked", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Poly1305.fsti" }
[ "total" ]
[ "Hacl.Impl.Poly1305.Fields.field_spec", "Hacl.Impl.Poly1305.poly1305_ctx", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Impl.Poly1305.Fields.limb", "Lib.Buffer.disjoint", "Hacl.Impl.Poly1305.state_inv_t", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Spec.Poly1305.felem", "Hacl.Impl.Poly1305.as_get_r", "Hacl.Impl.Poly1305.as_get_acc", "Spec.Poly1305.poly1305_update", "Lib.Buffer.as_seq" ]
[]
module Hacl.Impl.Poly1305 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Poly1305.Fields module S = Spec.Poly1305 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 1" inline_for_extraction noextract let poly1305_ctx (s:field_spec) = lbuffer (limb s) (nlimb s +! precomplen s) noextract val as_get_acc: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> GTot S.felem noextract val as_get_r: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> GTot S.felem noextract val state_inv_t: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> Type0 // If the ctx is not modified, all the components and invariants are preserved val reveal_ctx_inv': #s:field_spec -> ctx:poly1305_ctx s -> ctx':poly1305_ctx s -> h0:mem -> h1:mem -> Lemma (requires Seq.equal (as_seq h0 ctx) (as_seq h1 ctx') /\ state_inv_t h0 ctx) (ensures as_get_r h0 ctx == as_get_r h1 ctx' /\ as_get_acc h0 ctx == as_get_acc h1 ctx' /\ state_inv_t h1 ctx') let reveal_ctx_inv #s ctx h0 h1: Lemma (requires Seq.equal (as_seq h0 ctx) (as_seq h1 ctx) /\ state_inv_t h0 ctx) (ensures as_get_r h0 ctx == as_get_r h1 ctx /\ as_get_acc h0 ctx == as_get_acc h1 ctx /\ state_inv_t h1 ctx) = reveal_ctx_inv' #s ctx ctx h0 h1 val ctx_inv_zeros: #s:field_spec -> ctx:poly1305_ctx s -> h:mem -> Lemma (requires as_seq h ctx == Lib.Sequence.create (v (nlimb s +! precomplen s)) (limb_zero s)) (ensures state_inv_t #s h ctx) inline_for_extraction noextract let poly1305_init_st (s:field_spec) = ctx:poly1305_ctx s -> key:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h ctx /\ live h key /\ disjoint ctx key) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ (as_get_acc h1 ctx, as_get_r h1 ctx) == S.poly1305_init (as_seq h0 key)) [@ Meta.Attribute.specialize ] inline_for_extraction noextract val poly1305_init: #s:field_spec -> poly1305_init_st s inline_for_extraction noextract let poly1305_update1_st (s:field_spec) = ctx:poly1305_ctx s -> b:lbuffer uint8 16ul -> Stack unit (requires fun h -> live h ctx /\ live h b /\ disjoint b ctx /\ state_inv_t #s h ctx) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ as_get_r h0 ctx == as_get_r h1 ctx /\ as_get_acc h1 ctx == S.poly1305_update1 (as_get_r h0 ctx) 16 (as_seq h0 b) (as_get_acc h0 ctx)) inline_for_extraction noextract val poly1305_update1: (#s:field_spec) -> poly1305_update1_st s inline_for_extraction noextract
false
true
Hacl.Impl.Poly1305.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val poly1305_update_st : s: Hacl.Impl.Poly1305.Fields.field_spec -> Type0
[]
Hacl.Impl.Poly1305.poly1305_update_st
{ "file_name": "code/poly1305/Hacl.Impl.Poly1305.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Hacl.Impl.Poly1305.Fields.field_spec -> Type0
{ "end_col": 98, "end_line": 104, "start_col": 4, "start_line": 93 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "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": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let poly1305_update1_st (s:field_spec) = ctx:poly1305_ctx s -> b:lbuffer uint8 16ul -> Stack unit (requires fun h -> live h ctx /\ live h b /\ disjoint b ctx /\ state_inv_t #s h ctx) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ as_get_r h0 ctx == as_get_r h1 ctx /\ as_get_acc h1 ctx == S.poly1305_update1 (as_get_r h0 ctx) 16 (as_seq h0 b) (as_get_acc h0 ctx))
let poly1305_update1_st (s: field_spec) =
false
null
false
ctx: poly1305_ctx s -> b: lbuffer uint8 16ul -> Stack unit (requires fun h -> live h ctx /\ live h b /\ disjoint b ctx /\ state_inv_t #s h ctx) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ as_get_r h0 ctx == as_get_r h1 ctx /\ as_get_acc h1 ctx == S.poly1305_update1 (as_get_r h0 ctx) 16 (as_seq h0 b) (as_get_acc h0 ctx))
{ "checked_file": "Hacl.Impl.Poly1305.fsti.checked", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Poly1305.fsti" }
[ "total" ]
[ "Hacl.Impl.Poly1305.Fields.field_spec", "Hacl.Impl.Poly1305.poly1305_ctx", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Impl.Poly1305.Fields.limb", "Lib.Buffer.disjoint", "Hacl.Impl.Poly1305.state_inv_t", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Spec.Poly1305.felem", "Hacl.Impl.Poly1305.as_get_r", "Hacl.Impl.Poly1305.as_get_acc", "Spec.Poly1305.poly1305_update1", "Lib.Buffer.as_seq" ]
[]
module Hacl.Impl.Poly1305 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Poly1305.Fields module S = Spec.Poly1305 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 1" inline_for_extraction noextract let poly1305_ctx (s:field_spec) = lbuffer (limb s) (nlimb s +! precomplen s) noextract val as_get_acc: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> GTot S.felem noextract val as_get_r: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> GTot S.felem noextract val state_inv_t: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> Type0 // If the ctx is not modified, all the components and invariants are preserved val reveal_ctx_inv': #s:field_spec -> ctx:poly1305_ctx s -> ctx':poly1305_ctx s -> h0:mem -> h1:mem -> Lemma (requires Seq.equal (as_seq h0 ctx) (as_seq h1 ctx') /\ state_inv_t h0 ctx) (ensures as_get_r h0 ctx == as_get_r h1 ctx' /\ as_get_acc h0 ctx == as_get_acc h1 ctx' /\ state_inv_t h1 ctx') let reveal_ctx_inv #s ctx h0 h1: Lemma (requires Seq.equal (as_seq h0 ctx) (as_seq h1 ctx) /\ state_inv_t h0 ctx) (ensures as_get_r h0 ctx == as_get_r h1 ctx /\ as_get_acc h0 ctx == as_get_acc h1 ctx /\ state_inv_t h1 ctx) = reveal_ctx_inv' #s ctx ctx h0 h1 val ctx_inv_zeros: #s:field_spec -> ctx:poly1305_ctx s -> h:mem -> Lemma (requires as_seq h ctx == Lib.Sequence.create (v (nlimb s +! precomplen s)) (limb_zero s)) (ensures state_inv_t #s h ctx) inline_for_extraction noextract let poly1305_init_st (s:field_spec) = ctx:poly1305_ctx s -> key:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h ctx /\ live h key /\ disjoint ctx key) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ (as_get_acc h1 ctx, as_get_r h1 ctx) == S.poly1305_init (as_seq h0 key)) [@ Meta.Attribute.specialize ] inline_for_extraction noextract val poly1305_init: #s:field_spec -> poly1305_init_st s inline_for_extraction noextract
false
true
Hacl.Impl.Poly1305.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val poly1305_update1_st : s: Hacl.Impl.Poly1305.Fields.field_spec -> Type0
[]
Hacl.Impl.Poly1305.poly1305_update1_st
{ "file_name": "code/poly1305/Hacl.Impl.Poly1305.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Hacl.Impl.Poly1305.Fields.field_spec -> Type0
{ "end_col": 99, "end_line": 84, "start_col": 4, "start_line": 74 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "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": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let poly1305_mac_st (s:field_spec) = tag:lbuffer uint8 16ul -> len:size_t -> text:lbuffer uint8 len -> key:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h text /\ live h tag /\ live h key /\ disjoint tag text /\ disjoint tag key) (ensures fun h0 _ h1 -> modifies (loc tag) h0 h1 /\ as_seq h1 tag == S.poly1305_mac (as_seq h0 text) (as_seq h0 key))
let poly1305_mac_st (s: field_spec) =
false
null
false
tag: lbuffer uint8 16ul -> len: size_t -> text: lbuffer uint8 len -> key: lbuffer uint8 32ul -> Stack unit (requires fun h -> live h text /\ live h tag /\ live h key /\ disjoint tag text /\ disjoint tag key) (ensures fun h0 _ h1 -> modifies (loc tag) h0 h1 /\ as_seq h1 tag == S.poly1305_mac (as_seq h0 text) (as_seq h0 key))
{ "checked_file": "Hacl.Impl.Poly1305.fsti.checked", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Poly1305.fsti" }
[ "total" ]
[ "Hacl.Impl.Poly1305.Fields.field_spec", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Lib.Sequence.lseq", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Spec.Poly1305.poly1305_mac" ]
[]
module Hacl.Impl.Poly1305 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Poly1305.Fields module S = Spec.Poly1305 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 1" inline_for_extraction noextract let poly1305_ctx (s:field_spec) = lbuffer (limb s) (nlimb s +! precomplen s) noextract val as_get_acc: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> GTot S.felem noextract val as_get_r: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> GTot S.felem noextract val state_inv_t: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> Type0 // If the ctx is not modified, all the components and invariants are preserved val reveal_ctx_inv': #s:field_spec -> ctx:poly1305_ctx s -> ctx':poly1305_ctx s -> h0:mem -> h1:mem -> Lemma (requires Seq.equal (as_seq h0 ctx) (as_seq h1 ctx') /\ state_inv_t h0 ctx) (ensures as_get_r h0 ctx == as_get_r h1 ctx' /\ as_get_acc h0 ctx == as_get_acc h1 ctx' /\ state_inv_t h1 ctx') let reveal_ctx_inv #s ctx h0 h1: Lemma (requires Seq.equal (as_seq h0 ctx) (as_seq h1 ctx) /\ state_inv_t h0 ctx) (ensures as_get_r h0 ctx == as_get_r h1 ctx /\ as_get_acc h0 ctx == as_get_acc h1 ctx /\ state_inv_t h1 ctx) = reveal_ctx_inv' #s ctx ctx h0 h1 val ctx_inv_zeros: #s:field_spec -> ctx:poly1305_ctx s -> h:mem -> Lemma (requires as_seq h ctx == Lib.Sequence.create (v (nlimb s +! precomplen s)) (limb_zero s)) (ensures state_inv_t #s h ctx) inline_for_extraction noextract let poly1305_init_st (s:field_spec) = ctx:poly1305_ctx s -> key:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h ctx /\ live h key /\ disjoint ctx key) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ (as_get_acc h1 ctx, as_get_r h1 ctx) == S.poly1305_init (as_seq h0 key)) [@ Meta.Attribute.specialize ] inline_for_extraction noextract val poly1305_init: #s:field_spec -> poly1305_init_st s inline_for_extraction noextract let poly1305_update1_st (s:field_spec) = ctx:poly1305_ctx s -> b:lbuffer uint8 16ul -> Stack unit (requires fun h -> live h ctx /\ live h b /\ disjoint b ctx /\ state_inv_t #s h ctx) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ as_get_r h0 ctx == as_get_r h1 ctx /\ as_get_acc h1 ctx == S.poly1305_update1 (as_get_r h0 ctx) 16 (as_seq h0 b) (as_get_acc h0 ctx)) inline_for_extraction noextract val poly1305_update1: (#s:field_spec) -> poly1305_update1_st s inline_for_extraction noextract let poly1305_update_st (s:field_spec) = ctx:poly1305_ctx s -> len:size_t -> text:lbuffer uint8 len -> Stack unit (requires fun h -> live h text /\ live h ctx /\ disjoint ctx text /\ state_inv_t #s h ctx) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ as_get_r h0 ctx == as_get_r h1 ctx /\ as_get_acc h1 ctx == S.poly1305_update (as_seq h0 text) (as_get_acc h0 ctx) (as_get_r h0 ctx)) inline_for_extraction noextract [@ Meta.Attribute.specialize ] val poly1305_update: #s:field_spec -> poly1305_update_st s inline_for_extraction noextract let poly1305_finish_st (s:field_spec) = tag:lbuffer uint8 16ul -> key:lbuffer uint8 32ul -> ctx:poly1305_ctx s -> Stack unit (requires fun h -> live h tag /\ live h key /\ live h ctx /\ disjoint tag key /\ disjoint tag ctx /\ disjoint key ctx /\ state_inv_t #s h ctx) (ensures fun h0 _ h1 -> modifies (loc tag |+| loc ctx) h0 h1 /\ as_seq h1 tag == S.poly1305_finish (as_seq h0 key) (as_get_acc h0 ctx)) [@ Meta.Attribute.specialize ] noextract inline_for_extraction val poly1305_finish: #s:field_spec -> poly1305_finish_st s inline_for_extraction noextract
false
true
Hacl.Impl.Poly1305.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val poly1305_mac_st : s: Hacl.Impl.Poly1305.Fields.field_spec -> Type0
[]
Hacl.Impl.Poly1305.poly1305_mac_st
{ "file_name": "code/poly1305/Hacl.Impl.Poly1305.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Hacl.Impl.Poly1305.Fields.field_spec -> Type0
{ "end_col": 69, "end_line": 143, "start_col": 4, "start_line": 133 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "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": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let poly1305_finish_st (s:field_spec) = tag:lbuffer uint8 16ul -> key:lbuffer uint8 32ul -> ctx:poly1305_ctx s -> Stack unit (requires fun h -> live h tag /\ live h key /\ live h ctx /\ disjoint tag key /\ disjoint tag ctx /\ disjoint key ctx /\ state_inv_t #s h ctx) (ensures fun h0 _ h1 -> modifies (loc tag |+| loc ctx) h0 h1 /\ as_seq h1 tag == S.poly1305_finish (as_seq h0 key) (as_get_acc h0 ctx))
let poly1305_finish_st (s: field_spec) =
false
null
false
tag: lbuffer uint8 16ul -> key: lbuffer uint8 32ul -> ctx: poly1305_ctx s -> Stack unit (requires fun h -> live h tag /\ live h key /\ live h ctx /\ disjoint tag key /\ disjoint tag ctx /\ disjoint key ctx /\ state_inv_t #s h ctx) (ensures fun h0 _ h1 -> modifies (loc tag |+| loc ctx) h0 h1 /\ as_seq h1 tag == S.poly1305_finish (as_seq h0 key) (as_get_acc h0 ctx))
{ "checked_file": "Hacl.Impl.Poly1305.fsti.checked", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Poly1305.fsti" }
[ "total" ]
[ "Hacl.Impl.Poly1305.Fields.field_spec", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Poly1305.poly1305_ctx", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Impl.Poly1305.Fields.limb", "Lib.Buffer.disjoint", "Hacl.Impl.Poly1305.state_inv_t", "Lib.Buffer.modifies", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.loc", "Prims.eq2", "Lib.Sequence.lseq", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Spec.Poly1305.poly1305_finish", "Hacl.Impl.Poly1305.as_get_acc" ]
[]
module Hacl.Impl.Poly1305 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Poly1305.Fields module S = Spec.Poly1305 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 1" inline_for_extraction noextract let poly1305_ctx (s:field_spec) = lbuffer (limb s) (nlimb s +! precomplen s) noextract val as_get_acc: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> GTot S.felem noextract val as_get_r: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> GTot S.felem noextract val state_inv_t: #s:field_spec -> h:mem -> ctx:poly1305_ctx s -> Type0 // If the ctx is not modified, all the components and invariants are preserved val reveal_ctx_inv': #s:field_spec -> ctx:poly1305_ctx s -> ctx':poly1305_ctx s -> h0:mem -> h1:mem -> Lemma (requires Seq.equal (as_seq h0 ctx) (as_seq h1 ctx') /\ state_inv_t h0 ctx) (ensures as_get_r h0 ctx == as_get_r h1 ctx' /\ as_get_acc h0 ctx == as_get_acc h1 ctx' /\ state_inv_t h1 ctx') let reveal_ctx_inv #s ctx h0 h1: Lemma (requires Seq.equal (as_seq h0 ctx) (as_seq h1 ctx) /\ state_inv_t h0 ctx) (ensures as_get_r h0 ctx == as_get_r h1 ctx /\ as_get_acc h0 ctx == as_get_acc h1 ctx /\ state_inv_t h1 ctx) = reveal_ctx_inv' #s ctx ctx h0 h1 val ctx_inv_zeros: #s:field_spec -> ctx:poly1305_ctx s -> h:mem -> Lemma (requires as_seq h ctx == Lib.Sequence.create (v (nlimb s +! precomplen s)) (limb_zero s)) (ensures state_inv_t #s h ctx) inline_for_extraction noextract let poly1305_init_st (s:field_spec) = ctx:poly1305_ctx s -> key:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h ctx /\ live h key /\ disjoint ctx key) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ (as_get_acc h1 ctx, as_get_r h1 ctx) == S.poly1305_init (as_seq h0 key)) [@ Meta.Attribute.specialize ] inline_for_extraction noextract val poly1305_init: #s:field_spec -> poly1305_init_st s inline_for_extraction noextract let poly1305_update1_st (s:field_spec) = ctx:poly1305_ctx s -> b:lbuffer uint8 16ul -> Stack unit (requires fun h -> live h ctx /\ live h b /\ disjoint b ctx /\ state_inv_t #s h ctx) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ as_get_r h0 ctx == as_get_r h1 ctx /\ as_get_acc h1 ctx == S.poly1305_update1 (as_get_r h0 ctx) 16 (as_seq h0 b) (as_get_acc h0 ctx)) inline_for_extraction noextract val poly1305_update1: (#s:field_spec) -> poly1305_update1_st s inline_for_extraction noextract let poly1305_update_st (s:field_spec) = ctx:poly1305_ctx s -> len:size_t -> text:lbuffer uint8 len -> Stack unit (requires fun h -> live h text /\ live h ctx /\ disjoint ctx text /\ state_inv_t #s h ctx) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ state_inv_t #s h1 ctx /\ as_get_r h0 ctx == as_get_r h1 ctx /\ as_get_acc h1 ctx == S.poly1305_update (as_seq h0 text) (as_get_acc h0 ctx) (as_get_r h0 ctx)) inline_for_extraction noextract [@ Meta.Attribute.specialize ] val poly1305_update: #s:field_spec -> poly1305_update_st s inline_for_extraction noextract
false
true
Hacl.Impl.Poly1305.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val poly1305_finish_st : s: Hacl.Impl.Poly1305.Fields.field_spec -> Type0
[]
Hacl.Impl.Poly1305.poly1305_finish_st
{ "file_name": "code/poly1305/Hacl.Impl.Poly1305.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Hacl.Impl.Poly1305.Fields.field_spec -> Type0
{ "end_col": 75, "end_line": 124, "start_col": 4, "start_line": 114 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.Poly1305.Fields", "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": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let poly1305_ctx (s:field_spec) = lbuffer (limb s) (nlimb s +! precomplen s)
let poly1305_ctx (s: field_spec) =
false
null
false
lbuffer (limb s) (nlimb s +! precomplen s)
{ "checked_file": "Hacl.Impl.Poly1305.fsti.checked", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "Meta.Attribute.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Poly1305.Fields.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Poly1305.fsti" }
[ "total" ]
[ "Hacl.Impl.Poly1305.Fields.field_spec", "Lib.Buffer.lbuffer", "Hacl.Impl.Poly1305.Fields.limb", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Poly1305.Fields.nlimb", "Hacl.Impl.Poly1305.Fields.precomplen" ]
[]
module Hacl.Impl.Poly1305 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Poly1305.Fields module S = Spec.Poly1305 #reset-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 1"
false
true
Hacl.Impl.Poly1305.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val poly1305_ctx : s: Hacl.Impl.Poly1305.Fields.field_spec -> Type0
[]
Hacl.Impl.Poly1305.poly1305_ctx
{ "file_name": "code/poly1305/Hacl.Impl.Poly1305.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Hacl.Impl.Poly1305.Fields.field_spec -> Type0
{ "end_col": 76, "end_line": 18, "start_col": 34, "start_line": 18 }
Prims.GTot
val parse (#t: Type) (p: bare_parser t) (input: bytes) : GTot (option (t * consumed_length input))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Norm", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse (#t: Type) (p: bare_parser t) (input: bytes) : GTot (option (t * consumed_length input)) = p input
val parse (#t: Type) (p: bare_parser t) (input: bytes) : GTot (option (t * consumed_length input)) let parse (#t: Type) (p: bare_parser t) (input: bytes) : GTot (option (t * consumed_length input)) =
false
null
false
p input
{ "checked_file": "LowParse.Spec.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "LowParse.Norm.fst.checked", "LowParse.Bytes.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Base.fsti" }
[ "sometrivial" ]
[ "LowParse.Spec.Base.bare_parser", "LowParse.Bytes.bytes", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length" ]
[]
module LowParse.Spec.Base include LowParse.Bytes include LowParse.Norm module Seq = FStar.Seq module U8 = FStar.UInt8 module U32 = FStar.UInt32 /// parse a value of type t /// /// - the parser can fail (currently reporting an uninformative [None]) /// - it returns the parsed value as well as the number of bytes read /// (this is intended to be the number of bytes to advance the input pointer) /// /// note that the type now forbids lookahead; the parser cannot depend on /// values beyond the returned offset /// /// these parsers are used as specifications, and thus use unrepresentable types /// such as byte sequences and natural numbers and are always pure [@"substitute"] inline_for_extraction let consumed_length (b: bytes) : Tot Type = (n: nat { n <= Seq.length b } ) inline_for_extraction let bare_parser (t:Type) : Tot Type = (b: bytes) -> GTot (option (t * consumed_length b)) let parse (#t: Type) (p: bare_parser t) (input: bytes)
false
false
LowParse.Spec.Base.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse (#t: Type) (p: bare_parser t) (input: bytes) : GTot (option (t * consumed_length input))
[]
LowParse.Spec.Base.parse
{ "file_name": "src/lowparse/LowParse.Spec.Base.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Spec.Base.bare_parser t -> input: LowParse.Bytes.bytes -> Prims.GTot (FStar.Pervasives.Native.option (t * LowParse.Spec.Base.consumed_length input))
{ "end_col": 9, "end_line": 33, "start_col": 2, "start_line": 33 }