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 bn_from_mont_u32 (len: BN.meta_len U32) : bn_from_mont_st U32 len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len = bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
val bn_from_mont_u32 (len: BN.meta_len U32) : bn_from_mont_st U32 len let bn_from_mont_u32 (len: BN.meta_len U32) : bn_from_mont_st U32 len =
false
null
false
bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.meta_len", "Lib.IntTypes.U32", "Hacl.Bignum.Montgomery.bn_from_mont", "Hacl.Bignum.mk_runtime_bn", "Hacl.Bignum.Montgomery.bn_mont_reduction_u32", "Hacl.Bignum.Montgomery.bn_from_mont_st" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame () let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame () let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in // In case you need to debug the type class projection, this is the explicit // syntax without referring to the implicitly-defined projector. k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame () let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.sqr aM c; mont_reduction n nInv_u64 c resM; pop_frame () /// All of the functions above are inline_for_extraction noextract meaning that /// they're intended to be specialized by clients for a specific value of /// ``len``. We provide a default implementation that actually keeps ``len`` at /// runtime, to offer a version of mod_exp where all the parameters are present /// at run-time. let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len = bn_check_modulus #U32 #len let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len) let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len = bn_mont_reduction (BN.mk_runtime_bn U32 len) let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len = bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
false
false
Hacl.Bignum.Montgomery.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 bn_from_mont_u32 (len: BN.meta_len U32) : bn_from_mont_st U32 len
[]
Hacl.Bignum.Montgomery.bn_from_mont_u32
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len Lib.IntTypes.U32 -> Hacl.Bignum.Montgomery.bn_from_mont_st Lib.IntTypes.U32 len
{ "end_col": 69, "end_line": 190, "start_col": 2, "start_line": 190 }
Prims.Tot
val bn_mont_precomp: #t:limb_t -> len:BN.meta_len t -> precompr2:bn_precomp_r2_mod_n_st t len -> bn_mont_precomp_st t len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul)
val bn_mont_precomp: #t:limb_t -> len:BN.meta_len t -> precompr2:bn_precomp_r2_mod_n_st t len -> bn_mont_precomp_st t len let bn_mont_precomp #t len precompr2 nBits n r2 =
false
null
false
precompr2 nBits n r2; mod_inv_limb n.(0ul)
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.ModInvLimb.mod_inv_limb", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t", "Prims.unit" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res )
false
false
Hacl.Bignum.Montgomery.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 bn_mont_precomp: #t:limb_t -> len:BN.meta_len t -> precompr2:bn_precomp_r2_mod_n_st t len -> bn_mont_precomp_st t len
[]
Hacl.Bignum.Montgomery.bn_mont_precomp
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len t -> precompr2: Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st t len -> Hacl.Bignum.Montgomery.bn_mont_precomp_st t len
{ "end_col": 22, "end_line": 56, "start_col": 2, "start_line": 55 }
Prims.Tot
val bn_from_mont_u64 (len: BN.meta_len U64) : bn_from_mont_st U64 len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_from_mont_u64 (len:BN.meta_len U64) : bn_from_mont_st U64 len = bn_from_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
val bn_from_mont_u64 (len: BN.meta_len U64) : bn_from_mont_st U64 len let bn_from_mont_u64 (len: BN.meta_len U64) : bn_from_mont_st U64 len =
false
null
false
bn_from_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.meta_len", "Lib.IntTypes.U64", "Hacl.Bignum.Montgomery.bn_from_mont", "Hacl.Bignum.mk_runtime_bn", "Hacl.Bignum.Montgomery.bn_mont_reduction_u64", "Hacl.Bignum.Montgomery.bn_from_mont_st" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame () let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame () let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in // In case you need to debug the type class projection, this is the explicit // syntax without referring to the implicitly-defined projector. k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame () let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.sqr aM c; mont_reduction n nInv_u64 c resM; pop_frame () /// All of the functions above are inline_for_extraction noextract meaning that /// they're intended to be specialized by clients for a specific value of /// ``len``. We provide a default implementation that actually keeps ``len`` at /// runtime, to offer a version of mod_exp where all the parameters are present /// at run-time. let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len = bn_check_modulus #U32 #len let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len) let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len = bn_mont_reduction (BN.mk_runtime_bn U32 len) let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len = bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len = bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len = bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len = bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) inline_for_extraction noextract let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = { bn = BN.mk_runtime_bn U32 len; mont_check = bn_check_modulus_u32 len; precomp = bn_precomp_r2_mod_n_u32 len; reduction = bn_mont_reduction_u32 len; to = bn_to_mont_u32 len; from = bn_from_mont_u32 len; mul = bn_mont_mul_u32 len; sqr = bn_mont_sqr_u32 len; } let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len = bn_check_modulus #U64 #len let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len) let bn_mont_reduction_u64 (len:BN.meta_len U64) : bn_mont_reduction_st U64 len = bn_mont_reduction (BN.mk_runtime_bn U64 len) let bn_to_mont_u64 (len:BN.meta_len U64) : bn_to_mont_st U64 len = bn_to_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
false
false
Hacl.Bignum.Montgomery.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 bn_from_mont_u64 (len: BN.meta_len U64) : bn_from_mont_st U64 len
[]
Hacl.Bignum.Montgomery.bn_from_mont_u64
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len Lib.IntTypes.U64 -> Hacl.Bignum.Montgomery.bn_from_mont_st Lib.IntTypes.U64 len
{ "end_col": 69, "end_line": 218, "start_col": 2, "start_line": 218 }
Prims.Tot
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
let bn_mont_reduction_loop_div_r_st (t: limb_t) (len: size_t{0 < v len /\ v len + v len <= max_size_t}) =
false
null
false
n: lbignum t len -> mu: limb t -> c: lbignum t (len +! len) -> res: lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c))
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.op_Plus_Bang", "Hacl.Spec.Bignum.Base.carry", "FStar.Monotonic.HyperStack.mem", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.loc", "Prims.eq2", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Definitions.lbignum", "FStar.Pervasives.Native.Mktuple2", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.Montgomery.bn_mont_reduction_loop_div_r" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract
false
false
Hacl.Bignum.Montgomery.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 bn_mont_reduction_loop_div_r_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v len /\ Lib.IntTypes.v len + Lib.IntTypes.v len <= Lib.IntTypes.max_size_t } -> Type0
[]
Hacl.Bignum.Montgomery.bn_mont_reduction_loop_div_r_st
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t { 0 < Lib.IntTypes.v len /\ Lib.IntTypes.v len + Lib.IntTypes.v len <= Lib.IntTypes.max_size_t } -> Type0
{ "end_col": 89, "end_line": 104, "start_col": 4, "start_line": 95 }
Prims.Tot
val bn_mont_mul_u64 (len: BN.meta_len U64) : bn_mont_mul_st U64 len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_mul_u64 (len:BN.meta_len U64) : bn_mont_mul_st U64 len = bn_mont_mul (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
val bn_mont_mul_u64 (len: BN.meta_len U64) : bn_mont_mul_st U64 len let bn_mont_mul_u64 (len: BN.meta_len U64) : bn_mont_mul_st U64 len =
false
null
false
bn_mont_mul (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.meta_len", "Lib.IntTypes.U64", "Hacl.Bignum.Montgomery.bn_mont_mul", "Hacl.Bignum.mk_runtime_bn", "Hacl.Bignum.Montgomery.bn_mont_reduction_u64", "Hacl.Bignum.Montgomery.bn_mont_mul_st" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame () let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame () let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in // In case you need to debug the type class projection, this is the explicit // syntax without referring to the implicitly-defined projector. k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame () let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.sqr aM c; mont_reduction n nInv_u64 c resM; pop_frame () /// All of the functions above are inline_for_extraction noextract meaning that /// they're intended to be specialized by clients for a specific value of /// ``len``. We provide a default implementation that actually keeps ``len`` at /// runtime, to offer a version of mod_exp where all the parameters are present /// at run-time. let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len = bn_check_modulus #U32 #len let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len) let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len = bn_mont_reduction (BN.mk_runtime_bn U32 len) let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len = bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len = bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len = bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len = bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) inline_for_extraction noextract let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = { bn = BN.mk_runtime_bn U32 len; mont_check = bn_check_modulus_u32 len; precomp = bn_precomp_r2_mod_n_u32 len; reduction = bn_mont_reduction_u32 len; to = bn_to_mont_u32 len; from = bn_from_mont_u32 len; mul = bn_mont_mul_u32 len; sqr = bn_mont_sqr_u32 len; } let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len = bn_check_modulus #U64 #len let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len) let bn_mont_reduction_u64 (len:BN.meta_len U64) : bn_mont_reduction_st U64 len = bn_mont_reduction (BN.mk_runtime_bn U64 len) let bn_to_mont_u64 (len:BN.meta_len U64) : bn_to_mont_st U64 len = bn_to_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) let bn_from_mont_u64 (len:BN.meta_len U64) : bn_from_mont_st U64 len = bn_from_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
false
false
Hacl.Bignum.Montgomery.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 bn_mont_mul_u64 (len: BN.meta_len U64) : bn_mont_mul_st U64 len
[]
Hacl.Bignum.Montgomery.bn_mont_mul_u64
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len Lib.IntTypes.U64 -> Hacl.Bignum.Montgomery.bn_mont_mul_st Lib.IntTypes.U64 len
{ "end_col": 68, "end_line": 220, "start_col": 2, "start_line": 220 }
Prims.Tot
val bn_mont_mul_u32 (len: BN.meta_len U32) : bn_mont_mul_st U32 len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len = bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
val bn_mont_mul_u32 (len: BN.meta_len U32) : bn_mont_mul_st U32 len let bn_mont_mul_u32 (len: BN.meta_len U32) : bn_mont_mul_st U32 len =
false
null
false
bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.meta_len", "Lib.IntTypes.U32", "Hacl.Bignum.Montgomery.bn_mont_mul", "Hacl.Bignum.mk_runtime_bn", "Hacl.Bignum.Montgomery.bn_mont_reduction_u32", "Hacl.Bignum.Montgomery.bn_mont_mul_st" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame () let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame () let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in // In case you need to debug the type class projection, this is the explicit // syntax without referring to the implicitly-defined projector. k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame () let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.sqr aM c; mont_reduction n nInv_u64 c resM; pop_frame () /// All of the functions above are inline_for_extraction noextract meaning that /// they're intended to be specialized by clients for a specific value of /// ``len``. We provide a default implementation that actually keeps ``len`` at /// runtime, to offer a version of mod_exp where all the parameters are present /// at run-time. let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len = bn_check_modulus #U32 #len let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len) let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len = bn_mont_reduction (BN.mk_runtime_bn U32 len) let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len = bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len = bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
false
false
Hacl.Bignum.Montgomery.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 bn_mont_mul_u32 (len: BN.meta_len U32) : bn_mont_mul_st U32 len
[]
Hacl.Bignum.Montgomery.bn_mont_mul_u32
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len Lib.IntTypes.U32 -> Hacl.Bignum.Montgomery.bn_mont_mul_st Lib.IntTypes.U32 len
{ "end_col": 68, "end_line": 192, "start_col": 2, "start_line": 192 }
Prims.Tot
val bn_mont_sqr_u32 (len: BN.meta_len U32) : bn_mont_sqr_st U32 len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len = bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
val bn_mont_sqr_u32 (len: BN.meta_len U32) : bn_mont_sqr_st U32 len let bn_mont_sqr_u32 (len: BN.meta_len U32) : bn_mont_sqr_st U32 len =
false
null
false
bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.meta_len", "Lib.IntTypes.U32", "Hacl.Bignum.Montgomery.bn_mont_sqr", "Hacl.Bignum.mk_runtime_bn", "Hacl.Bignum.Montgomery.bn_mont_reduction_u32", "Hacl.Bignum.Montgomery.bn_mont_sqr_st" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame () let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame () let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in // In case you need to debug the type class projection, this is the explicit // syntax without referring to the implicitly-defined projector. k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame () let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.sqr aM c; mont_reduction n nInv_u64 c resM; pop_frame () /// All of the functions above are inline_for_extraction noextract meaning that /// they're intended to be specialized by clients for a specific value of /// ``len``. We provide a default implementation that actually keeps ``len`` at /// runtime, to offer a version of mod_exp where all the parameters are present /// at run-time. let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len = bn_check_modulus #U32 #len let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len) let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len = bn_mont_reduction (BN.mk_runtime_bn U32 len) let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len = bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len = bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len = bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
false
false
Hacl.Bignum.Montgomery.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 bn_mont_sqr_u32 (len: BN.meta_len U32) : bn_mont_sqr_st U32 len
[]
Hacl.Bignum.Montgomery.bn_mont_sqr_u32
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len Lib.IntTypes.U32 -> Hacl.Bignum.Montgomery.bn_mont_sqr_st Lib.IntTypes.U32 len
{ "end_col": 68, "end_line": 194, "start_col": 2, "start_line": 194 }
Prims.Tot
val mk_runtime_mont: #t:limb_t -> len:BN.meta_len t -> mont t
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_runtime_mont (#t:limb_t) (len:BN.meta_len t) : mont t = match t with | U32 -> mk_runtime_mont_u32 len | U64 -> mk_runtime_mont_u64 len
val mk_runtime_mont: #t:limb_t -> len:BN.meta_len t -> mont t let mk_runtime_mont (#t: limb_t) (len: BN.meta_len t) : mont t =
false
null
false
match t with | U32 -> mk_runtime_mont_u32 len | U64 -> mk_runtime_mont_u64 len
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.Montgomery.mk_runtime_mont_u32", "Hacl.Bignum.Montgomery.mk_runtime_mont_u64", "Hacl.Bignum.Montgomery.mont" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame () let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame () let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in // In case you need to debug the type class projection, this is the explicit // syntax without referring to the implicitly-defined projector. k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame () let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.sqr aM c; mont_reduction n nInv_u64 c resM; pop_frame () /// All of the functions above are inline_for_extraction noextract meaning that /// they're intended to be specialized by clients for a specific value of /// ``len``. We provide a default implementation that actually keeps ``len`` at /// runtime, to offer a version of mod_exp where all the parameters are present /// at run-time. let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len = bn_check_modulus #U32 #len let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len) let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len = bn_mont_reduction (BN.mk_runtime_bn U32 len) let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len = bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len = bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len = bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len = bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) inline_for_extraction noextract let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = { bn = BN.mk_runtime_bn U32 len; mont_check = bn_check_modulus_u32 len; precomp = bn_precomp_r2_mod_n_u32 len; reduction = bn_mont_reduction_u32 len; to = bn_to_mont_u32 len; from = bn_from_mont_u32 len; mul = bn_mont_mul_u32 len; sqr = bn_mont_sqr_u32 len; } let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len = bn_check_modulus #U64 #len let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len) let bn_mont_reduction_u64 (len:BN.meta_len U64) : bn_mont_reduction_st U64 len = bn_mont_reduction (BN.mk_runtime_bn U64 len) let bn_to_mont_u64 (len:BN.meta_len U64) : bn_to_mont_st U64 len = bn_to_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) let bn_from_mont_u64 (len:BN.meta_len U64) : bn_from_mont_st U64 len = bn_from_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) let bn_mont_mul_u64 (len:BN.meta_len U64) : bn_mont_mul_st U64 len = bn_mont_mul (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) let bn_mont_sqr_u64 (len:BN.meta_len U64) : bn_mont_sqr_st U64 len = bn_mont_sqr (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) inline_for_extraction noextract let mk_runtime_mont_u64 (len:BN.meta_len U64) : mont U64 = { bn = BN.mk_runtime_bn U64 len; mont_check = bn_check_modulus_u64 len; precomp = bn_precomp_r2_mod_n_u64 len; reduction = bn_mont_reduction_u64 len; to = bn_to_mont_u64 len; from = bn_from_mont_u64 len; mul = bn_mont_mul_u64 len; sqr = bn_mont_sqr_u64 len; }
false
false
Hacl.Bignum.Montgomery.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 mk_runtime_mont: #t:limb_t -> len:BN.meta_len t -> mont t
[]
Hacl.Bignum.Montgomery.mk_runtime_mont
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len t -> Hacl.Bignum.Montgomery.mont t
{ "end_col": 34, "end_line": 239, "start_col": 2, "start_line": 237 }
Prims.Tot
val bn_to_mont_u32 (len: BN.meta_len U32) : bn_to_mont_st U32 len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len = bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
val bn_to_mont_u32 (len: BN.meta_len U32) : bn_to_mont_st U32 len let bn_to_mont_u32 (len: BN.meta_len U32) : bn_to_mont_st U32 len =
false
null
false
bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len)
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.meta_len", "Lib.IntTypes.U32", "Hacl.Bignum.Montgomery.bn_to_mont", "Hacl.Bignum.mk_runtime_bn", "Hacl.Bignum.Montgomery.bn_mont_reduction_u32", "Hacl.Bignum.Montgomery.bn_to_mont_st" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame () let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame () let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in // In case you need to debug the type class projection, this is the explicit // syntax without referring to the implicitly-defined projector. k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame () let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.sqr aM c; mont_reduction n nInv_u64 c resM; pop_frame () /// All of the functions above are inline_for_extraction noextract meaning that /// they're intended to be specialized by clients for a specific value of /// ``len``. We provide a default implementation that actually keeps ``len`` at /// runtime, to offer a version of mod_exp where all the parameters are present /// at run-time. let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len = bn_check_modulus #U32 #len let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len) let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len = bn_mont_reduction (BN.mk_runtime_bn U32 len)
false
false
Hacl.Bignum.Montgomery.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 bn_to_mont_u32 (len: BN.meta_len U32) : bn_to_mont_st U32 len
[]
Hacl.Bignum.Montgomery.bn_to_mont_u32
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len Lib.IntTypes.U32 -> Hacl.Bignum.Montgomery.bn_to_mont_st Lib.IntTypes.U32 len
{ "end_col": 67, "end_line": 188, "start_col": 2, "start_line": 188 }
Prims.Tot
val bn_to_mont_u64 (len: BN.meta_len U64) : bn_to_mont_st U64 len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_to_mont_u64 (len:BN.meta_len U64) : bn_to_mont_st U64 len = bn_to_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
val bn_to_mont_u64 (len: BN.meta_len U64) : bn_to_mont_st U64 len let bn_to_mont_u64 (len: BN.meta_len U64) : bn_to_mont_st U64 len =
false
null
false
bn_to_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len)
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.meta_len", "Lib.IntTypes.U64", "Hacl.Bignum.Montgomery.bn_to_mont", "Hacl.Bignum.mk_runtime_bn", "Hacl.Bignum.Montgomery.bn_mont_reduction_u64", "Hacl.Bignum.Montgomery.bn_to_mont_st" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame () let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame () let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in // In case you need to debug the type class projection, this is the explicit // syntax without referring to the implicitly-defined projector. k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame () let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.sqr aM c; mont_reduction n nInv_u64 c resM; pop_frame () /// All of the functions above are inline_for_extraction noextract meaning that /// they're intended to be specialized by clients for a specific value of /// ``len``. We provide a default implementation that actually keeps ``len`` at /// runtime, to offer a version of mod_exp where all the parameters are present /// at run-time. let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len = bn_check_modulus #U32 #len let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len) let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len = bn_mont_reduction (BN.mk_runtime_bn U32 len) let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len = bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len = bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len = bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len = bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) inline_for_extraction noextract let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = { bn = BN.mk_runtime_bn U32 len; mont_check = bn_check_modulus_u32 len; precomp = bn_precomp_r2_mod_n_u32 len; reduction = bn_mont_reduction_u32 len; to = bn_to_mont_u32 len; from = bn_from_mont_u32 len; mul = bn_mont_mul_u32 len; sqr = bn_mont_sqr_u32 len; } let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len = bn_check_modulus #U64 #len let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len) let bn_mont_reduction_u64 (len:BN.meta_len U64) : bn_mont_reduction_st U64 len = bn_mont_reduction (BN.mk_runtime_bn U64 len)
false
false
Hacl.Bignum.Montgomery.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 bn_to_mont_u64 (len: BN.meta_len U64) : bn_to_mont_st U64 len
[]
Hacl.Bignum.Montgomery.bn_to_mont_u64
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len Lib.IntTypes.U64 -> Hacl.Bignum.Montgomery.bn_to_mont_st Lib.IntTypes.U64 len
{ "end_col": 67, "end_line": 216, "start_col": 2, "start_line": 216 }
Prims.Tot
val bn_mont_reduction_u64 (len: BN.meta_len U64) : bn_mont_reduction_st U64 len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_reduction_u64 (len:BN.meta_len U64) : bn_mont_reduction_st U64 len = bn_mont_reduction (BN.mk_runtime_bn U64 len)
val bn_mont_reduction_u64 (len: BN.meta_len U64) : bn_mont_reduction_st U64 len let bn_mont_reduction_u64 (len: BN.meta_len U64) : bn_mont_reduction_st U64 len =
false
null
false
bn_mont_reduction (BN.mk_runtime_bn U64 len)
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.meta_len", "Lib.IntTypes.U64", "Hacl.Bignum.Montgomery.bn_mont_reduction", "Hacl.Bignum.mk_runtime_bn", "Hacl.Bignum.Montgomery.bn_mont_reduction_st" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame () let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame () let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in // In case you need to debug the type class projection, this is the explicit // syntax without referring to the implicitly-defined projector. k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame () let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.sqr aM c; mont_reduction n nInv_u64 c resM; pop_frame () /// All of the functions above are inline_for_extraction noextract meaning that /// they're intended to be specialized by clients for a specific value of /// ``len``. We provide a default implementation that actually keeps ``len`` at /// runtime, to offer a version of mod_exp where all the parameters are present /// at run-time. let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len = bn_check_modulus #U32 #len let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len) let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len = bn_mont_reduction (BN.mk_runtime_bn U32 len) let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len = bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len = bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len = bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len = bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) inline_for_extraction noextract let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = { bn = BN.mk_runtime_bn U32 len; mont_check = bn_check_modulus_u32 len; precomp = bn_precomp_r2_mod_n_u32 len; reduction = bn_mont_reduction_u32 len; to = bn_to_mont_u32 len; from = bn_from_mont_u32 len; mul = bn_mont_mul_u32 len; sqr = bn_mont_sqr_u32 len; } let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len = bn_check_modulus #U64 #len let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len)
false
false
Hacl.Bignum.Montgomery.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 bn_mont_reduction_u64 (len: BN.meta_len U64) : bn_mont_reduction_st U64 len
[]
Hacl.Bignum.Montgomery.bn_mont_reduction_u64
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len Lib.IntTypes.U64 -> Hacl.Bignum.Montgomery.bn_mont_reduction_st Lib.IntTypes.U64 len
{ "end_col": 46, "end_line": 214, "start_col": 2, "start_line": 214 }
Prims.Tot
val bn_mont_reduction_u32 (len: BN.meta_len U32) : bn_mont_reduction_st U32 len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len = bn_mont_reduction (BN.mk_runtime_bn U32 len)
val bn_mont_reduction_u32 (len: BN.meta_len U32) : bn_mont_reduction_st U32 len let bn_mont_reduction_u32 (len: BN.meta_len U32) : bn_mont_reduction_st U32 len =
false
null
false
bn_mont_reduction (BN.mk_runtime_bn U32 len)
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.meta_len", "Lib.IntTypes.U32", "Hacl.Bignum.Montgomery.bn_mont_reduction", "Hacl.Bignum.mk_runtime_bn", "Hacl.Bignum.Montgomery.bn_mont_reduction_st" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame () let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame () let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in // In case you need to debug the type class projection, this is the explicit // syntax without referring to the implicitly-defined projector. k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame () let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.sqr aM c; mont_reduction n nInv_u64 c resM; pop_frame () /// All of the functions above are inline_for_extraction noextract meaning that /// they're intended to be specialized by clients for a specific value of /// ``len``. We provide a default implementation that actually keeps ``len`` at /// runtime, to offer a version of mod_exp where all the parameters are present /// at run-time. let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len = bn_check_modulus #U32 #len let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len)
false
false
Hacl.Bignum.Montgomery.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 bn_mont_reduction_u32 (len: BN.meta_len U32) : bn_mont_reduction_st U32 len
[]
Hacl.Bignum.Montgomery.bn_mont_reduction_u32
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len Lib.IntTypes.U32 -> Hacl.Bignum.Montgomery.bn_mont_reduction_st Lib.IntTypes.U32 len
{ "end_col": 46, "end_line": 186, "start_col": 2, "start_line": 186 }
Prims.Tot
val mk_runtime_mont_u64 (len: BN.meta_len U64) : mont U64
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_runtime_mont_u64 (len:BN.meta_len U64) : mont U64 = { bn = BN.mk_runtime_bn U64 len; mont_check = bn_check_modulus_u64 len; precomp = bn_precomp_r2_mod_n_u64 len; reduction = bn_mont_reduction_u64 len; to = bn_to_mont_u64 len; from = bn_from_mont_u64 len; mul = bn_mont_mul_u64 len; sqr = bn_mont_sqr_u64 len; }
val mk_runtime_mont_u64 (len: BN.meta_len U64) : mont U64 let mk_runtime_mont_u64 (len: BN.meta_len U64) : mont U64 =
false
null
false
{ bn = BN.mk_runtime_bn U64 len; mont_check = bn_check_modulus_u64 len; precomp = bn_precomp_r2_mod_n_u64 len; reduction = bn_mont_reduction_u64 len; to = bn_to_mont_u64 len; from = bn_from_mont_u64 len; mul = bn_mont_mul_u64 len; sqr = bn_mont_sqr_u64 len }
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.meta_len", "Lib.IntTypes.U64", "Hacl.Bignum.Montgomery.Mkmont", "Hacl.Bignum.mk_runtime_bn", "Hacl.Bignum.Montgomery.bn_check_modulus_u64", "Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_u64", "Hacl.Bignum.Montgomery.bn_mont_reduction_u64", "Hacl.Bignum.Montgomery.bn_to_mont_u64", "Hacl.Bignum.Montgomery.bn_from_mont_u64", "Hacl.Bignum.Montgomery.bn_mont_mul_u64", "Hacl.Bignum.Montgomery.bn_mont_sqr_u64", "Hacl.Bignum.Montgomery.mont" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame () let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame () let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in // In case you need to debug the type class projection, this is the explicit // syntax without referring to the implicitly-defined projector. k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame () let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.sqr aM c; mont_reduction n nInv_u64 c resM; pop_frame () /// All of the functions above are inline_for_extraction noextract meaning that /// they're intended to be specialized by clients for a specific value of /// ``len``. We provide a default implementation that actually keeps ``len`` at /// runtime, to offer a version of mod_exp where all the parameters are present /// at run-time. let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len = bn_check_modulus #U32 #len let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len) let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len = bn_mont_reduction (BN.mk_runtime_bn U32 len) let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len = bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len = bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len = bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len = bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) inline_for_extraction noextract let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = { bn = BN.mk_runtime_bn U32 len; mont_check = bn_check_modulus_u32 len; precomp = bn_precomp_r2_mod_n_u32 len; reduction = bn_mont_reduction_u32 len; to = bn_to_mont_u32 len; from = bn_from_mont_u32 len; mul = bn_mont_mul_u32 len; sqr = bn_mont_sqr_u32 len; } let bn_check_modulus_u64 (len:BN.meta_len U64) : bn_check_modulus_st U64 len = bn_check_modulus #U64 #len let bn_precomp_r2_mod_n_u64 (len:BN.meta_len U64) : bn_precomp_r2_mod_n_st U64 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U64 len) let bn_mont_reduction_u64 (len:BN.meta_len U64) : bn_mont_reduction_st U64 len = bn_mont_reduction (BN.mk_runtime_bn U64 len) let bn_to_mont_u64 (len:BN.meta_len U64) : bn_to_mont_st U64 len = bn_to_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) let bn_from_mont_u64 (len:BN.meta_len U64) : bn_from_mont_st U64 len = bn_from_mont (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) let bn_mont_mul_u64 (len:BN.meta_len U64) : bn_mont_mul_st U64 len = bn_mont_mul (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) let bn_mont_sqr_u64 (len:BN.meta_len U64) : bn_mont_sqr_st U64 len = bn_mont_sqr (BN.mk_runtime_bn U64 len) (bn_mont_reduction_u64 len) inline_for_extraction noextract
false
true
Hacl.Bignum.Montgomery.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 mk_runtime_mont_u64 (len: BN.meta_len U64) : mont U64
[]
Hacl.Bignum.Montgomery.mk_runtime_mont_u64
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len Lib.IntTypes.U64 -> Hacl.Bignum.Montgomery.mont Lib.IntTypes.U64
{ "end_col": 28, "end_line": 233, "start_col": 2, "start_line": 226 }
Prims.Tot
val mk_runtime_mont_u32 (len: BN.meta_len U32) : mont U32
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_runtime_mont_u32 (len:BN.meta_len U32) : mont U32 = { bn = BN.mk_runtime_bn U32 len; mont_check = bn_check_modulus_u32 len; precomp = bn_precomp_r2_mod_n_u32 len; reduction = bn_mont_reduction_u32 len; to = bn_to_mont_u32 len; from = bn_from_mont_u32 len; mul = bn_mont_mul_u32 len; sqr = bn_mont_sqr_u32 len; }
val mk_runtime_mont_u32 (len: BN.meta_len U32) : mont U32 let mk_runtime_mont_u32 (len: BN.meta_len U32) : mont U32 =
false
null
false
{ bn = BN.mk_runtime_bn U32 len; mont_check = bn_check_modulus_u32 len; precomp = bn_precomp_r2_mod_n_u32 len; reduction = bn_mont_reduction_u32 len; to = bn_to_mont_u32 len; from = bn_from_mont_u32 len; mul = bn_mont_mul_u32 len; sqr = bn_mont_sqr_u32 len }
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.meta_len", "Lib.IntTypes.U32", "Hacl.Bignum.Montgomery.Mkmont", "Hacl.Bignum.mk_runtime_bn", "Hacl.Bignum.Montgomery.bn_check_modulus_u32", "Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_u32", "Hacl.Bignum.Montgomery.bn_mont_reduction_u32", "Hacl.Bignum.Montgomery.bn_to_mont_u32", "Hacl.Bignum.Montgomery.bn_from_mont_u32", "Hacl.Bignum.Montgomery.bn_mont_mul_u32", "Hacl.Bignum.Montgomery.bn_mont_sqr_u32", "Hacl.Bignum.Montgomery.mont" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame () let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame () let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in // In case you need to debug the type class projection, this is the explicit // syntax without referring to the implicitly-defined projector. k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame () let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.sqr aM c; mont_reduction n nInv_u64 c resM; pop_frame () /// All of the functions above are inline_for_extraction noextract meaning that /// they're intended to be specialized by clients for a specific value of /// ``len``. We provide a default implementation that actually keeps ``len`` at /// runtime, to offer a version of mod_exp where all the parameters are present /// at run-time. let bn_check_modulus_u32 (len:BN.meta_len U32) : bn_check_modulus_st U32 len = bn_check_modulus #U32 #len let bn_precomp_r2_mod_n_u32 (len:BN.meta_len U32) : bn_precomp_r2_mod_n_st U32 len = bn_precomp_r2_mod_n (BN.mk_runtime_bn U32 len) let bn_mont_reduction_u32 (len:BN.meta_len U32) : bn_mont_reduction_st U32 len = bn_mont_reduction (BN.mk_runtime_bn U32 len) let bn_to_mont_u32 (len:BN.meta_len U32) : bn_to_mont_st U32 len = bn_to_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_from_mont_u32 (len:BN.meta_len U32) : bn_from_mont_st U32 len = bn_from_mont (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_mul_u32 (len:BN.meta_len U32) : bn_mont_mul_st U32 len = bn_mont_mul (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) let bn_mont_sqr_u32 (len:BN.meta_len U32) : bn_mont_sqr_st U32 len = bn_mont_sqr (BN.mk_runtime_bn U32 len) (bn_mont_reduction_u32 len) inline_for_extraction noextract
false
true
Hacl.Bignum.Montgomery.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 mk_runtime_mont_u32 (len: BN.meta_len U32) : mont U32
[]
Hacl.Bignum.Montgomery.mk_runtime_mont_u32
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len Lib.IntTypes.U32 -> Hacl.Bignum.Montgomery.mont Lib.IntTypes.U32
{ "end_col": 28, "end_line": 205, "start_col": 2, "start_line": 198 }
Prims.Tot
val bn_check_modulus: #t:limb_t -> #len:BN.meta_len t -> bn_check_modulus_st t len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m
val bn_check_modulus: #t:limb_t -> #len:BN.meta_len t -> bn_check_modulus_st t len let bn_check_modulus #t #len n =
false
null
false
push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Amp_Dot", "Hacl.Bignum.bn_lt_mask", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.uint", "Hacl.Bignum.bn_is_odd", "Hacl.Bignum.bn_from_uint", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.Buffer.create", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
false
false
Hacl.Bignum.Montgomery.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 bn_check_modulus: #t:limb_t -> #len:BN.meta_len t -> bn_check_modulus_st t len
[]
Hacl.Bignum.Montgomery.bn_check_modulus
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Bignum.Montgomery.bn_check_modulus_st t len
{ "end_col": 3, "end_line": 35, "start_col": 2, "start_line": 27 }
Prims.Tot
val bn_mont_reduction: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_st t k.BN.len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res
val bn_mont_reduction: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_st t k.BN.len let bn_mont_reduction #t k n nInv c res =
false
null
false
[@@ inline_let ]let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.bn", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.bn_reduce_once", "Prims.unit", "Hacl.Spec.Bignum.Base.carry", "Hacl.Bignum.Montgomery.bn_mont_reduction_loop_div_r", "Hacl.Bignum.meta_len" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0
false
false
Hacl.Bignum.Montgomery.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 bn_mont_reduction: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_st t k.BN.len
[]
Hacl.Bignum.Montgomery.bn_mont_reduction
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.bn t -> Hacl.Bignum.Montgomery.bn_mont_reduction_st t (Mkbn?.len k)
{ "end_col": 32, "end_line": 135, "start_col": 2, "start_line": 133 }
Prims.Tot
val bn_precomp_r2_mod_n: #t:limb_t -> k:BN.bn t -> bn_precomp_r2_mod_n_st t k.BN.len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res )
val bn_precomp_r2_mod_n: #t:limb_t -> k:BN.bn t -> bn_precomp_r2_mod_n_st t k.BN.len let bn_precomp_r2_mod_n #t k nBits n res =
false
null
false
[@@ inline_let ]let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@@ inline_let ]let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati ((2 * bits t) * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res)
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.bn", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Division", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.bits", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Definitions.lbignum", "Lib.Buffer.loop1", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.op_Subtraction_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size", "Hacl.Bignum.add_mod_n", "Prims.unit", "Lib.LoopCombinators.unfold_repeati", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.op_Subtraction", "FStar.Mul.op_Star", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.nat", "Hacl.Spec.Bignum.Montgomery.bn_lshift1_mod_n", "Hacl.Bignum.bn_set_ith_bit", "Lib.Buffer.memset", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Hacl.Bignum.meta_len" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m
false
false
Hacl.Bignum.Montgomery.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 bn_precomp_r2_mod_n: #t:limb_t -> k:BN.bn t -> bn_precomp_r2_mod_n_st t k.BN.len
[]
Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.bn t -> Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st t (Mkbn?.len k)
{ "end_col": 3, "end_line": 51, "start_col": 2, "start_line": 39 }
Prims.Tot
val bn_mont_sqr: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_mont_sqr_st t k.BN.len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.sqr aM c; mont_reduction n nInv_u64 c resM; pop_frame ()
val bn_mont_sqr: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_mont_sqr_st t k.BN.len let bn_mont_sqr #t k mont_reduction n nInv_u64 aM resM =
false
null
false
[@@ inline_let ]let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.sqr aM c; mont_reduction n nInv_u64 c resM; pop_frame ()
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.bn", "Hacl.Bignum.Montgomery.bn_mont_reduction_st", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Bignum.__proj__Mkbn__item__sqr", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.add", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.create", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame", "Hacl.Bignum.meta_len" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame () let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame () let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in // In case you need to debug the type class projection, this is the explicit // syntax without referring to the implicitly-defined projector. k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame ()
false
false
Hacl.Bignum.Montgomery.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 bn_mont_sqr: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_mont_sqr_st t k.BN.len
[]
Hacl.Bignum.Montgomery.bn_mont_sqr
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.bn t -> mr: Hacl.Bignum.Montgomery.bn_mont_reduction_st t (Mkbn?.len k) -> Hacl.Bignum.Montgomery.bn_mont_sqr_st t (Mkbn?.len k)
{ "end_col": 14, "end_line": 173, "start_col": 2, "start_line": 168 }
Prims.Tot
val bn_to_mont: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_to_mont_st t k.BN.len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame ()
val bn_to_mont: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_to_mont_st t k.BN.len let bn_to_mont #t k mont_reduction n nInv r2 a aM =
false
null
false
[@@ inline_let ]let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame ()
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.bn", "Hacl.Bignum.Montgomery.bn_mont_reduction_st", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Bignum.mul", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.add", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.create", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame", "Hacl.Bignum.meta_len" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res
false
false
Hacl.Bignum.Montgomery.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 bn_to_mont: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_to_mont_st t k.BN.len
[]
Hacl.Bignum.Montgomery.bn_to_mont
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.bn t -> mr: Hacl.Bignum.Montgomery.bn_mont_reduction_st t (Mkbn?.len k) -> Hacl.Bignum.Montgomery.bn_to_mont_st t (Mkbn?.len k)
{ "end_col": 14, "end_line": 144, "start_col": 2, "start_line": 139 }
Prims.Tot
val bn_from_mont: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_from_mont_st t k.BN.len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame ()
val bn_from_mont: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_from_mont_st t k.BN.len let bn_from_mont #t k mont_reduction n nInv_u64 aM a =
false
null
false
[@@ inline_let ]let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame ()
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.bn", "Hacl.Bignum.Montgomery.bn_mont_reduction_st", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.Buffer.update_sub", "Lib.Buffer.MUT", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.add", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame", "Hacl.Bignum.meta_len" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame ()
false
false
Hacl.Bignum.Montgomery.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 bn_from_mont: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_from_mont_st t k.BN.len
[]
Hacl.Bignum.Montgomery.bn_from_mont
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.bn t -> mr: Hacl.Bignum.Montgomery.bn_mont_reduction_st t (Mkbn?.len k) -> Hacl.Bignum.Montgomery.bn_from_mont_st t (Mkbn?.len k)
{ "end_col": 14, "end_line": 153, "start_col": 2, "start_line": 148 }
Prims.Tot
val bn_mont_mul: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_mont_mul_st t k.BN.len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in // In case you need to debug the type class projection, this is the explicit // syntax without referring to the implicitly-defined projector. k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame ()
val bn_mont_mul: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_mont_mul_st t k.BN.len let bn_mont_mul #t k mont_reduction n nInv_u64 aM bM resM =
false
null
false
[@@ inline_let ]let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in k.BN.mul aM bM c; mont_reduction n nInv_u64 c resM; pop_frame ()
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.bn", "Hacl.Bignum.Montgomery.bn_mont_reduction_st", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Bignum.__proj__Mkbn__item__mul", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.add", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.create", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame", "Hacl.Bignum.meta_len" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0 let bn_mont_reduction #t k n nInv c res = [@inline_let] let len = k.BN.len in let c0 = bn_mont_reduction_loop_div_r #t k n nInv c res in BN.bn_reduce_once len n c0 res let bn_to_mont #t k mont_reduction n nInv r2 a aM = [@inline_let] let len = k.BN.len in push_frame (); let c = create (len +! len) (uint #t 0) in BN.mul a r2 c; mont_reduction n nInv c aM; pop_frame () let bn_from_mont #t k mont_reduction n nInv_u64 aM a = [@inline_let] let len = k.BN.len in push_frame (); let tmp = create (len +! len) (uint #t 0) in update_sub tmp 0ul len aM; mont_reduction n nInv_u64 tmp a; pop_frame ()
false
false
Hacl.Bignum.Montgomery.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 bn_mont_mul: #t:limb_t -> k:BN.bn t -> mr:bn_mont_reduction_st t k.BN.len -> bn_mont_mul_st t k.BN.len
[]
Hacl.Bignum.Montgomery.bn_mont_mul
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.bn t -> mr: Hacl.Bignum.Montgomery.bn_mont_reduction_st t (Mkbn?.len k) -> Hacl.Bignum.Montgomery.bn_mont_mul_st t (Mkbn?.len k)
{ "end_col": 14, "end_line": 164, "start_col": 2, "start_line": 157 }
Prims.Tot
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_reduction_loop_div_r #t k n nInv c res = [@inline_let] let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@inline_let] let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@inline_let] let footprint i = loc c0 |+| loc c in [@ inline_let] let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c ); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0
val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len let bn_mont_reduction_loop_div_r #t k n nInv c res =
false
null
false
[@@ inline_let ]let len = k.BN.len in push_frame (); let c0 = create 1ul (uint #t 0) in [@@ inline_let ]let refl h i : GTot (S.bn_mont_reduction_t i) = Seq.index (as_seq h c0) 0, as_seq h c in [@@ inline_let ]let footprint i = loc c0 |+| loc c in [@@ inline_let ]let spec h = S.bn_mont_reduction_f (as_seq h n) nInv in let h0 = ST.get () in loop h0 len S.bn_mont_reduction_t refl footprint spec (fun j -> Loops.unfold_repeat_gen (v len) S.bn_mont_reduction_t (spec h0) (refl h0 0) (v j); bn_mont_reduction_f len n nInv j c0 c); BN.bn_rshift (len +! len) c len res; let c0 = c0.(0ul) in pop_frame (); c0
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.bn", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.Bignum.Base.carry", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.bn_rshift", "Lib.Buffer.loop", "Hacl.Spec.Bignum.Montgomery.bn_mont_reduction_t", "Lib.IntTypes.v", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThan", "Hacl.Bignum.Montgomery.bn_mont_reduction_f", "Lib.LoopCombinators.unfold_repeat_gen", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.nat", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.op_Addition", "Hacl.Spec.Bignum.Montgomery.bn_mont_reduction_f", "Lib.Buffer.as_seq", "LowStar.Monotonic.Buffer.loc", "Lib.IntTypes.size_nat", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.loc", "FStar.Pervasives.Native.Mktuple2", "FStar.Seq.Base.index", "Lib.Buffer.lbuffer_t", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame", "Hacl.Bignum.meta_len" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j))) inline_for_extraction noextract let bn_mont_reduction_loop_div_r_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) = n:lbignum t len -> mu:limb t -> c:lbignum t (len +! len) -> res:lbignum t len -> Stack (carry t) (requires fun h -> live h n /\ live h c /\ live h res /\ disjoint res n /\ disjoint res c /\ disjoint n c) (ensures fun h0 c0 h1 -> modifies (loc res |+| loc c) h0 h1 /\ (c0, as_seq h1 res) == S.bn_mont_reduction_loop_div_r (as_seq h0 n) mu (as_seq h0 c)) inline_for_extraction noextract val bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
false
false
Hacl.Bignum.Montgomery.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 bn_mont_reduction_loop_div_r: #t:limb_t -> k:BN.bn t -> bn_mont_reduction_loop_div_r_st t k.BN.len
[]
Hacl.Bignum.Montgomery.bn_mont_reduction_loop_div_r
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Hacl.Bignum.bn t -> Hacl.Bignum.Montgomery.bn_mont_reduction_loop_div_r_st t (Mkbn?.len k)
{ "end_col": 4, "end_line": 129, "start_col": 2, "start_line": 110 }
FStar.HyperStack.ST.Stack
val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
[ { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Base", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum.ModInvLimb", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_mont_reduction_f #t len n nInv j c res = let qj = nInv *. res.(j) in // Keeping the inline_for_extraction version here. let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res)) let bn_mont_reduction_f #t len n nInv j c res =
true
null
false
let qj = nInv *. res.(j) in let c1 = BN.bn_mul1_lshift_add_in_place len n qj (len +! len) j res in let h0 = ST.get () in let resb = sub res (len +! j) 1ul in let res_j = res.(len +! j) in c.(0ul) <- addcarry_st c.(0ul) c1 res_j resb; let h1 = ST.get () in let tmp = sub res (len +! j) 1ul in B.modifies_buffer_elim (B.gsub #(limb t) res 0ul (len +! j)) (loc c |+| loc tmp) h0 h1; assert (v (len +! j +! 1ul) + v (len +! len -! len -! j -! 1ul) == v (len +! len)); B.modifies_buffer_elim (B.gsub #(limb t) res (len +! j +! 1ul) (len -! j -! 1ul)) (loc c |+| loc tmp) h0 h1; LSeq.lemma_update_sub (as_seq h0 res) (v len + v j) 1 (LSeq.sub (as_seq h1 res) (v len + v j) 1) (as_seq h1 res); LSeq.eq_intro (as_seq h1 res) (LSeq.upd (as_seq h0 res) (v len + v j) (Seq.index (as_seq h1 res) (v len + v j)))
{ "checked_file": "Hacl.Bignum.Montgomery.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.Montgomery.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.Montgomery.fst" }
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.max_size_t", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.limb", "Prims.op_LessThan", "Lib.Buffer.lbuffer", "Hacl.Spec.Bignum.Base.carry", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.op_Plus_Bang", "Lib.Sequence.eq_intro", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.Sequence.upd", "FStar.Seq.Base.index", "Prims.unit", "Lib.Sequence.lemma_update_sub", "Lib.Sequence.sub", "LowStar.Monotonic.Buffer.modifies_buffer_elim", "LowStar.Buffer.trivial_preorder", "LowStar.Buffer.gsub", "Lib.IntTypes.op_Subtraction_Bang", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.loc", "Prims._assert", "Prims.eq2", "Prims.int", "Lib.Buffer.lbuffer_t", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.op_Array_Assignment", "Hacl.Bignum.Base.addcarry_st", "Lib.Buffer.op_Array_Access", "Hacl.Bignum.bn_mul1_lshift_add_in_place", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Star_Dot" ]
[]
module Hacl.Bignum.Montgomery open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions open Hacl.Bignum.Base module ST = FStar.HyperStack.ST module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module B = LowStar.Buffer module S = Hacl.Spec.Bignum.Montgomery module SB = Hacl.Spec.Bignum module BN = Hacl.Bignum friend Hacl.Spec.Bignum.Montgomery #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let bn_check_modulus #t #len n = push_frame (); let one = create len (uint #t 0) in BN.bn_from_uint len (uint #t 1) one; let bit0 = BN.bn_is_odd len n in let m0 = uint #t 0 -. bit0 in let m1 = BN.bn_lt_mask len one n in let m = m0 &. m1 in pop_frame (); m let bn_precomp_r2_mod_n #t k nBits n res = [@inline_let] let len = k.BN.len in memset res (uint #t 0) len; BN.bn_set_ith_bit len res nBits; [@inline_let] let spec h = S.bn_lshift1_mod_n (as_seq h n) in let h0 = ST.get () in loop1 h0 (2ul *! size (bits t) *! len -! nBits) res spec (fun i -> Loops.unfold_repeati (2 * bits t * v len - v nBits) (spec h0) (as_seq h0 res) (v i); BN.add_mod_n n res res res ) let bn_mont_precomp #t len precompr2 nBits n r2 = precompr2 nBits n r2; mod_inv_limb n.(0ul) inline_for_extraction noextract val bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
false
false
Hacl.Bignum.Montgomery.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 bn_mont_reduction_f: #t:limb_t -> len:size_t{v len + v len <= max_size_t} -> n:lbignum t len -> nInv:(limb t) -> j:size_t{v j < v len} -> c:lbuffer (carry t) 1ul -> res:lbignum t (len +! len) -> Stack unit (requires fun h -> live h n /\ live h res /\ live h c /\ disjoint n res /\ disjoint n c /\ disjoint c res) (ensures fun h0 _ h1 -> modifies (loc res |+| loc c) h0 h1 /\ (Seq.index (as_seq h1 c) 0, as_seq h1 res) == S.bn_mont_reduction_f (as_seq h0 n) nInv (v j) (Seq.index (as_seq h0 c) 0, as_seq h0 res))
[]
Hacl.Bignum.Montgomery.bn_mont_reduction_f
{ "file_name": "code/bignum/Hacl.Bignum.Montgomery.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_t{Lib.IntTypes.v len + Lib.IntTypes.v len <= Lib.IntTypes.max_size_t} -> n: Hacl.Bignum.Definitions.lbignum t len -> nInv: Hacl.Bignum.Definitions.limb t -> j: Lib.IntTypes.size_t{Lib.IntTypes.v j < Lib.IntTypes.v len} -> c: Lib.Buffer.lbuffer (Hacl.Spec.Bignum.Base.carry t) 1ul -> res: Hacl.Bignum.Definitions.lbignum t (len +! len) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 114, "end_line": 90, "start_col": 47, "start_line": 76 }
Prims.Tot
val v (x:t) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 v x = x.v
val v (x:t) : Tot (uint_t n) let v x =
false
null
false
x.v
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[ "total" ]
[ "FStar.UInt64.t", "FStar.UInt64.__proj__Mk__item__v", "FStar.UInt.uint_t", "FStar.UInt64.n" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t
false
true
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val v (x:t) : Tot (uint_t n)
[]
FStar.UInt64.v
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.UInt64.t -> FStar.UInt.uint_t FStar.UInt64.n
{ "end_col": 13, "end_line": 28, "start_col": 10, "start_line": 28 }
Prims.Tot
val one : x:t{v x = 1}
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 = uint_to_t 1
val one : x:t{v x = 1} let one =
false
null
false
uint_to_t 1
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[ "total" ]
[ "FStar.UInt64.uint_to_t" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val one : x:t{v x = 1}
[]
FStar.UInt64.one
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.UInt64.t{FStar.UInt64.v x = 1}
{ "end_col": 21, "end_line": 40, "start_col": 10, "start_line": 40 }
Prims.Tot
val zero : x:t{v x = 0}
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 = uint_to_t 0
val zero : x:t{v x = 0} let zero =
false
null
false
uint_to_t 0
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[ "total" ]
[ "FStar.UInt64.uint_to_t" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = ()
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val zero : x:t{v x = 0}
[]
FStar.UInt64.zero
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.UInt64.t{FStar.UInt64.v x = 0}
{ "end_col": 22, "end_line": 38, "start_col": 11, "start_line": 38 }
Prims.Pure
val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 add_underspec a b = Mk (add_underspec (v a) (v b))
val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c)) let add_underspec a b =
false
null
false
Mk (add_underspec (v a) (v b))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt64.Mk", "FStar.UInt.add_underspec", "FStar.UInt64.n", "FStar.UInt64.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a + v b) n ==> v a + v b = v c))
[]
FStar.UInt64.add_underspec
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 54, "end_line": 44, "start_col": 24, "start_line": 44 }
Prims.Pure
val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 add a b = Mk (add (v a) (v b))
val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c)) let add a b =
false
null
false
Mk (add (v a) (v b))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt64.Mk", "FStar.UInt.add", "FStar.UInt64.n", "FStar.UInt64.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add (a:t) (b:t) : Pure t (requires (size (v a + v b) n)) (ensures (fun c -> v a + v b = v c))
[]
FStar.UInt64.add
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 34, "end_line": 42, "start_col": 14, "start_line": 42 }
Prims.Pure
val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 x y = Mk (logxor (v x) (v y))
val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z)) let logxor x y =
false
null
false
Mk (logxor (v x) (v y))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt64.Mk", "FStar.UInt.logxor", "FStar.UInt64.n", "FStar.UInt64.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val logxor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logxor` v y == v z))
[]
FStar.UInt64.logxor
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 40, "end_line": 66, "start_col": 17, "start_line": 66 }
Prims.Pure
val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 sub a b = Mk (sub (v a) (v b))
val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c)) let sub a b =
false
null
false
Mk (sub (v a) (v b))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt64.Mk", "FStar.UInt.sub", "FStar.UInt64.n", "FStar.UInt64.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sub (a:t) (b:t) : Pure t (requires (size (v a - v b) n)) (ensures (fun c -> v a - v b = v c))
[]
FStar.UInt64.sub
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 34, "end_line": 48, "start_col": 14, "start_line": 48 }
Prims.Pure
val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 mul a b = Mk (mul (v a) (v b))
val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c)) let mul a b =
false
null
false
Mk (mul (v a) (v b))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt64.Mk", "FStar.UInt.mul", "FStar.UInt64.n", "FStar.UInt64.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul (a:t) (b:t) : Pure t (requires (size (v a * v b) n)) (ensures (fun c -> v a * v b = v c))
[]
FStar.UInt64.mul
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 34, "end_line": 54, "start_col": 14, "start_line": 54 }
Prims.Pure
val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 mul_underspec a b = Mk (mul_underspec (v a) (v b))
val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c)) let mul_underspec a b =
false
null
false
Mk (mul_underspec (v a) (v b))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt64.Mk", "FStar.UInt.mul_underspec", "FStar.UInt64.n", "FStar.UInt64.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a * v b) n ==> v a * v b = v c))
[]
FStar.UInt64.mul_underspec
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 54, "end_line": 56, "start_col": 24, "start_line": 56 }
Prims.Pure
val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 sub_underspec a b = Mk (sub_underspec (v a) (v b))
val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c)) let sub_underspec a b =
false
null
false
Mk (sub_underspec (v a) (v b))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt64.Mk", "FStar.UInt.sub_underspec", "FStar.UInt64.n", "FStar.UInt64.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sub_underspec (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> size (v a - v b) n ==> v a - v b = v c))
[]
FStar.UInt64.sub_underspec
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 54, "end_line": 50, "start_col": 24, "start_line": 50 }
Prims.Pure
val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 x = Mk (lognot (v x))
val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z)) let lognot x =
false
null
false
Mk (lognot (v x))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt64.Mk", "FStar.UInt.lognot", "FStar.UInt64.n", "FStar.UInt64.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y)) let logxor x y = Mk (logxor (v x) (v y)) let logor x y = Mk (logor (v x) (v y))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lognot (x:t) : Pure t (requires True) (ensures (fun z -> lognot (v x) == v z))
[]
FStar.UInt64.lognot
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 32, "end_line": 70, "start_col": 15, "start_line": 70 }
Prims.Pure
val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 x y = Mk (logor (v x) (v y))
val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z)) let logor x y =
false
null
false
Mk (logor (v x) (v y))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt64.Mk", "FStar.UInt.logor", "FStar.UInt64.n", "FStar.UInt64.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y)) let logxor x y = Mk (logxor (v x) (v y))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val logor (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logor` v y == v z))
[]
FStar.UInt64.logor
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 38, "end_line": 68, "start_col": 16, "start_line": 68 }
Prims.Pure
val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 uint_to_t x = Mk x
val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x)) let uint_to_t x =
false
null
false
Mk x
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt.uint_t", "FStar.UInt64.n", "FStar.UInt64.Mk", "FStar.UInt64.t" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val uint_to_t (x:uint_t n) : Pure t (requires True) (ensures (fun y -> v y = x))
[]
FStar.UInt64.uint_to_t
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.UInt.uint_t FStar.UInt64.n -> Prims.Pure FStar.UInt64.t
{ "end_col": 22, "end_line": 30, "start_col": 18, "start_line": 30 }
Prims.Pure
val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 sub_mod a b = Mk (sub_mod (v a) (v b))
val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c)) let sub_mod a b =
false
null
false
Mk (sub_mod (v a) (v b))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt64.Mk", "FStar.UInt.sub_mod", "FStar.UInt64.n", "FStar.UInt64.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sub_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.sub_mod (v a) (v b) = v c))
[]
FStar.UInt64.sub_mod
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 42, "end_line": 52, "start_col": 18, "start_line": 52 }
Prims.Pure
val shift_left (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 a s = Mk (shift_left (v a) (UInt32.v s))
val shift_left (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c)) let shift_left a s =
false
null
false
Mk (shift_left (v a) (UInt32.v s))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt32.t", "FStar.UInt64.Mk", "FStar.UInt.shift_left", "FStar.UInt64.n", "FStar.UInt64.v", "FStar.UInt32.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y)) let logxor x y = Mk (logxor (v x) (v y)) let logor x y = Mk (logor (v x) (v y)) let lognot x = Mk (lognot (v x)) let shift_right a s = Mk (shift_right (v a) (UInt32.v s)) #push-options "--z3rlimit 80 --fuel 1" //AR: working around the interleaving semantics of pragmas
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 80, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val shift_left (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_left (v a) (UInt32.v s) = v c))
[]
FStar.UInt64.shift_left
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 55, "end_line": 76, "start_col": 21, "start_line": 76 }
Prims.Pure
val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 add_mod a b = Mk (add_mod (v a) (v b))
val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c)) let add_mod a b =
false
null
false
Mk (add_mod (v a) (v b))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt64.Mk", "FStar.UInt.add_mod", "FStar.UInt64.n", "FStar.UInt64.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.add_mod (v a) (v b) = v c))
[]
FStar.UInt64.add_mod
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 42, "end_line": 46, "start_col": 18, "start_line": 46 }
Prims.Pure
val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 mul_mod a b = Mk (mul_mod (v a) (v b))
val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c)) let mul_mod a b =
false
null
false
Mk (mul_mod (v a) (v b))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt64.Mk", "FStar.UInt.mul_mod", "FStar.UInt64.n", "FStar.UInt64.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_mod (a:t) (b:t) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mul_mod (v a) (v b) = v c))
[]
FStar.UInt64.mul_mod
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 42, "end_line": 58, "start_col": 18, "start_line": 58 }
Prims.Pure
val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 div a b = Mk (div (v a) (v b))
val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c)) let div a b =
false
null
false
Mk (div (v a) (v b))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "Prims.b2t", "Prims.op_disEquality", "Prims.int", "FStar.UInt64.v", "FStar.UInt64.Mk", "FStar.UInt.div", "FStar.UInt64.n" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c))
[]
FStar.UInt64.div
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.UInt64.t{FStar.UInt64.v b <> 0} -> Prims.Pure FStar.UInt64.t
{ "end_col": 34, "end_line": 60, "start_col": 14, "start_line": 60 }
Prims.Pure
val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 logand x y = Mk (logand (v x) (v y))
val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z)) let logand x y =
false
null
false
Mk (logand (v x) (v y))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt64.Mk", "FStar.UInt.logand", "FStar.UInt64.n", "FStar.UInt64.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val logand (x:t) (y:t) : Pure t (requires True) (ensures (fun z -> v x `logand` v y = v z))
[]
FStar.UInt64.logand
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: FStar.UInt64.t -> y: FStar.UInt64.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 40, "end_line": 64, "start_col": 17, "start_line": 64 }
Prims.Pure
val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 rem a b = Mk (mod (v a) (v b))
val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c)) let rem a b =
false
null
false
Mk (mod (v a) (v b))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "Prims.b2t", "Prims.op_disEquality", "Prims.int", "FStar.UInt64.v", "FStar.UInt64.Mk", "FStar.UInt.mod", "FStar.UInt64.n" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> FStar.UInt.mod (v a) (v b) = v c))
[]
FStar.UInt64.rem
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.UInt64.t{FStar.UInt64.v b <> 0} -> Prims.Pure FStar.UInt64.t
{ "end_col": 34, "end_line": 62, "start_col": 14, "start_line": 62 }
Prims.Pure
val shift_right (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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 a s = Mk (shift_right (v a) (UInt32.v s))
val shift_right (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c)) let shift_right a s =
false
null
false
Mk (shift_right (v a) (UInt32.v s))
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[]
[ "FStar.UInt64.t", "FStar.UInt32.t", "FStar.UInt64.Mk", "FStar.UInt.shift_right", "FStar.UInt64.n", "FStar.UInt64.v", "FStar.UInt32.v" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y)) let logxor x y = Mk (logxor (v x) (v y)) let logor x y = Mk (logor (v x) (v y)) let lognot x = Mk (lognot (v x))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val shift_right (a:t) (s:UInt32.t) : Pure t (requires (UInt32.v s < n)) (ensures (fun c -> FStar.UInt.shift_right (v a) (UInt32.v s) = v c))
[]
FStar.UInt64.shift_right
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> s: FStar.UInt32.t -> Prims.Pure FStar.UInt64.t
{ "end_col": 57, "end_line": 72, "start_col": 22, "start_line": 72 }
FStar.Pervasives.Lemma
val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b))))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.UInt", "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_sub_msbs a b = from_vec_propriety (to_vec (v a)) 1; from_vec_propriety (to_vec (v b)) 1; from_vec_propriety (to_vec (v (sub_mod a b))) 1
val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b)))) let lemma_sub_msbs a b =
false
null
true
from_vec_propriety (to_vec (v a)) 1; from_vec_propriety (to_vec (v b)) 1; from_vec_propriety (to_vec (v (sub_mod a b))) 1
{ "checked_file": "FStar.UInt64.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt64.fst" }
[ "lemma" ]
[ "FStar.UInt64.t", "FStar.UInt.from_vec_propriety", "FStar.UInt64.n", "FStar.UInt.to_vec", "FStar.UInt64.v", "FStar.UInt64.sub_mod", "Prims.unit" ]
[]
(* Copyright 2008-2019 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt64 (**** THIS MODULE IS GENERATED AUTOMATICALLY USING [mk_int.sh], DO NOT EDIT DIRECTLY ****) open FStar.UInt open FStar.Mul #set-options "--max_fuel 0 --max_ifuel 0" type t : eqtype = | Mk: v:uint_t n -> t let v x = x.v let uint_to_t x = Mk x let uv_inv _ = () let vu_inv _ = () let v_inj _ _ = () let zero = uint_to_t 0 let one = uint_to_t 1 let add a b = Mk (add (v a) (v b)) let add_underspec a b = Mk (add_underspec (v a) (v b)) let add_mod a b = Mk (add_mod (v a) (v b)) let sub a b = Mk (sub (v a) (v b)) let sub_underspec a b = Mk (sub_underspec (v a) (v b)) let sub_mod a b = Mk (sub_mod (v a) (v b)) let mul a b = Mk (mul (v a) (v b)) let mul_underspec a b = Mk (mul_underspec (v a) (v b)) let mul_mod a b = Mk (mul_mod (v a) (v b)) let div a b = Mk (div (v a) (v b)) let rem a b = Mk (mod (v a) (v b)) let logand x y = Mk (logand (v x) (v y)) let logxor x y = Mk (logxor (v x) (v y)) let logor x y = Mk (logor (v x) (v y)) let lognot x = Mk (lognot (v x)) let shift_right a s = Mk (shift_right (v a) (UInt32.v s)) #push-options "--z3rlimit 80 --fuel 1" //AR: working around the interleaving semantics of pragmas let shift_left a s = Mk (shift_left (v a) (UInt32.v s))
false
false
FStar.UInt64.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 80, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_sub_msbs (a:t) (b:t) : Lemma ((msb (v a) = msb (v b)) ==> (v a < v b <==> msb (v (sub_mod a b))))
[]
FStar.UInt64.lemma_sub_msbs
{ "file_name": "ulib/FStar.UInt64.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.UInt64.t -> FStar.Pervasives.Lemma (ensures FStar.UInt.msb (FStar.UInt64.v a) = FStar.UInt.msb (FStar.UInt64.v b) ==> (FStar.UInt64.v a < FStar.UInt64.v b <==> FStar.UInt.msb (FStar.UInt64.v (FStar.UInt64.sub_mod a b))))
{ "end_col": 53, "end_line": 81, "start_col": 6, "start_line": 79 }
FStar.HyperStack.ST.Stack
val whatever: Prims.unit -> Stack bool (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1))
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "C", "short_module": null }, { "abbrev": false, "full_module": "C", "short_module": null }, { "abbrev": 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 whatever (): Stack bool (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1)) = true
val whatever: Prims.unit -> Stack bool (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1)) let whatever () : Stack bool (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1)) =
true
null
false
true
{ "checked_file": "C.Failure.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "C.Failure.fst" }
[]
[ "Prims.unit", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.b2t", "Prims.eq2" ]
[]
module C.Failure open FStar.HyperStack.ST let whatever (): Stack bool (requires (fun _ -> true))
false
false
C.Failure.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 whatever: Prims.unit -> Stack bool (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1))
[]
C.Failure.whatever
{ "file_name": "krmllib/C.Failure.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.bool
{ "end_col": 6, "end_line": 8, "start_col": 2, "start_line": 8 }
FStar.HyperStack.ST.Stack
val failwith (#a: Type) (s: C.String.t) : Stack a (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1))
[ { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "C", "short_module": null }, { "abbrev": false, "full_module": "C", "short_module": null }, { "abbrev": 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 failwith (#a: Type) (s: C.String.t): Stack a (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1)) = C.String.print s; // Defeat recursion warnings. if whatever () then C.portable_exit 255l; failwith s
val failwith (#a: Type) (s: C.String.t) : Stack a (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1)) let rec failwith (#a: Type) (s: C.String.t) : Stack a (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1)) =
true
null
false
C.String.print s; if whatever () then C.portable_exit 255l; failwith s
{ "checked_file": "C.Failure.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int32.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "C.String.fsti.checked", "C.fst.checked" ], "interface_file": false, "source_file": "C.Failure.fst" }
[]
[ "C.String.t", "C.Failure.failwith", "Prims.unit", "C.portable_exit", "FStar.Int32.__int_to_t", "Prims.bool", "C.Failure.whatever", "C.String.print", "FStar.Monotonic.HyperStack.mem", "Prims.b2t", "Prims.eq2" ]
[]
module C.Failure open FStar.HyperStack.ST let whatever (): Stack bool (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1)) = true [@(deprecated "LowStar.Failure.failwith")] let rec failwith (#a: Type) (s: C.String.t): Stack a (requires (fun _ -> true))
false
false
C.Failure.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 failwith (#a: Type) (s: C.String.t) : Stack a (requires (fun _ -> true)) (ensures (fun h0 _ h1 -> h0 == h1))
[ "recursion" ]
C.Failure.failwith
{ "file_name": "krmllib/C.Failure.fst", "git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd", "git_url": "https://github.com/FStarLang/karamel.git", "project_name": "karamel" }
s: C.String.t -> FStar.HyperStack.ST.Stack a
{ "end_col": 12, "end_line": 18, "start_col": 2, "start_line": 14 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Exponentiation", "short_module": null }, { "abbrev": 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 inttype_a = t:inttype{t = U32 \/ t = U64}
let inttype_a =
false
null
false
t: inttype{t = U32 \/ t = U64}
{ "checked_file": "Hacl.Impl.Exponentiation.Definitions.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Exponentiation.Definitions.fst" }
[ "total" ]
[ "Lib.IntTypes.inttype", "Prims.l_or", "Prims.b2t", "Prims.op_Equality", "Lib.IntTypes.U32", "Lib.IntTypes.U64" ]
[]
module Hacl.Impl.Exponentiation.Definitions open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Lib.Exponentiation.Definition #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
false
true
Hacl.Impl.Exponentiation.Definitions.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 inttype_a : Type0
[]
Hacl.Impl.Exponentiation.Definitions.inttype_a
{ "file_name": "code/bignum/Hacl.Impl.Exponentiation.Definitions.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 45, "end_line": 17, "start_col": 16, "start_line": 17 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Exponentiation", "short_module": null }, { "abbrev": 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 lone_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (to:to_comm_monoid a_t len ctx_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> x:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h x /\ live h ctx /\ disjoint ctx x /\ to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc x) h0 h1 /\ to.linv (as_seq h1 x) /\ to.refl (as_seq h1 x) == to.comm_monoid.S.one)
let lone_st (a_t: inttype_a) (len: size_t{v len > 0}) (ctx_len: size_t) (to: to_comm_monoid a_t len ctx_len) =
false
null
false
ctx: lbuffer (uint_t a_t SEC) ctx_len -> x: lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h x /\ live h ctx /\ disjoint ctx x /\ to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc x) h0 h1 /\ to.linv (as_seq h1 x) /\ to.refl (as_seq h1 x) == to.comm_monoid.S.one)
{ "checked_file": "Hacl.Impl.Exponentiation.Definitions.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Exponentiation.Definitions.fst" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Exponentiation.Definitions.to_comm_monoid", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv_ctx", "Lib.Buffer.as_seq", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv", "Prims.eq2", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__a_spec", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__refl", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__one", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__comm_monoid" ]
[]
module Hacl.Impl.Exponentiation.Definitions open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Lib.Exponentiation.Definition #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let inttype_a = t:inttype{t = U32 \/ t = U64} inline_for_extraction noextract class to_comm_monoid (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) = { a_spec: Type0; comm_monoid: S.comm_monoid a_spec; linv_ctx: x:LSeq.lseq (uint_t a_t SEC) (v ctx_len) -> Type0; linv: x:LSeq.lseq (uint_t a_t SEC) (v len) -> Type0; refl: x:LSeq.lseq (uint_t a_t SEC) (v len){linv x} -> GTot a_spec; } inline_for_extraction noextract let lone_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t)
false
false
Hacl.Impl.Exponentiation.Definitions.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 lone_st : a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> to: Hacl.Impl.Exponentiation.Definitions.to_comm_monoid a_t len ctx_len -> Type0
[]
Hacl.Impl.Exponentiation.Definitions.lone_st
{ "file_name": "code/bignum/Hacl.Impl.Exponentiation.Definitions.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> to: Hacl.Impl.Exponentiation.Definitions.to_comm_monoid a_t len ctx_len -> Type0
{ "end_col": 50, "end_line": 43, "start_col": 4, "start_line": 35 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Exponentiation", "short_module": null }, { "abbrev": 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 lsqr_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (to:to_comm_monoid a_t len ctx_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> x:lbuffer (uint_t a_t SEC) len -> xx:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h x /\ live h xx /\ live h ctx /\ disjoint x ctx /\ disjoint xx ctx /\ eq_or_disjoint x xx /\ to.linv (as_seq h x) /\ to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc xx) h0 h1 /\ to.linv (as_seq h1 xx) /\ to.refl (as_seq h1 xx) == to.comm_monoid.S.mul (refl (as_seq h0 x)) (refl (as_seq h0 x)))
let lsqr_st (a_t: inttype_a) (len: size_t{v len > 0}) (ctx_len: size_t) (to: to_comm_monoid a_t len ctx_len) =
false
null
false
ctx: lbuffer (uint_t a_t SEC) ctx_len -> x: lbuffer (uint_t a_t SEC) len -> xx: lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h x /\ live h xx /\ live h ctx /\ disjoint x ctx /\ disjoint xx ctx /\ eq_or_disjoint x xx /\ to.linv (as_seq h x) /\ to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc xx) h0 h1 /\ to.linv (as_seq h1 xx) /\ to.refl (as_seq h1 xx) == to.comm_monoid.S.mul (refl (as_seq h0 x)) (refl (as_seq h0 x)))
{ "checked_file": "Hacl.Impl.Exponentiation.Definitions.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Exponentiation.Definitions.fst" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Exponentiation.Definitions.to_comm_monoid", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Lib.Buffer.eq_or_disjoint", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv", "Lib.Buffer.as_seq", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv_ctx", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__a_spec", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__refl", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__mul", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__comm_monoid", "Hacl.Impl.Exponentiation.Definitions.refl" ]
[]
module Hacl.Impl.Exponentiation.Definitions open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Lib.Exponentiation.Definition #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let inttype_a = t:inttype{t = U32 \/ t = U64} inline_for_extraction noextract class to_comm_monoid (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) = { a_spec: Type0; comm_monoid: S.comm_monoid a_spec; linv_ctx: x:LSeq.lseq (uint_t a_t SEC) (v ctx_len) -> Type0; linv: x:LSeq.lseq (uint_t a_t SEC) (v len) -> Type0; refl: x:LSeq.lseq (uint_t a_t SEC) (v len){linv x} -> GTot a_spec; } inline_for_extraction noextract let lone_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (to:to_comm_monoid a_t len ctx_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> x:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h x /\ live h ctx /\ disjoint ctx x /\ to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc x) h0 h1 /\ to.linv (as_seq h1 x) /\ to.refl (as_seq h1 x) == to.comm_monoid.S.one) inline_for_extraction noextract let lmul_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (to:to_comm_monoid a_t len ctx_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> x:lbuffer (uint_t a_t SEC) len -> y:lbuffer (uint_t a_t SEC) len -> xy:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h x /\ live h y /\ live h xy /\ live h ctx /\ eq_or_disjoint x xy /\ eq_or_disjoint y xy /\ eq_or_disjoint x y /\ disjoint ctx x /\ disjoint ctx y /\ disjoint ctx xy /\ to.linv (as_seq h x) /\ to.linv (as_seq h y) /\ to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc xy) h0 h1 /\ to.linv (as_seq h1 xy) /\ to.refl (as_seq h1 xy) == to.comm_monoid.S.mul (to.refl (as_seq h0 x)) (to.refl (as_seq h0 y))) inline_for_extraction noextract let lsqr_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t)
false
false
Hacl.Impl.Exponentiation.Definitions.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 lsqr_st : a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> to: Hacl.Impl.Exponentiation.Definitions.to_comm_monoid a_t len ctx_len -> Type0
[]
Hacl.Impl.Exponentiation.Definitions.lsqr_st
{ "file_name": "code/bignum/Hacl.Impl.Exponentiation.Definitions.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> to: Hacl.Impl.Exponentiation.Definitions.to_comm_monoid a_t len ctx_len -> Type0
{ "end_col": 93, "end_line": 81, "start_col": 4, "start_line": 72 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Exponentiation", "short_module": null }, { "abbrev": 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 lmul_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (to:to_comm_monoid a_t len ctx_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> x:lbuffer (uint_t a_t SEC) len -> y:lbuffer (uint_t a_t SEC) len -> xy:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h x /\ live h y /\ live h xy /\ live h ctx /\ eq_or_disjoint x xy /\ eq_or_disjoint y xy /\ eq_or_disjoint x y /\ disjoint ctx x /\ disjoint ctx y /\ disjoint ctx xy /\ to.linv (as_seq h x) /\ to.linv (as_seq h y) /\ to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc xy) h0 h1 /\ to.linv (as_seq h1 xy) /\ to.refl (as_seq h1 xy) == to.comm_monoid.S.mul (to.refl (as_seq h0 x)) (to.refl (as_seq h0 y)))
let lmul_st (a_t: inttype_a) (len: size_t{v len > 0}) (ctx_len: size_t) (to: to_comm_monoid a_t len ctx_len) =
false
null
false
ctx: lbuffer (uint_t a_t SEC) ctx_len -> x: lbuffer (uint_t a_t SEC) len -> y: lbuffer (uint_t a_t SEC) len -> xy: lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h x /\ live h y /\ live h xy /\ live h ctx /\ eq_or_disjoint x xy /\ eq_or_disjoint y xy /\ eq_or_disjoint x y /\ disjoint ctx x /\ disjoint ctx y /\ disjoint ctx xy /\ to.linv (as_seq h x) /\ to.linv (as_seq h y) /\ to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc xy) h0 h1 /\ to.linv (as_seq h1 xy) /\ to.refl (as_seq h1 xy) == to.comm_monoid.S.mul (to.refl (as_seq h0 x)) (to.refl (as_seq h0 y)))
{ "checked_file": "Hacl.Impl.Exponentiation.Definitions.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.Definition.fsti.checked", "Lib.Buffer.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Exponentiation.Definitions.fst" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Exponentiation.Definitions.to_comm_monoid", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.eq_or_disjoint", "Lib.Buffer.disjoint", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv", "Lib.Buffer.as_seq", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv_ctx", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__a_spec", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__refl", "Lib.Exponentiation.Definition.__proj__Mkcomm_monoid__item__mul", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__comm_monoid" ]
[]
module Hacl.Impl.Exponentiation.Definitions open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Lib.Exponentiation.Definition #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let inttype_a = t:inttype{t = U32 \/ t = U64} inline_for_extraction noextract class to_comm_monoid (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) = { a_spec: Type0; comm_monoid: S.comm_monoid a_spec; linv_ctx: x:LSeq.lseq (uint_t a_t SEC) (v ctx_len) -> Type0; linv: x:LSeq.lseq (uint_t a_t SEC) (v len) -> Type0; refl: x:LSeq.lseq (uint_t a_t SEC) (v len){linv x} -> GTot a_spec; } inline_for_extraction noextract let lone_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (to:to_comm_monoid a_t len ctx_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> x:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h x /\ live h ctx /\ disjoint ctx x /\ to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc x) h0 h1 /\ to.linv (as_seq h1 x) /\ to.refl (as_seq h1 x) == to.comm_monoid.S.one) inline_for_extraction noextract let lmul_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t)
false
false
Hacl.Impl.Exponentiation.Definitions.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 lmul_st : a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> to: Hacl.Impl.Exponentiation.Definitions.to_comm_monoid a_t len ctx_len -> Type0
[]
Hacl.Impl.Exponentiation.Definitions.lmul_st
{ "file_name": "code/bignum/Hacl.Impl.Exponentiation.Definitions.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> to: Hacl.Impl.Exponentiation.Definitions.to_comm_monoid a_t len ctx_len -> Type0
{ "end_col": 99, "end_line": 63, "start_col": 4, "start_line": 52 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ocmp = BS.ocmp
let ocmp =
false
null
false
BS.ocmp
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.ocmp" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code
false
true
Vale.X64.Lemmas.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 ocmp : Prims.eqtype
[]
Vale.X64.Lemmas.ocmp
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.eqtype
{ "end_col": 25, "end_line": 14, "start_col": 18, "start_line": 14 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let machine_eval_code = BS.machine_eval_code
let machine_eval_code =
false
null
false
BS.machine_eval_code
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total", "" ]
[ "Vale.X64.Machine_Semantics_s.machine_eval_code" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags
false
true
Vale.X64.Lemmas.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 machine_eval_code : c: Vale.X64.Machine_Semantics_s.code -> fuel: Prims.nat -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.Tot (FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state)
[]
Vale.X64.Lemmas.machine_eval_code
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c: Vale.X64.Machine_Semantics_s.code -> fuel: Prims.nat -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.Tot (FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state)
{ "end_col": 51, "end_line": 23, "start_col": 31, "start_line": 23 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags
let update_cf (flags: Flags.t) (new_cf: bool) =
false
null
false
Flags.upd fCarry (Some new_cf) flags
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total" ]
[ "Vale.X64.Flags.t", "Prims.bool", "Vale.X64.Flags.upd", "Vale.X64.Machine_s.fCarry", "FStar.Pervasives.Native.Some" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags
false
true
Vale.X64.Lemmas.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 update_cf : flags: Vale.X64.Flags.t -> new_cf: Prims.bool -> Vale.X64.Flags.t
[]
Vale.X64.Lemmas.update_cf
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
flags: Vale.X64.Flags.t -> new_cf: Prims.bool -> Vale.X64.Flags.t
{ "end_col": 82, "end_line": 19, "start_col": 46, "start_line": 19 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let machine_state = BS.machine_state
let machine_state =
false
null
false
BS.machine_state
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.machine_state" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags
false
true
Vale.X64.Lemmas.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 machine_state : Type
[]
Vale.X64.Lemmas.machine_state
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type
{ "end_col": 43, "end_line": 22, "start_col": 27, "start_line": 22 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let code = BS.code
let code =
false
null
false
BS.code
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.code" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s
false
true
Vale.X64.Lemmas.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 code : Type0
[]
Vale.X64.Lemmas.code
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 25, "end_line": 12, "start_col": 18, "start_line": 12 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fuel = nat
let fuel =
false
null
false
nat
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total" ]
[ "Prims.nat" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes
false
true
Vale.X64.Lemmas.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 fuel : Type0
[]
Vale.X64.Lemmas.fuel
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 21, "end_line": 15, "start_col": 18, "start_line": 15 }
Prims.GTot
val eval_ocmp (s: vale_state) (c: ocmp) : GTot bool
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_ocmp (s:vale_state) (c:ocmp) : GTot bool = snd (BS.machine_eval_ocmp (state_to_S s) c)
val eval_ocmp (s: vale_state) (c: ocmp) : GTot bool let eval_ocmp (s: vale_state) (c: ocmp) : GTot bool =
false
null
false
snd (BS.machine_eval_ocmp (state_to_S s) c)
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "sometrivial" ]
[ "Vale.X64.State.vale_state", "Vale.X64.Lemmas.ocmp", "FStar.Pervasives.Native.snd", "Vale.X64.Machine_Semantics_s.machine_state", "Prims.bool", "Vale.X64.Machine_Semantics_s.machine_eval_ocmp", "Vale.X64.StateLemmas.state_to_S" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags unfold let machine_state = BS.machine_state unfold let machine_eval_code = BS.machine_eval_code let rec code_modifies_ghost (c:code) : bool = match c with | Ins (Instr _ _ (BS.AnnotateGhost _)) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:machine_state) : machine_state = {s with BS.ms_trace = []; BS.ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.BS.ms_heap else s.BS.ms_heap; } let state_eq_S (ignore_ghost:bool) (s1 s2:machine_state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) let state_eq_opt (ignore_ghost:bool) (s1 s2:option BS.machine_state) = match (s1, s2) with | (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2 let eval_code (c:code) (s0:vale_state) (f0:fuel) (s1:vale_state) : Type0 = state_eq_opt (code_modifies_ghost c) (machine_eval_code c f0 (state_to_S s0)) (Some (state_to_S s1)) let eval_ins (c:code) (s0:vale_state) : Ghost (vale_state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM) = reveal_opaque (`%BS.machine_eval_code_ins) BS.machine_eval_code_ins; let f0 = 0 in let (Some sM) = machine_eval_code c f0 (state_to_S s0) in lemma_to_of sM; (state_of_S sM, f0)
false
false
Vale.X64.Lemmas.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 eval_ocmp (s: vale_state) (c: ocmp) : GTot bool
[]
Vale.X64.Lemmas.eval_ocmp
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.X64.State.vale_state -> c: Vale.X64.Lemmas.ocmp -> Prims.GTot Prims.bool
{ "end_col": 95, "end_line": 64, "start_col": 52, "start_line": 64 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let state_eq_S (ignore_ghost:bool) (s1 s2:machine_state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2)
let state_eq_S (ignore_ghost: bool) (s1 s2: machine_state) =
false
null
false
machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2)
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total" ]
[ "Prims.bool", "Vale.X64.Lemmas.machine_state", "Vale.X64.StateLemmas.machine_state_eq", "Vale.X64.Lemmas.core_state", "Prims.logical" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags unfold let machine_state = BS.machine_state unfold let machine_eval_code = BS.machine_eval_code let rec code_modifies_ghost (c:code) : bool = match c with | Ins (Instr _ _ (BS.AnnotateGhost _)) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:machine_state) : machine_state = {s with BS.ms_trace = []; BS.ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.BS.ms_heap else s.BS.ms_heap; }
false
true
Vale.X64.Lemmas.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 state_eq_S : ignore_ghost: Prims.bool -> s1: Vale.X64.Lemmas.machine_state -> s2: Vale.X64.Lemmas.machine_state -> Prims.logical
[]
Vale.X64.Lemmas.state_eq_S
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ignore_ghost: Prims.bool -> s1: Vale.X64.Lemmas.machine_state -> s2: Vale.X64.Lemmas.machine_state -> Prims.logical
{ "end_col": 76, "end_line": 44, "start_col": 2, "start_line": 44 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let codes = BS.codes
let codes =
false
null
false
BS.codes
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.codes" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16
false
true
Vale.X64.Lemmas.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 codes : Type0
[]
Vale.X64.Lemmas.codes
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 27, "end_line": 13, "start_col": 19, "start_line": 13 }
Prims.Tot
val cf (flags: Flags.t) : Flags.flag_val_t
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags
val cf (flags: Flags.t) : Flags.flag_val_t let cf (flags: Flags.t) : Flags.flag_val_t =
false
null
false
Flags.sel fCarry flags
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total" ]
[ "Vale.X64.Flags.t", "Vale.X64.Flags.sel", "Vale.X64.Machine_s.fCarry", "Vale.X64.Flags.flag_val_t" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat
false
true
Vale.X64.Lemmas.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 cf (flags: Flags.t) : Flags.flag_val_t
[]
Vale.X64.Lemmas.cf
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
flags: Vale.X64.Flags.t -> Vale.X64.Flags.flag_val_t
{ "end_col": 66, "end_line": 17, "start_col": 44, "start_line": 17 }
Prims.Tot
val eval_code (c: code) (s0: vale_state) (f0: fuel) (s1: vale_state) : Type0
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_code (c:code) (s0:vale_state) (f0:fuel) (s1:vale_state) : Type0 = state_eq_opt (code_modifies_ghost c) (machine_eval_code c f0 (state_to_S s0)) (Some (state_to_S s1))
val eval_code (c: code) (s0: vale_state) (f0: fuel) (s1: vale_state) : Type0 let eval_code (c: code) (s0: vale_state) (f0: fuel) (s1: vale_state) : Type0 =
false
null
false
state_eq_opt (code_modifies_ghost c) (machine_eval_code c f0 (state_to_S s0)) (Some (state_to_S s1))
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total" ]
[ "Vale.X64.Lemmas.code", "Vale.X64.State.vale_state", "Vale.X64.Lemmas.fuel", "Vale.X64.Lemmas.state_eq_opt", "Vale.X64.Lemmas.code_modifies_ghost", "Vale.X64.Lemmas.machine_eval_code", "Vale.X64.StateLemmas.state_to_S", "FStar.Pervasives.Native.Some", "Vale.X64.Machine_Semantics_s.machine_state" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags unfold let machine_state = BS.machine_state unfold let machine_eval_code = BS.machine_eval_code let rec code_modifies_ghost (c:code) : bool = match c with | Ins (Instr _ _ (BS.AnnotateGhost _)) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:machine_state) : machine_state = {s with BS.ms_trace = []; BS.ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.BS.ms_heap else s.BS.ms_heap; } let state_eq_S (ignore_ghost:bool) (s1 s2:machine_state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) let state_eq_opt (ignore_ghost:bool) (s1 s2:option BS.machine_state) = match (s1, s2) with | (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2
false
true
Vale.X64.Lemmas.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 eval_code (c: code) (s0: vale_state) (f0: fuel) (s1: vale_state) : Type0
[]
Vale.X64.Lemmas.eval_code
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c: Vale.X64.Lemmas.code -> s0: Vale.X64.State.vale_state -> f0: Vale.X64.Lemmas.fuel -> s1: Vale.X64.State.vale_state -> Type0
{ "end_col": 102, "end_line": 52, "start_col": 2, "start_line": 52 }
Prims.Tot
val overflow (flags: Flags.t) : Flags.flag_val_t
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags
val overflow (flags: Flags.t) : Flags.flag_val_t let overflow (flags: Flags.t) : Flags.flag_val_t =
false
null
false
Flags.sel fOverflow flags
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total" ]
[ "Vale.X64.Flags.t", "Vale.X64.Flags.sel", "Vale.X64.Machine_s.fOverflow", "Vale.X64.Flags.flag_val_t" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat
false
true
Vale.X64.Lemmas.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 overflow (flags: Flags.t) : Flags.flag_val_t
[]
Vale.X64.Lemmas.overflow
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
flags: Vale.X64.Flags.t -> Vale.X64.Flags.flag_val_t
{ "end_col": 75, "end_line": 18, "start_col": 50, "start_line": 18 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags
let update_of (flags: Flags.t) (new_of: bool) =
false
null
false
Flags.upd fOverflow (Some new_of) flags
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total" ]
[ "Vale.X64.Flags.t", "Prims.bool", "Vale.X64.Flags.upd", "Vale.X64.Machine_s.fOverflow", "FStar.Pervasives.Native.Some" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags
false
true
Vale.X64.Lemmas.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 update_of : flags: Vale.X64.Flags.t -> new_of: Prims.bool -> Vale.X64.Flags.t
[]
Vale.X64.Lemmas.update_of
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
flags: Vale.X64.Flags.t -> new_of: Prims.bool -> Vale.X64.Flags.t
{ "end_col": 85, "end_line": 20, "start_col": 46, "start_line": 20 }
Prims.Tot
val havoc_flags:Flags.t
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let havoc_flags : Flags.t = Flags.of_fun BS.havoc_flags
val havoc_flags:Flags.t let havoc_flags:Flags.t =
false
null
false
Flags.of_fun BS.havoc_flags
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total" ]
[ "Vale.X64.Flags.of_fun", "Vale.X64.Machine_Semantics_s.havoc_flags" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags unfold let machine_state = BS.machine_state unfold let machine_eval_code = BS.machine_eval_code let rec code_modifies_ghost (c:code) : bool = match c with | Ins (Instr _ _ (BS.AnnotateGhost _)) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:machine_state) : machine_state = {s with BS.ms_trace = []; BS.ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.BS.ms_heap else s.BS.ms_heap; } let state_eq_S (ignore_ghost:bool) (s1 s2:machine_state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) let state_eq_opt (ignore_ghost:bool) (s1 s2:option BS.machine_state) = match (s1, s2) with | (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2 let eval_code (c:code) (s0:vale_state) (f0:fuel) (s1:vale_state) : Type0 = state_eq_opt (code_modifies_ghost c) (machine_eval_code c f0 (state_to_S s0)) (Some (state_to_S s1)) let eval_ins (c:code) (s0:vale_state) : Ghost (vale_state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM) = reveal_opaque (`%BS.machine_eval_code_ins) BS.machine_eval_code_ins; let f0 = 0 in let (Some sM) = machine_eval_code c f0 (state_to_S s0) in lemma_to_of sM; (state_of_S sM, f0) let eval_ocmp (s:vale_state) (c:ocmp) : GTot bool = snd (BS.machine_eval_ocmp (state_to_S s) c) let valid_ocmp (c:ocmp) (s:vale_state) : GTot bool = BS.valid_ocmp c (state_to_S s)
false
true
Vale.X64.Lemmas.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 havoc_flags:Flags.t
[]
Vale.X64.Lemmas.havoc_flags
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.X64.Flags.t
{ "end_col": 29, "end_line": 70, "start_col": 2, "start_line": 70 }
Prims.Tot
val core_state (ignore_ghost: bool) (s: machine_state) : machine_state
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let core_state (ignore_ghost:bool) (s:machine_state) : machine_state = {s with BS.ms_trace = []; BS.ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.BS.ms_heap else s.BS.ms_heap; }
val core_state (ignore_ghost: bool) (s: machine_state) : machine_state let core_state (ignore_ghost: bool) (s: machine_state) : machine_state =
false
null
false
{ s with BS.ms_trace = []; BS.ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.BS.ms_heap else s.BS.ms_heap }
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total" ]
[ "Prims.bool", "Vale.X64.Lemmas.machine_state", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.Arch.HeapLemmas.heap_ignore_ghost_machine", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.Arch.Heap.heap_impl", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Prims.Nil", "Vale.X64.Machine_s.observation" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags unfold let machine_state = BS.machine_state unfold let machine_eval_code = BS.machine_eval_code let rec code_modifies_ghost (c:code) : bool = match c with | Ins (Instr _ _ (BS.AnnotateGhost _)) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs
false
true
Vale.X64.Lemmas.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 core_state (ignore_ghost: bool) (s: machine_state) : machine_state
[]
Vale.X64.Lemmas.core_state
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ignore_ghost: Prims.bool -> s: Vale.X64.Lemmas.machine_state -> Vale.X64.Lemmas.machine_state
{ "end_col": 95, "end_line": 40, "start_col": 3, "start_line": 38 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let state_eq_opt (ignore_ghost:bool) (s1 s2:option BS.machine_state) = match (s1, s2) with | (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2
let state_eq_opt (ignore_ghost: bool) (s1 s2: option BS.machine_state) =
false
null
false
match (s1, s2) with | Some s1, Some s2 -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "total" ]
[ "Prims.bool", "FStar.Pervasives.Native.option", "Vale.X64.Machine_Semantics_s.machine_state", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Lemmas.state_eq_S", "FStar.Pervasives.Native.tuple2", "Prims.eq2", "Prims.logical" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags unfold let machine_state = BS.machine_state unfold let machine_eval_code = BS.machine_eval_code let rec code_modifies_ghost (c:code) : bool = match c with | Ins (Instr _ _ (BS.AnnotateGhost _)) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:machine_state) : machine_state = {s with BS.ms_trace = []; BS.ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.BS.ms_heap else s.BS.ms_heap; } let state_eq_S (ignore_ghost:bool) (s1 s2:machine_state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2)
false
true
Vale.X64.Lemmas.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 state_eq_opt : ignore_ghost: Prims.bool -> s1: FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state -> s2: FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state -> Prims.logical
[]
Vale.X64.Lemmas.state_eq_opt
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ignore_ghost: Prims.bool -> s1: FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state -> s2: FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state -> Prims.logical
{ "end_col": 17, "end_line": 49, "start_col": 2, "start_line": 47 }
Prims.GTot
val ensure_valid_ocmp (c: ocmp) (s: vale_state) : GTot vale_state
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ensure_valid_ocmp (c:ocmp) (s:vale_state) : GTot vale_state = let ts:machine_state = fst (BS.machine_eval_ocmp (state_to_S s) c) in state_of_S ts
val ensure_valid_ocmp (c: ocmp) (s: vale_state) : GTot vale_state let ensure_valid_ocmp (c: ocmp) (s: vale_state) : GTot vale_state =
false
null
false
let ts:machine_state = fst (BS.machine_eval_ocmp (state_to_S s) c) in state_of_S ts
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "sometrivial" ]
[ "Vale.X64.Lemmas.ocmp", "Vale.X64.State.vale_state", "Vale.X64.StateLemmas.state_of_S", "Vale.X64.Machine_Semantics_s.machine_state", "FStar.Pervasives.Native.fst", "Prims.bool", "Vale.X64.Machine_Semantics_s.machine_eval_ocmp", "Vale.X64.StateLemmas.state_to_S" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags unfold let machine_state = BS.machine_state unfold let machine_eval_code = BS.machine_eval_code let rec code_modifies_ghost (c:code) : bool = match c with | Ins (Instr _ _ (BS.AnnotateGhost _)) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:machine_state) : machine_state = {s with BS.ms_trace = []; BS.ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.BS.ms_heap else s.BS.ms_heap; } let state_eq_S (ignore_ghost:bool) (s1 s2:machine_state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) let state_eq_opt (ignore_ghost:bool) (s1 s2:option BS.machine_state) = match (s1, s2) with | (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2 let eval_code (c:code) (s0:vale_state) (f0:fuel) (s1:vale_state) : Type0 = state_eq_opt (code_modifies_ghost c) (machine_eval_code c f0 (state_to_S s0)) (Some (state_to_S s1)) let eval_ins (c:code) (s0:vale_state) : Ghost (vale_state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM) = reveal_opaque (`%BS.machine_eval_code_ins) BS.machine_eval_code_ins; let f0 = 0 in let (Some sM) = machine_eval_code c f0 (state_to_S s0) in lemma_to_of sM; (state_of_S sM, f0) let eval_ocmp (s:vale_state) (c:ocmp) : GTot bool = snd (BS.machine_eval_ocmp (state_to_S s) c) let valid_ocmp (c:ocmp) (s:vale_state) : GTot bool = BS.valid_ocmp c (state_to_S s) let havoc_flags : Flags.t = Flags.of_fun BS.havoc_flags
false
false
Vale.X64.Lemmas.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 ensure_valid_ocmp (c: ocmp) (s: vale_state) : GTot vale_state
[]
Vale.X64.Lemmas.ensure_valid_ocmp
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c: Vale.X64.Lemmas.ocmp -> s: Vale.X64.State.vale_state -> Prims.GTot Vale.X64.State.vale_state
{ "end_col": 15, "end_line": 74, "start_col": 65, "start_line": 72 }
Prims.GTot
val valid_ocmp (c: ocmp) (s: vale_state) : GTot bool
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_ocmp (c:ocmp) (s:vale_state) : GTot bool = BS.valid_ocmp c (state_to_S s)
val valid_ocmp (c: ocmp) (s: vale_state) : GTot bool let valid_ocmp (c: ocmp) (s: vale_state) : GTot bool =
false
null
false
BS.valid_ocmp c (state_to_S s)
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[ "sometrivial" ]
[ "Vale.X64.Lemmas.ocmp", "Vale.X64.State.vale_state", "Vale.X64.Machine_Semantics_s.valid_ocmp", "Vale.X64.StateLemmas.state_to_S", "Prims.bool" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags unfold let machine_state = BS.machine_state unfold let machine_eval_code = BS.machine_eval_code let rec code_modifies_ghost (c:code) : bool = match c with | Ins (Instr _ _ (BS.AnnotateGhost _)) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:machine_state) : machine_state = {s with BS.ms_trace = []; BS.ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.BS.ms_heap else s.BS.ms_heap; } let state_eq_S (ignore_ghost:bool) (s1 s2:machine_state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) let state_eq_opt (ignore_ghost:bool) (s1 s2:option BS.machine_state) = match (s1, s2) with | (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2 let eval_code (c:code) (s0:vale_state) (f0:fuel) (s1:vale_state) : Type0 = state_eq_opt (code_modifies_ghost c) (machine_eval_code c f0 (state_to_S s0)) (Some (state_to_S s1)) let eval_ins (c:code) (s0:vale_state) : Ghost (vale_state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM) = reveal_opaque (`%BS.machine_eval_code_ins) BS.machine_eval_code_ins; let f0 = 0 in let (Some sM) = machine_eval_code c f0 (state_to_S s0) in lemma_to_of sM; (state_of_S sM, f0) let eval_ocmp (s:vale_state) (c:ocmp) : GTot bool = snd (BS.machine_eval_ocmp (state_to_S s) c)
false
false
Vale.X64.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_ocmp (c: ocmp) (s: vale_state) : GTot bool
[]
Vale.X64.Lemmas.valid_ocmp
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c: Vale.X64.Lemmas.ocmp -> s: Vale.X64.State.vale_state -> Prims.GTot Prims.bool
{ "end_col": 32, "end_line": 67, "start_col": 2, "start_line": 67 }
Prims.Ghost
val eval_ins (c: code) (s0: vale_state) : Ghost (vale_state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM)
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "BS" }, { "abbrev": false, "full_module": "Vale.X64.Bytes_Code_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_ins (c:code) (s0:vale_state) : Ghost (vale_state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM) = reveal_opaque (`%BS.machine_eval_code_ins) BS.machine_eval_code_ins; let f0 = 0 in let (Some sM) = machine_eval_code c f0 (state_to_S s0) in lemma_to_of sM; (state_of_S sM, f0)
val eval_ins (c: code) (s0: vale_state) : Ghost (vale_state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM) let eval_ins (c: code) (s0: vale_state) : Ghost (vale_state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM) =
false
null
false
reveal_opaque (`%BS.machine_eval_code_ins) BS.machine_eval_code_ins; let f0 = 0 in let Some sM = machine_eval_code c f0 (state_to_S s0) in lemma_to_of sM; (state_of_S sM, f0)
{ "checked_file": "Vale.X64.Lemmas.fsti.checked", "dependencies": [ "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Arch.HeapLemmas.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.X64.Lemmas.fsti" }
[]
[ "Vale.X64.Lemmas.code", "Vale.X64.State.vale_state", "Vale.X64.Machine_Semantics_s.machine_state", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Lemmas.fuel", "Vale.X64.StateLemmas.state_of_S", "Prims.unit", "Vale.X64.StateLemmas.lemma_to_of", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.option", "Vale.X64.Lemmas.machine_eval_code", "Vale.X64.StateLemmas.state_to_S", "Prims.int", "FStar.Pervasives.reveal_opaque", "Vale.X64.Machine_Semantics_s.ins", "Vale.X64.Machine_Semantics_s.machine_eval_code_ins", "Prims.b2t", "Vale.X64.Machine_s.uu___is_Ins", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Lemmas.eval_code" ]
[]
module Vale.X64.Lemmas open FStar.Mul open Vale.Arch.Heap open Vale.Arch.HeapImpl open Vale.Arch.HeapLemmas open Vale.X64.Machine_s open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Bytes_Code_s module BS = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 unfold let code = BS.code unfold let codes = BS.codes unfold let ocmp = BS.ocmp unfold let fuel = nat let cf (flags:Flags.t) : Flags.flag_val_t = Flags.sel fCarry flags let overflow (flags:Flags.t) : Flags.flag_val_t = Flags.sel fOverflow flags let update_cf (flags:Flags.t) (new_cf:bool) = Flags.upd fCarry (Some new_cf) flags let update_of (flags:Flags.t) (new_of:bool) = Flags.upd fOverflow (Some new_of) flags unfold let machine_state = BS.machine_state unfold let machine_eval_code = BS.machine_eval_code let rec code_modifies_ghost (c:code) : bool = match c with | Ins (Instr _ _ (BS.AnnotateGhost _)) -> true | Ins _ -> false | Block cs -> codes_modifies_ghost cs | IfElse _ c1 c2 -> code_modifies_ghost c1 || code_modifies_ghost c2 | While _ c -> code_modifies_ghost c and codes_modifies_ghost (cs:codes) : bool = match cs with | [] -> false | c::cs -> code_modifies_ghost c || codes_modifies_ghost cs let core_state (ignore_ghost:bool) (s:machine_state) : machine_state = {s with BS.ms_trace = []; BS.ms_heap = if ignore_ghost then heap_ignore_ghost_machine s.BS.ms_heap else s.BS.ms_heap; } let state_eq_S (ignore_ghost:bool) (s1 s2:machine_state) = machine_state_eq (core_state ignore_ghost s1) (core_state ignore_ghost s2) let state_eq_opt (ignore_ghost:bool) (s1 s2:option BS.machine_state) = match (s1, s2) with | (Some s1, Some s2) -> state_eq_S ignore_ghost s1 s2 | _ -> s1 == s2 let eval_code (c:code) (s0:vale_state) (f0:fuel) (s1:vale_state) : Type0 = state_eq_opt (code_modifies_ghost c) (machine_eval_code c f0 (state_to_S s0)) (Some (state_to_S s1)) let eval_ins (c:code) (s0:vale_state) : Ghost (vale_state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM)
false
false
Vale.X64.Lemmas.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 eval_ins (c: code) (s0: vale_state) : Ghost (vale_state & fuel) (requires Ins? c) (ensures fun (sM, f0) -> eval_code c s0 f0 sM)
[]
Vale.X64.Lemmas.eval_ins
{ "file_name": "vale/code/arch/x64/Vale.X64.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c: Vale.X64.Lemmas.code -> s0: Vale.X64.State.vale_state -> Prims.Ghost (Vale.X64.State.vale_state * Vale.X64.Lemmas.fuel)
{ "end_col": 21, "end_line": 62, "start_col": 2, "start_line": 58 }
FStar.HyperStack.ST.Stack
val pow2_252m2: out:felem -> z:felem -> Stack unit (requires fun h -> live h out /\ live h z /\ disjoint out z /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == F51.fevalh h0 z `SC.fpow` ((SC.prime + 3) / 8) )
[ { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Finv", "short_module": "CI" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let pow2_252m2 out z = push_frame(); let buf = create 20ul (u64 0) in crecip_1 out buf z; crecip_2 out buf z; assert_norm (7237005577332262213973186563042994240829374041602535252466099000494570602494 == (SC.prime + 3) / 8); pop_frame()
val pow2_252m2: out:felem -> z:felem -> Stack unit (requires fun h -> live h out /\ live h z /\ disjoint out z /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == F51.fevalh h0 z `SC.fpow` ((SC.prime + 3) / 8) ) let pow2_252m2 out z =
true
null
false
push_frame (); let buf = create 20ul (u64 0) in crecip_1 out buf z; crecip_2 out buf z; assert_norm (7237005577332262213973186563042994240829374041602535252466099000494570602494 == (SC.prime + 3) / 8); pop_frame ()
{ "checked_file": "Hacl.Impl.Ed25519.Pow2_252m2.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Finv.fst.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.Pow2_252m2.fst" }
[]
[ "Hacl.Bignum25519.felem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.op_Division", "Prims.op_Addition", "Spec.Curve25519.prime", "Hacl.Impl.Ed25519.Pow2_252m2.crecip_2", "Hacl.Impl.Ed25519.Pow2_252m2.crecip_1", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.u64", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.Ed25519.Pow2_252m2 open FStar.HyperStack.All module ST = FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module SC = Spec.Curve25519 module CI = Hacl.Spec.Curve25519.Finv #set-options "--z3rlimit 500 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract val crecip_1: out:felem -> buf:lbuffer uint64 20ul -> z:felem -> Stack unit (requires fun h -> live h out /\ live h buf /\ live h z /\ disjoint buf z /\ disjoint out z /\ disjoint out buf /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc buf) h0 h1 /\ F51.mul_inv_t h1 (gsub buf 10ul 5ul) /\ F51.felem_fits h1 (gsub buf 5ul 5ul) (1, 2, 1, 1, 1) /\ F51.fevalh h1 (gsub buf 5ul 5ul) == CI.pow (F51.fevalh h0 z) 1267650600228228275596796362752 /\ F51.fevalh h1 (gsub buf 10ul 5ul) == CI.pow (F51.fevalh h0 z) 1125899906842623 ) let crecip_1 out buf z = let a = sub buf 0ul 5ul in let t0 = sub buf 5ul 5ul in let b = sub buf 10ul 5ul in let c = sub buf 15ul 5ul in (**) let h0 = ST.get() in fsquare_times a z 1ul; // a = z ** (2 ** 1) == z ** 2 (**) assert_norm (pow2 1 == 2); fsquare_times t0 a 2ul; // t0 == a ** (2 ** 2) == (z ** 2) ** 4 == z ** 8 (**) CI.lemma_pow_mul (F51.fevalh h0 z) 2 4; (**) assert_norm (pow2 2 == 4); fmul b t0 z; // b == z0 ** 9 (**) CI.lemma_pow_one (F51.fevalh h0 z); (**) CI.lemma_pow_add (F51.fevalh h0 z) 8 1; fmul a b a; // a == b * a == z ** 11 (**) CI.lemma_pow_add (F51.fevalh h0 z) 9 2; fsquare_times t0 a 1ul; // t0 == a ** 2 == z ** 22 (**) CI.lemma_pow_mul (F51.fevalh h0 z) 11 2; fmul b t0 b; // b == z ** 31 (**) CI.lemma_pow_add (F51.fevalh h0 z) 22 9; fsquare_times t0 b 5ul; // t0 == b ** (2 ** 5) == z ** 992 (**) assert_norm (pow2 5 == 32); (**) CI.lemma_pow_mul (F51.fevalh h0 z) 31 32; fmul b t0 b; // b == t0 * b == z ** 1023 (**) CI.lemma_pow_add (F51.fevalh h0 z) 992 31; fsquare_times t0 b 10ul; // t0 = b ** (2 ** 1024) == z ** 1047552 (**) assert_norm (pow2 10 == 1024); (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1023 1024; fmul c t0 b; // c == z ** 1048575 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1047552 1023; fsquare_times t0 c 20ul; // t0 == c ** (2 ** 20) == 1099510579200 (**) assert_norm (pow2 20 == 1048576); (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1048575 1048576; fmul t0 t0 c; // t0 == z ** 1099511627775 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1099510579200 1048575; fsquare_times_inplace t0 10ul; // t0 == z ** 1125899906841600 (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1099511627775 1024; fmul b t0 b; // b == z ** 1125899906842623 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1125899906841600 1023; fsquare_times t0 b 50ul; // t0 == z ** 1267650600228228275596796362752; (**) assert_norm (pow2 50 = 1125899906842624); (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1125899906842623 1125899906842624 inline_for_extraction noextract val crecip_2: out:felem -> buf:lbuffer uint64 20ul -> z:felem -> Stack unit (requires fun h -> live h out /\ live h buf /\ live h z /\ disjoint buf z /\ disjoint out z /\ disjoint out buf /\ F51.mul_inv_t h (gsub buf 10ul 5ul) /\ F51.felem_fits h (gsub buf 5ul 5ul) (1, 2, 1, 1, 1) /\ F51.fevalh h (gsub buf 5ul 5ul) == CI.pow (F51.fevalh h z) 1267650600228228275596796362752 /\ F51.fevalh h (gsub buf 10ul 5ul) == CI.pow (F51.fevalh h z) 1125899906842623 /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc buf |+| loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == CI.pow (F51.fevalh h0 z) 7237005577332262213973186563042994240829374041602535252466099000494570602494 ) let crecip_2 out buf z = let a = sub buf 0ul 5ul in let t0 = sub buf 5ul 5ul in let b = sub buf 10ul 5ul in let c = sub buf 15ul 5ul in let h0 = ST.get() in (**) assert_norm (pow2 1 == 2); fsquare_times a z 1ul; // a == z ** 2; fmul c t0 b; // c == z ** 1267650600228229401496703205375 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1267650600228228275596796362752 1125899906842623; fsquare_times t0 c 100ul; // t0 == z ** 1606938044258990275541962092339894951921974764381296132096000 (**) assert_norm (pow2 100 = 1267650600228229401496703205376); (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1267650600228229401496703205375 1267650600228229401496703205376; fmul t0 t0 c; // t0 == z ** 1606938044258990275541962092341162602522202993782792835301375 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1606938044258990275541962092339894951921974764381296132096000 1267650600228229401496703205375; (**) assert_norm (pow2 50 == 1125899906842624); fsquare_times_inplace t0 50ul; // t0 == z ** 1809251394333065553493296640760748560207343510400633813116523624223735808000 (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1606938044258990275541962092341162602522202993782792835301375 1125899906842624; fmul t0 t0 b; // t0 == z ** 1809251394333065553493296640760748560207343510400633813116524750123642650623 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1809251394333065553493296640760748560207343510400633813116523624223735808000 1125899906842623; (**) assert_norm (pow2 2 == 4); fsquare_times_inplace t0 2ul; // t0 == z ** 7237005577332262213973186563042994240829374041602535252466099000494570602492 (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1809251394333065553493296640760748560207343510400633813116524750123642650623 4; fmul out t0 a; (**) CI.lemma_pow_add (F51.fevalh h0 z) 7237005577332262213973186563042994240829374041602535252466099000494570602492 2 val pow2_252m2: out:felem -> z:felem -> Stack unit (requires fun h -> live h out /\ live h z /\ disjoint out z /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == F51.fevalh h0 z `SC.fpow` ((SC.prime + 3) / 8) ) [@CInline]
false
false
Hacl.Impl.Ed25519.Pow2_252m2.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 500, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pow2_252m2: out:felem -> z:felem -> Stack unit (requires fun h -> live h out /\ live h z /\ disjoint out z /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == F51.fevalh h0 z `SC.fpow` ((SC.prime + 3) / 8) )
[]
Hacl.Impl.Ed25519.Pow2_252m2.pow2_252m2
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.Pow2_252m2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Hacl.Bignum25519.felem -> z: Hacl.Bignum25519.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 13, "end_line": 138, "start_col": 2, "start_line": 133 }
FStar.HyperStack.ST.Stack
val crecip_2: out:felem -> buf:lbuffer uint64 20ul -> z:felem -> Stack unit (requires fun h -> live h out /\ live h buf /\ live h z /\ disjoint buf z /\ disjoint out z /\ disjoint out buf /\ F51.mul_inv_t h (gsub buf 10ul 5ul) /\ F51.felem_fits h (gsub buf 5ul 5ul) (1, 2, 1, 1, 1) /\ F51.fevalh h (gsub buf 5ul 5ul) == CI.pow (F51.fevalh h z) 1267650600228228275596796362752 /\ F51.fevalh h (gsub buf 10ul 5ul) == CI.pow (F51.fevalh h z) 1125899906842623 /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc buf |+| loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == CI.pow (F51.fevalh h0 z) 7237005577332262213973186563042994240829374041602535252466099000494570602494 )
[ { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Finv", "short_module": "CI" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crecip_2 out buf z = let a = sub buf 0ul 5ul in let t0 = sub buf 5ul 5ul in let b = sub buf 10ul 5ul in let c = sub buf 15ul 5ul in let h0 = ST.get() in (**) assert_norm (pow2 1 == 2); fsquare_times a z 1ul; // a == z ** 2; fmul c t0 b; // c == z ** 1267650600228229401496703205375 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1267650600228228275596796362752 1125899906842623; fsquare_times t0 c 100ul; // t0 == z ** 1606938044258990275541962092339894951921974764381296132096000 (**) assert_norm (pow2 100 = 1267650600228229401496703205376); (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1267650600228229401496703205375 1267650600228229401496703205376; fmul t0 t0 c; // t0 == z ** 1606938044258990275541962092341162602522202993782792835301375 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1606938044258990275541962092339894951921974764381296132096000 1267650600228229401496703205375; (**) assert_norm (pow2 50 == 1125899906842624); fsquare_times_inplace t0 50ul; // t0 == z ** 1809251394333065553493296640760748560207343510400633813116523624223735808000 (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1606938044258990275541962092341162602522202993782792835301375 1125899906842624; fmul t0 t0 b; // t0 == z ** 1809251394333065553493296640760748560207343510400633813116524750123642650623 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1809251394333065553493296640760748560207343510400633813116523624223735808000 1125899906842623; (**) assert_norm (pow2 2 == 4); fsquare_times_inplace t0 2ul; // t0 == z ** 7237005577332262213973186563042994240829374041602535252466099000494570602492 (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1809251394333065553493296640760748560207343510400633813116524750123642650623 4; fmul out t0 a; (**) CI.lemma_pow_add (F51.fevalh h0 z) 7237005577332262213973186563042994240829374041602535252466099000494570602492 2
val crecip_2: out:felem -> buf:lbuffer uint64 20ul -> z:felem -> Stack unit (requires fun h -> live h out /\ live h buf /\ live h z /\ disjoint buf z /\ disjoint out z /\ disjoint out buf /\ F51.mul_inv_t h (gsub buf 10ul 5ul) /\ F51.felem_fits h (gsub buf 5ul 5ul) (1, 2, 1, 1, 1) /\ F51.fevalh h (gsub buf 5ul 5ul) == CI.pow (F51.fevalh h z) 1267650600228228275596796362752 /\ F51.fevalh h (gsub buf 10ul 5ul) == CI.pow (F51.fevalh h z) 1125899906842623 /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc buf |+| loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == CI.pow (F51.fevalh h0 z) 7237005577332262213973186563042994240829374041602535252466099000494570602494 ) let crecip_2 out buf z =
true
null
false
let a = sub buf 0ul 5ul in let t0 = sub buf 5ul 5ul in let b = sub buf 10ul 5ul in let c = sub buf 15ul 5ul in let h0 = ST.get () in assert_norm (pow2 1 == 2); fsquare_times a z 1ul; fmul c t0 b; CI.lemma_pow_add (F51.fevalh h0 z) 1267650600228228275596796362752 1125899906842623; fsquare_times t0 c 100ul; assert_norm (pow2 100 = 1267650600228229401496703205376); CI.lemma_pow_mul (F51.fevalh h0 z) 1267650600228229401496703205375 1267650600228229401496703205376; fmul t0 t0 c; CI.lemma_pow_add (F51.fevalh h0 z) 1606938044258990275541962092339894951921974764381296132096000 1267650600228229401496703205375; assert_norm (pow2 50 == 1125899906842624); fsquare_times_inplace t0 50ul; CI.lemma_pow_mul (F51.fevalh h0 z) 1606938044258990275541962092341162602522202993782792835301375 1125899906842624; fmul t0 t0 b; CI.lemma_pow_add (F51.fevalh h0 z) 1809251394333065553493296640760748560207343510400633813116523624223735808000 1125899906842623; assert_norm (pow2 2 == 4); fsquare_times_inplace t0 2ul; CI.lemma_pow_mul (F51.fevalh h0 z) 1809251394333065553493296640760748560207343510400633813116524750123642650623 4; fmul out t0 a; CI.lemma_pow_add (F51.fevalh h0 z) 7237005577332262213973186563042994240829374041602535252466099000494570602492 2
{ "checked_file": "Hacl.Impl.Ed25519.Pow2_252m2.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Finv.fst.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.Pow2_252m2.fst" }
[]
[ "Hacl.Bignum25519.felem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Hacl.Spec.Curve25519.Finv.lemma_pow_add", "Hacl.Impl.Ed25519.Field51.fevalh", "Prims.unit", "Hacl.Bignum25519.fmul", "Hacl.Spec.Curve25519.Finv.lemma_pow_mul", "Hacl.Bignum25519.fsquare_times_inplace", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.pow2", "Prims.b2t", "Prims.op_Equality", "Hacl.Bignum25519.fsquare_times", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub" ]
[]
module Hacl.Impl.Ed25519.Pow2_252m2 open FStar.HyperStack.All module ST = FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module SC = Spec.Curve25519 module CI = Hacl.Spec.Curve25519.Finv #set-options "--z3rlimit 500 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract val crecip_1: out:felem -> buf:lbuffer uint64 20ul -> z:felem -> Stack unit (requires fun h -> live h out /\ live h buf /\ live h z /\ disjoint buf z /\ disjoint out z /\ disjoint out buf /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc buf) h0 h1 /\ F51.mul_inv_t h1 (gsub buf 10ul 5ul) /\ F51.felem_fits h1 (gsub buf 5ul 5ul) (1, 2, 1, 1, 1) /\ F51.fevalh h1 (gsub buf 5ul 5ul) == CI.pow (F51.fevalh h0 z) 1267650600228228275596796362752 /\ F51.fevalh h1 (gsub buf 10ul 5ul) == CI.pow (F51.fevalh h0 z) 1125899906842623 ) let crecip_1 out buf z = let a = sub buf 0ul 5ul in let t0 = sub buf 5ul 5ul in let b = sub buf 10ul 5ul in let c = sub buf 15ul 5ul in (**) let h0 = ST.get() in fsquare_times a z 1ul; // a = z ** (2 ** 1) == z ** 2 (**) assert_norm (pow2 1 == 2); fsquare_times t0 a 2ul; // t0 == a ** (2 ** 2) == (z ** 2) ** 4 == z ** 8 (**) CI.lemma_pow_mul (F51.fevalh h0 z) 2 4; (**) assert_norm (pow2 2 == 4); fmul b t0 z; // b == z0 ** 9 (**) CI.lemma_pow_one (F51.fevalh h0 z); (**) CI.lemma_pow_add (F51.fevalh h0 z) 8 1; fmul a b a; // a == b * a == z ** 11 (**) CI.lemma_pow_add (F51.fevalh h0 z) 9 2; fsquare_times t0 a 1ul; // t0 == a ** 2 == z ** 22 (**) CI.lemma_pow_mul (F51.fevalh h0 z) 11 2; fmul b t0 b; // b == z ** 31 (**) CI.lemma_pow_add (F51.fevalh h0 z) 22 9; fsquare_times t0 b 5ul; // t0 == b ** (2 ** 5) == z ** 992 (**) assert_norm (pow2 5 == 32); (**) CI.lemma_pow_mul (F51.fevalh h0 z) 31 32; fmul b t0 b; // b == t0 * b == z ** 1023 (**) CI.lemma_pow_add (F51.fevalh h0 z) 992 31; fsquare_times t0 b 10ul; // t0 = b ** (2 ** 1024) == z ** 1047552 (**) assert_norm (pow2 10 == 1024); (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1023 1024; fmul c t0 b; // c == z ** 1048575 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1047552 1023; fsquare_times t0 c 20ul; // t0 == c ** (2 ** 20) == 1099510579200 (**) assert_norm (pow2 20 == 1048576); (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1048575 1048576; fmul t0 t0 c; // t0 == z ** 1099511627775 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1099510579200 1048575; fsquare_times_inplace t0 10ul; // t0 == z ** 1125899906841600 (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1099511627775 1024; fmul b t0 b; // b == z ** 1125899906842623 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1125899906841600 1023; fsquare_times t0 b 50ul; // t0 == z ** 1267650600228228275596796362752; (**) assert_norm (pow2 50 = 1125899906842624); (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1125899906842623 1125899906842624 inline_for_extraction noextract val crecip_2: out:felem -> buf:lbuffer uint64 20ul -> z:felem -> Stack unit (requires fun h -> live h out /\ live h buf /\ live h z /\ disjoint buf z /\ disjoint out z /\ disjoint out buf /\ F51.mul_inv_t h (gsub buf 10ul 5ul) /\ F51.felem_fits h (gsub buf 5ul 5ul) (1, 2, 1, 1, 1) /\ F51.fevalh h (gsub buf 5ul 5ul) == CI.pow (F51.fevalh h z) 1267650600228228275596796362752 /\ F51.fevalh h (gsub buf 10ul 5ul) == CI.pow (F51.fevalh h z) 1125899906842623 /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc buf |+| loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == CI.pow (F51.fevalh h0 z) 7237005577332262213973186563042994240829374041602535252466099000494570602494
false
false
Hacl.Impl.Ed25519.Pow2_252m2.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 500, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crecip_2: out:felem -> buf:lbuffer uint64 20ul -> z:felem -> Stack unit (requires fun h -> live h out /\ live h buf /\ live h z /\ disjoint buf z /\ disjoint out z /\ disjoint out buf /\ F51.mul_inv_t h (gsub buf 10ul 5ul) /\ F51.felem_fits h (gsub buf 5ul 5ul) (1, 2, 1, 1, 1) /\ F51.fevalh h (gsub buf 5ul 5ul) == CI.pow (F51.fevalh h z) 1267650600228228275596796362752 /\ F51.fevalh h (gsub buf 10ul 5ul) == CI.pow (F51.fevalh h z) 1125899906842623 /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc buf |+| loc out) h0 h1 /\ F51.mul_inv_t h1 out /\ F51.fevalh h1 out == CI.pow (F51.fevalh h0 z) 7237005577332262213973186563042994240829374041602535252466099000494570602494 )
[]
Hacl.Impl.Ed25519.Pow2_252m2.crecip_2
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.Pow2_252m2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Hacl.Bignum25519.felem -> buf: Lib.Buffer.lbuffer Lib.IntTypes.uint64 20ul -> z: Hacl.Bignum25519.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 120, "end_line": 120, "start_col": 24, "start_line": 96 }
FStar.HyperStack.ST.Stack
val crecip_1: out:felem -> buf:lbuffer uint64 20ul -> z:felem -> Stack unit (requires fun h -> live h out /\ live h buf /\ live h z /\ disjoint buf z /\ disjoint out z /\ disjoint out buf /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc buf) h0 h1 /\ F51.mul_inv_t h1 (gsub buf 10ul 5ul) /\ F51.felem_fits h1 (gsub buf 5ul 5ul) (1, 2, 1, 1, 1) /\ F51.fevalh h1 (gsub buf 5ul 5ul) == CI.pow (F51.fevalh h0 z) 1267650600228228275596796362752 /\ F51.fevalh h1 (gsub buf 10ul 5ul) == CI.pow (F51.fevalh h0 z) 1125899906842623 )
[ { "abbrev": true, "full_module": "Hacl.Spec.Curve25519.Finv", "short_module": "CI" }, { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crecip_1 out buf z = let a = sub buf 0ul 5ul in let t0 = sub buf 5ul 5ul in let b = sub buf 10ul 5ul in let c = sub buf 15ul 5ul in (**) let h0 = ST.get() in fsquare_times a z 1ul; // a = z ** (2 ** 1) == z ** 2 (**) assert_norm (pow2 1 == 2); fsquare_times t0 a 2ul; // t0 == a ** (2 ** 2) == (z ** 2) ** 4 == z ** 8 (**) CI.lemma_pow_mul (F51.fevalh h0 z) 2 4; (**) assert_norm (pow2 2 == 4); fmul b t0 z; // b == z0 ** 9 (**) CI.lemma_pow_one (F51.fevalh h0 z); (**) CI.lemma_pow_add (F51.fevalh h0 z) 8 1; fmul a b a; // a == b * a == z ** 11 (**) CI.lemma_pow_add (F51.fevalh h0 z) 9 2; fsquare_times t0 a 1ul; // t0 == a ** 2 == z ** 22 (**) CI.lemma_pow_mul (F51.fevalh h0 z) 11 2; fmul b t0 b; // b == z ** 31 (**) CI.lemma_pow_add (F51.fevalh h0 z) 22 9; fsquare_times t0 b 5ul; // t0 == b ** (2 ** 5) == z ** 992 (**) assert_norm (pow2 5 == 32); (**) CI.lemma_pow_mul (F51.fevalh h0 z) 31 32; fmul b t0 b; // b == t0 * b == z ** 1023 (**) CI.lemma_pow_add (F51.fevalh h0 z) 992 31; fsquare_times t0 b 10ul; // t0 = b ** (2 ** 1024) == z ** 1047552 (**) assert_norm (pow2 10 == 1024); (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1023 1024; fmul c t0 b; // c == z ** 1048575 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1047552 1023; fsquare_times t0 c 20ul; // t0 == c ** (2 ** 20) == 1099510579200 (**) assert_norm (pow2 20 == 1048576); (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1048575 1048576; fmul t0 t0 c; // t0 == z ** 1099511627775 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1099510579200 1048575; fsquare_times_inplace t0 10ul; // t0 == z ** 1125899906841600 (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1099511627775 1024; fmul b t0 b; // b == z ** 1125899906842623 (**) CI.lemma_pow_add (F51.fevalh h0 z) 1125899906841600 1023; fsquare_times t0 b 50ul; // t0 == z ** 1267650600228228275596796362752; (**) assert_norm (pow2 50 = 1125899906842624); (**) CI.lemma_pow_mul (F51.fevalh h0 z) 1125899906842623 1125899906842624
val crecip_1: out:felem -> buf:lbuffer uint64 20ul -> z:felem -> Stack unit (requires fun h -> live h out /\ live h buf /\ live h z /\ disjoint buf z /\ disjoint out z /\ disjoint out buf /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc buf) h0 h1 /\ F51.mul_inv_t h1 (gsub buf 10ul 5ul) /\ F51.felem_fits h1 (gsub buf 5ul 5ul) (1, 2, 1, 1, 1) /\ F51.fevalh h1 (gsub buf 5ul 5ul) == CI.pow (F51.fevalh h0 z) 1267650600228228275596796362752 /\ F51.fevalh h1 (gsub buf 10ul 5ul) == CI.pow (F51.fevalh h0 z) 1125899906842623 ) let crecip_1 out buf z =
true
null
false
let a = sub buf 0ul 5ul in let t0 = sub buf 5ul 5ul in let b = sub buf 10ul 5ul in let c = sub buf 15ul 5ul in let h0 = ST.get () in fsquare_times a z 1ul; assert_norm (pow2 1 == 2); fsquare_times t0 a 2ul; CI.lemma_pow_mul (F51.fevalh h0 z) 2 4; assert_norm (pow2 2 == 4); fmul b t0 z; CI.lemma_pow_one (F51.fevalh h0 z); CI.lemma_pow_add (F51.fevalh h0 z) 8 1; fmul a b a; CI.lemma_pow_add (F51.fevalh h0 z) 9 2; fsquare_times t0 a 1ul; CI.lemma_pow_mul (F51.fevalh h0 z) 11 2; fmul b t0 b; CI.lemma_pow_add (F51.fevalh h0 z) 22 9; fsquare_times t0 b 5ul; assert_norm (pow2 5 == 32); CI.lemma_pow_mul (F51.fevalh h0 z) 31 32; fmul b t0 b; CI.lemma_pow_add (F51.fevalh h0 z) 992 31; fsquare_times t0 b 10ul; assert_norm (pow2 10 == 1024); CI.lemma_pow_mul (F51.fevalh h0 z) 1023 1024; fmul c t0 b; CI.lemma_pow_add (F51.fevalh h0 z) 1047552 1023; fsquare_times t0 c 20ul; assert_norm (pow2 20 == 1048576); CI.lemma_pow_mul (F51.fevalh h0 z) 1048575 1048576; fmul t0 t0 c; CI.lemma_pow_add (F51.fevalh h0 z) 1099510579200 1048575; fsquare_times_inplace t0 10ul; CI.lemma_pow_mul (F51.fevalh h0 z) 1099511627775 1024; fmul b t0 b; CI.lemma_pow_add (F51.fevalh h0 z) 1125899906841600 1023; fsquare_times t0 b 50ul; assert_norm (pow2 50 = 1125899906842624); CI.lemma_pow_mul (F51.fevalh h0 z) 1125899906842623 1125899906842624
{ "checked_file": "Hacl.Impl.Ed25519.Pow2_252m2.fst.checked", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Curve25519.Finv.fst.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.Pow2_252m2.fst" }
[]
[ "Hacl.Bignum25519.felem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Hacl.Spec.Curve25519.Finv.lemma_pow_mul", "Hacl.Impl.Ed25519.Field51.fevalh", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.pow2", "Hacl.Bignum25519.fsquare_times", "Hacl.Spec.Curve25519.Finv.lemma_pow_add", "Hacl.Bignum25519.fmul", "Hacl.Bignum25519.fsquare_times_inplace", "Prims.eq2", "Hacl.Spec.Curve25519.Finv.lemma_pow_one", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub" ]
[]
module Hacl.Impl.Ed25519.Pow2_252m2 open FStar.HyperStack.All module ST = FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module SC = Spec.Curve25519 module CI = Hacl.Spec.Curve25519.Finv #set-options "--z3rlimit 500 --max_fuel 0 --max_ifuel 0" inline_for_extraction noextract val crecip_1: out:felem -> buf:lbuffer uint64 20ul -> z:felem -> Stack unit (requires fun h -> live h out /\ live h buf /\ live h z /\ disjoint buf z /\ disjoint out z /\ disjoint out buf /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc buf) h0 h1 /\ F51.mul_inv_t h1 (gsub buf 10ul 5ul) /\ F51.felem_fits h1 (gsub buf 5ul 5ul) (1, 2, 1, 1, 1) /\ F51.fevalh h1 (gsub buf 5ul 5ul) == CI.pow (F51.fevalh h0 z) 1267650600228228275596796362752 /\ F51.fevalh h1 (gsub buf 10ul 5ul) == CI.pow (F51.fevalh h0 z) 1125899906842623
false
false
Hacl.Impl.Ed25519.Pow2_252m2.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 500, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crecip_1: out:felem -> buf:lbuffer uint64 20ul -> z:felem -> Stack unit (requires fun h -> live h out /\ live h buf /\ live h z /\ disjoint buf z /\ disjoint out z /\ disjoint out buf /\ F51.mul_inv_t h z) (ensures fun h0 _ h1 -> modifies (loc buf) h0 h1 /\ F51.mul_inv_t h1 (gsub buf 10ul 5ul) /\ F51.felem_fits h1 (gsub buf 5ul 5ul) (1, 2, 1, 1, 1) /\ F51.fevalh h1 (gsub buf 5ul 5ul) == CI.pow (F51.fevalh h0 z) 1267650600228228275596796362752 /\ F51.fevalh h1 (gsub buf 10ul 5ul) == CI.pow (F51.fevalh h0 z) 1125899906842623 )
[]
Hacl.Impl.Ed25519.Pow2_252m2.crecip_1
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.Pow2_252m2.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Hacl.Bignum25519.felem -> buf: Lib.Buffer.lbuffer Lib.IntTypes.uint64 20ul -> z: Hacl.Bignum25519.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 75, "end_line": 75, "start_col": 24, "start_line": 34 }
Prims.Tot
val read_false:leaf_reader parse_false
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called"
val read_false:leaf_reader parse_false let read_false:leaf_reader parse_false =
false
null
false
fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called"
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "LowStar.Failure.failwith", "Prims.squash", "Prims.l_False" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret ()
false
true
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val read_false:leaf_reader parse_false
[]
LowParse.Low.Combinators.read_false
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.Low.Base.leaf_reader LowParse.Spec.Combinators.parse_false
{ "end_col": 61, "end_line": 454, "start_col": 43, "start_line": 453 }
Prims.Tot
val clens_synth (#t1 #t2: Type) (f: (t1 -> GTot t2)) (g: (t2 -> GTot t1)) : Tot (clens t1 t2)
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 clens_synth (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t1 t2) = { clens_cond = (fun (x: t1) -> True); clens_get = (fun (x: t1) -> f x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) }
val clens_synth (#t1 #t2: Type) (f: (t1 -> GTot t2)) (g: (t2 -> GTot t1)) : Tot (clens t1 t2) let clens_synth (#t1 #t2: Type) (f: (t1 -> GTot t2)) (g: (t2 -> GTot t1)) : Tot (clens t1 t2) =
false
null
false
{ clens_cond = (fun (x: t1) -> True); clens_get = (fun (x: t1) -> f x) }
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Low.Base.Spec.Mkclens", "Prims.l_True", "LowParse.Low.Base.Spec.clens" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" 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 _ #_ #_ _ _ -> 0ul inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun _ #_ #_ _ _ -> 0ul // dummy let valid_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) = valid_facts (p ()) h input pos; valid_facts (lift_parser p) h input pos inline_for_extraction let validate_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: validator #k #t (p ())) : Tot (validator #k #t (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input (uint64_to_uint32 pos); v input pos inline_for_extraction let jump_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: jumper (p ())) : Tot (jumper (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input pos; v input pos let clens_synth (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t1 t2)
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val clens_synth (#t1 #t2: Type) (f: (t1 -> GTot t2)) (g: (t2 -> GTot t1)) : Tot (clens t1 t2)
[]
LowParse.Low.Combinators.clens_synth
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
f: (_: t1 -> Prims.GTot t2) -> g: (_: t2 -> Prims.GTot t1) -> LowParse.Low.Base.Spec.clens t1 t2
{ "end_col": 35, "end_line": 519, "start_col": 2, "start_line": 518 }
Prims.Tot
val validate_empty: Prims.unit -> Tot (validator parse_empty)
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 validate_empty () : Tot (validator parse_empty) = validate_ret ()
val validate_empty: Prims.unit -> Tot (validator parse_empty) let validate_empty () : Tot (validator parse_empty) =
false
null
false
validate_ret ()
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "Prims.unit", "LowParse.Low.Combinators.validate_ret", "LowParse.Low.Base.validator", "LowParse.Spec.Combinators.parse_ret_kind", "LowParse.Spec.Combinators.parse_empty" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction
false
true
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_empty: Prims.unit -> Tot (validator parse_empty)
[]
LowParse.Low.Combinators.validate_empty
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
_: Prims.unit -> LowParse.Low.Base.validator LowParse.Spec.Combinators.parse_empty
{ "end_col": 17, "end_line": 421, "start_col": 2, "start_line": 421 }
Prims.Tot
val read_empty:leaf_reader parse_empty
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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_empty : leaf_reader parse_empty = read_ret ()
val read_empty:leaf_reader parse_empty let read_empty:leaf_reader parse_empty =
false
null
false
read_ret ()
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Low.Combinators.read_ret", "Prims.unit" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v
false
true
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val read_empty:leaf_reader parse_empty
[]
LowParse.Low.Combinators.read_empty
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.Low.Base.leaf_reader LowParse.Spec.Combinators.parse_empty
{ "end_col": 54, "end_line": 450, "start_col": 43, "start_line": 450 }
Prims.Tot
val gaccessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k': parser_kind) (#t': Type) (#p': parser k' t') (#cl: clens t1 t') (g: gaccessor p1 p' cl) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (gaccessor (p1 `nondep_then` p2) p' ((clens_fst _ _) `clens_compose` cl))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 gaccessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (g: gaccessor p1 p' cl) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (gaccessor (p1 `nondep_then` p2) p' (clens_fst _ _ `clens_compose` cl)) = gaccessor_fst p1 u p2 `gaccessor_compose` g
val gaccessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k': parser_kind) (#t': Type) (#p': parser k' t') (#cl: clens t1 t') (g: gaccessor p1 p' cl) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (gaccessor (p1 `nondep_then` p2) p' ((clens_fst _ _) `clens_compose` cl)) let gaccessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k': parser_kind) (#t': Type) (#p': parser k' t') (#cl: clens t1 t') (g: gaccessor p1 p' cl) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (gaccessor (p1 `nondep_then` p2) p' ((clens_fst _ _) `clens_compose` cl)) =
false
null
false
(gaccessor_fst p1 u p2) `gaccessor_compose` g
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Low.Base.Spec.clens", "LowParse.Low.Base.Spec.gaccessor", "Prims.squash", "Prims.unit", "LowParse.Low.Base.Spec.gaccessor_compose", "LowParse.Spec.Combinators.and_then_kind", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Combinators.nondep_then", "LowParse.Low.Combinators.clens_fst", "LowParse.Low.Combinators.gaccessor_fst", "LowParse.Low.Base.Spec.clens_compose" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" 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 _ #_ #_ _ _ -> 0ul inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun _ #_ #_ _ _ -> 0ul // dummy let valid_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) = valid_facts (p ()) h input pos; valid_facts (lift_parser p) h input pos inline_for_extraction let validate_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: validator #k #t (p ())) : Tot (validator #k #t (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input (uint64_to_uint32 pos); v input pos inline_for_extraction let jump_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: jumper (p ())) : Tot (jumper (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input pos; v input pos let clens_synth (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t1 t2) = { clens_cond = (fun (x: t1) -> True); clens_get = (fun (x: t1) -> f x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (parse_synth p1 f) p1 (clens_synth g f) input pos')) = synth_injective_synth_inverse_synth_inverse_recip f g (); parse_synth_eq p1 f input; 0 val gaccessor_synth (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor (parse_synth p1 f) p1 (clens_synth g f)) val gaccessor_synth_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth p1 f g u input == gaccessor_synth' p1 f g u input) inline_for_extraction let accessor_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_eq p1 f g u); slice_access_eq h (gaccessor_synth p1 f g u) input pos in pos let clens_synth_inv (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t2 t1) = { clens_cond = (fun (x: t2) -> True); clens_get = (fun (x: t2) -> g x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth_inv' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' p1 (parse_synth p1 f) (clens_synth_inv g f) input pos')) = parse_synth_eq p1 f input; 0 val gaccessor_synth_inv (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor p1 (parse_synth p1 f) (clens_synth_inv g f)) val gaccessor_synth_inv_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth_inv p1 f g u input == gaccessor_synth_inv' p1 f g u input) inline_for_extraction let accessor_synth_inv (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth_inv p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_inv_eq p1 f g u); slice_access_eq h (gaccessor_synth_inv p1 f g u) input pos in pos let clens_fst (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t1) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = fst; (* clens_put = (fun x y -> (y, snd x)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let clens_snd (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t2) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = snd; (* clens_put = (fun x y -> (fst x, y)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let gaccessor_fst' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires True) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p1 (clens_fst _ _) input pos')) = nondep_then_eq p1 p2 input; 0 [@"opaque_to_smt"] let gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p1 (clens_fst _ _)) = gaccessor_prop_equiv (p1 `nondep_then` p2) p1 (clens_fst _ _) (gaccessor_fst' p1 sq p2); gaccessor_fst' p1 sq p2 let gaccessor_fst_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_fst p1 sq p2 input == gaccessor_fst' p1 sq p2 input) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2 input) let gaccessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (g: gaccessor p1 p' cl) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit)
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k': parser_kind) (#t': Type) (#p': parser k' t') (#cl: clens t1 t') (g: gaccessor p1 p' cl) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (gaccessor (p1 `nondep_then` p2) p' ((clens_fst _ _) `clens_compose` cl))
[]
LowParse.Low.Combinators.gaccessor_fst_then
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
g: LowParse.Low.Base.Spec.gaccessor p1 p' cl -> p2: LowParse.Spec.Base.parser k2 t2 -> u276: Prims.squash Prims.unit -> LowParse.Low.Base.Spec.gaccessor (LowParse.Spec.Combinators.nondep_then p1 p2) p' (LowParse.Low.Base.Spec.clens_compose (LowParse.Low.Combinators.clens_fst t1 t2) cl)
{ "end_col": 45, "end_line": 741, "start_col": 2, "start_line": 741 }
Prims.Tot
val jump_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (v: (k: kt1 -> Tot (jumper (p k)))) (k: kt2) : Tot (jumper (p (f k)))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 jump_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (v: ((k: kt1) -> Tot (jumper (p k)))) (k: kt2) : Tot (jumper (p (f k))) = fun #rrel #rel input pos -> v (f k) input pos
val jump_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (v: (k: kt1 -> Tot (jumper (p k)))) (k: kt2) : Tot (jumper (p (f k))) let jump_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (v: (k: kt1 -> Tot (jumper (p k)))) (k: kt2) : Tot (jumper (p (f k))) =
false
null
false
fun #rrel #rel input pos -> v (f k) input pos
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Low.Base.jumper", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" 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 _ #_ #_ _ _ -> 0ul inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun _ #_ #_ _ _ -> 0ul // dummy let valid_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) = valid_facts (p ()) h input pos; valid_facts (lift_parser p) h input pos inline_for_extraction let validate_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: validator #k #t (p ())) : Tot (validator #k #t (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input (uint64_to_uint32 pos); v input pos inline_for_extraction let jump_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: jumper (p ())) : Tot (jumper (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input pos; v input pos let clens_synth (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t1 t2) = { clens_cond = (fun (x: t1) -> True); clens_get = (fun (x: t1) -> f x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (parse_synth p1 f) p1 (clens_synth g f) input pos')) = synth_injective_synth_inverse_synth_inverse_recip f g (); parse_synth_eq p1 f input; 0 val gaccessor_synth (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor (parse_synth p1 f) p1 (clens_synth g f)) val gaccessor_synth_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth p1 f g u input == gaccessor_synth' p1 f g u input) inline_for_extraction let accessor_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_eq p1 f g u); slice_access_eq h (gaccessor_synth p1 f g u) input pos in pos let clens_synth_inv (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t2 t1) = { clens_cond = (fun (x: t2) -> True); clens_get = (fun (x: t2) -> g x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth_inv' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' p1 (parse_synth p1 f) (clens_synth_inv g f) input pos')) = parse_synth_eq p1 f input; 0 val gaccessor_synth_inv (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor p1 (parse_synth p1 f) (clens_synth_inv g f)) val gaccessor_synth_inv_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth_inv p1 f g u input == gaccessor_synth_inv' p1 f g u input) inline_for_extraction let accessor_synth_inv (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth_inv p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_inv_eq p1 f g u); slice_access_eq h (gaccessor_synth_inv p1 f g u) input pos in pos let clens_fst (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t1) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = fst; (* clens_put = (fun x y -> (y, snd x)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let clens_snd (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t2) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = snd; (* clens_put = (fun x y -> (fst x, y)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let gaccessor_fst' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires True) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p1 (clens_fst _ _) input pos')) = nondep_then_eq p1 p2 input; 0 [@"opaque_to_smt"] let gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p1 (clens_fst _ _)) = gaccessor_prop_equiv (p1 `nondep_then` p2) p1 (clens_fst _ _) (gaccessor_fst' p1 sq p2); gaccessor_fst' p1 sq p2 let gaccessor_fst_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_fst p1 sq p2 input == gaccessor_fst' p1 sq p2 input) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2 input) let gaccessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (g: gaccessor p1 p' cl) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (gaccessor (p1 `nondep_then` p2) p' (clens_fst _ _ `clens_compose` cl)) = gaccessor_fst p1 u p2 `gaccessor_compose` g let gaccessor_then_fst (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (g: gaccessor p0 (p1 `nondep_then` p2) cl) : Tot (gaccessor p0 p1 (cl `clens_compose` clens_fst _ _)) = g `gaccessor_compose` gaccessor_fst _ () _ let gaccessor_snd' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p2 (clens_snd _ _) input pos')) = nondep_then_eq p1 p2 input; match parse p1 input with | None -> 0 // dummy | Some (_, consumed) -> consumed let gaccessor_snd_injective (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (sl sl' : bytes) : Lemma (requires (gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ injective_precond (p1 `nondep_then` p2) sl sl')) (ensures (gaccessor_snd' p1 p2 sl == gaccessor_snd' p1 p2 sl')) = nondep_then_eq p1 p2 sl; nondep_then_eq p1 p2 sl'; parse_injective p1 sl sl' let gaccessor_snd_no_lookahead (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (sl sl' : bytes) : Lemma (requires ((and_then_kind k1 k2).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ no_lookahead_on_precond (p1 `nondep_then` p2) sl sl')) (ensures (gaccessor_snd' p1 p2 sl == gaccessor_snd' p1 p2 sl')) = nondep_then_eq p1 p2 sl; nondep_then_eq p1 p2 sl' ; parse_strong_prefix (p1 `nondep_then` p2) sl sl'; parse_injective p1 sl sl' ; parse_strong_prefix p1 sl sl' [@"opaque_to_smt"] let gaccessor_snd (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p2 (clens_snd _ _)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_snd_injective p1 p2 x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_snd_no_lookahead p1 p2 x)); gaccessor_prop_equiv (p1 `nondep_then` p2) p2 (clens_snd _ _) (gaccessor_snd' p1 p2); gaccessor_snd' p1 p2 let gaccessor_snd_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_snd p1 p2 input == gaccessor_snd' p1 p2 input) = reveal_opaque (`%gaccessor_snd) (gaccessor_snd p1 p2 input ) let gaccessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (g: gaccessor p0 (p1 `nondep_then` p2) cl) : Tot (gaccessor p0 p2 (cl `clens_compose` clens_snd _ _)) = g `gaccessor_compose` gaccessor_snd _ _ (* let clens_fst_snd_disjoint (t1 t2: Type) : Lemma (clens_disjoint (clens_fst t1 t2) (clens_snd t1 t2)) = clens_disjoint_l_intro (clens_fst t1 t2) (clens_snd t1 t2) (fun x1 x2 -> ()); clens_disjoint_l_intro (clens_snd t1 t2) (clens_fst t1 t2) (fun x1 x2 -> ()) *) (* abstract let gaccessor_fst_snd_disjoint (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash (k1.parser_kind_subkind == Some ParserStrong)) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Lemma (gaccessors_disjoint (gaccessor_fst p1 sq p2) (gaccessor_snd p1 p2)) = // clens_fst_snd_disjoint t1 t2; gaccessors_disjoint_intro (gaccessor_fst p1 sq p2) (gaccessor_snd p1 p2) (* *) (fun x -> ()) *) inline_for_extraction let accessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (accessor (gaccessor_fst p1 sq p2)) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2); fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_fst p1 sq p2) input pos in pos inline_for_extraction let accessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (#g: gaccessor p1 p' cl) (a: accessor g) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (accessor (gaccessor_fst_then g p2 u)) = accessor_compose (accessor_fst p1 u p2) a u inline_for_extraction let accessor_then_fst (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) : Tot (accessor (gaccessor_then_fst g)) = accessor_compose a (accessor_fst p1 () p2) () inline_for_extraction let accessor_snd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (j1: jumper p1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (accessor (gaccessor_snd p1 p2)) = reveal_opaque (`%gaccessor_snd) (gaccessor_snd p1 p2); fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in let res = j1 input pos in [@inline_let] let _ = slice_access_eq h (gaccessor_snd p1 p2) input pos; valid_facts p1 h input pos in res inline_for_extraction let accessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) (j1: jumper p1) : Tot (accessor (gaccessor_then_snd g)) = accessor_compose a (accessor_snd j1 p2) () inline_for_extraction let make_total_constant_size_reader (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' : ((#rrel: _) -> (#rel: _) -> (s: B.mbuffer byte rrel rel) -> (pos: U32.t) -> HST.Stack t (requires (fun h -> B.live h s /\ U32.v pos + sz <= B.length s)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == f (Seq.slice (B.as_seq h s) (U32.v pos) (U32.v pos + sz)) )))) : Tot (leaf_reader (make_total_constant_size_parser sz t f)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (make_total_constant_size_parser sz t f) h sl pos in f' sl.base pos let valid_filter (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t: Type) (p: parser k t) (f: (t -> GTot bool)) (input: slice rrel rel) (pos: U32.t) : Lemma ( (valid (parse_filter p f) h input pos \/ (valid p h input pos /\ f (contents p h input pos))) ==> ( valid p h input pos /\ f (contents p h input pos) == true /\ valid_content_pos (parse_filter p f) h input pos (contents p h input pos) (get_valid_pos p h input pos) )) = valid_facts (parse_filter p f) h input pos; valid_facts p h input pos; if U32.v pos <= U32.v input.len then parse_filter_eq p f (bytes_of_slice_from h input pos) inline_for_extraction let validate_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (v32: validator p) (p32: leaf_reader p) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) : Tot (validator (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input (uint64_to_uint32 pos) in let res = v32 input pos in if is_error res then res else let va = p32 input (uint64_to_uint32 pos) in if not (f' va) then validator_error_generic else res inline_for_extraction let validate_filter_with_error_code (#k: parser_kind) (#t: Type0) (#p: parser k t) (v32: validator p) (p32: leaf_reader p) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) (c: error_code) : Tot (validator (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input (uint64_to_uint32 pos) in let res = v32 input pos in if is_error res then maybe_set_validator_error_pos_and_code res pos c else let va = p32 input (uint64_to_uint32 pos) in if not (f' va) then set_validator_error_pos_and_code validator_error_generic pos c else res inline_for_extraction let validate_filter_ret (#t: Type0) (r: t) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) : Tot (validator (parse_filter (parse_ret r) f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h (parse_ret r) f input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_ret r) h input (uint64_to_uint32 pos) in if not (f' r) then validator_error_generic else pos inline_for_extraction let validate_filter_ret_with_error_code (#t: Type0) (r: t) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) (c: error_code) : Tot (validator (parse_filter (parse_ret r) f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h (parse_ret r) f input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_ret r) h input (uint64_to_uint32 pos) in if not (f' r) then set_validator_error_pos_and_code validator_error_generic pos c else pos inline_for_extraction let jump_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (j: jumper p) (f: (t -> GTot bool)) : Tot (jumper (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in j input pos inline_for_extraction let read_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> GTot bool)) : Tot (leaf_reader (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in (p32 input pos <: (res: t { f res == true } )) // FIXME: WHY WHY WHY do we need this coercion? inline_for_extraction let write_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: leaf_writer_strong s) (f: (t -> GTot bool)) : Tot (leaf_writer_strong (serialize_filter s f)) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialized_length_eq s x in [@inline_let] let _ = serialized_length_eq (serialize_filter s f) x in let res = s32 x input pos in let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in res inline_for_extraction let write_filter_weak (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: leaf_writer_weak s) (f: (t -> GTot bool)) : Tot (leaf_writer_weak (serialize_filter s f)) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialized_length_eq s x in [@inline_let] let _ = serialized_length_eq (serialize_filter s f) x in let res = s32 x input pos in let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in 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 (serialize_filter s f)) = fun x #rrel #rel input pos -> s32 x input pos inline_for_extraction let read_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' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in let res = p1' input pos in f2' res <: t2 // FIXME: WHY WHY WHY this coercion AND the separate let binding? inline_for_extraction let read_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = read_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let read_inline_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' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in [@inline_let] let f2'' (x: t1) : HST.Stack t2 (requires (fun _ -> True)) (ensures (fun h y h' -> h == h' /\ y == f2 x)) = f2' x in // FIXME: WHY WHY WHY do I need this stateful function here? why can't I directly use f2' ? f2'' (p1' input pos) inline_for_extraction let read_inline_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = read_inline_synth p1 f2 (fun x -> f2 x) p1' () inline_for_extraction let write_synth (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (#s1: serializer p1) (s1' : leaf_writer_strong s1) (#t2: Type) (f2: t1 -> GTot t2) (g1: t2 -> GTot t1) (g1' : (x2: t2) -> Tot (x1: t1 { x1 == g1 x2 } )) (u: squash (synth_injective f2 /\ synth_inverse f2 g1)) : Tot (leaf_writer_strong (serialize_synth p1 f2 s1 g1 ())) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 () x in [@inline_let] let _ = serialized_length_eq (serialize_synth p1 f2 s1 g1 ()) x in [@inline_let] let _ = serialized_length_eq s1 (g1 x) in let pos' = s1' (g1' x) input pos in let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in pos' inline_for_extraction let write_synth_weak (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (#s1: serializer p1) (s1' : leaf_writer_weak s1) (#t2: Type) (f2: t1 -> GTot t2) (g1: t2 -> GTot t1) (g1' : (x2: t2) -> Tot (x1: t1 { x1 == g1 x2 } )) (u: squash (synth_injective f2 /\ synth_inverse f2 g1)) : Tot (leaf_writer_weak (serialize_synth p1 f2 s1 g1 ())) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 () x in [@inline_let] let _ = serialized_length_eq (serialize_synth p1 f2 s1 g1 ()) x in [@inline_let] let _ = serialized_length_eq s1 (g1 x) in let pos' = s1' (g1' x) input pos in let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in pos' inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (#s1: serializer p1) (s1' : serializer32 s1) (#t2: Type) (f2: t1 -> GTot t2) (g1: t2 -> GTot t1) (g1' : (x2: t2) -> Tot (x1: t1 { x1 == g1 x2 } )) (u: squash (synth_injective f2 /\ synth_inverse f2 g1)) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 ())) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 () x in s1' (g1' x) input pos (* Special case for vldata and maybe also sum types *) inline_for_extraction let validate_filter_and_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (p1': leaf_reader p1) (f: (t1 -> GTot bool)) (f' : ((x: t1) -> Tot (y: bool { y == f x } ))) (#k2: parser_kind) (#t2: Type) (#p2: ((x: t1 { f x == true} ) -> parser k2 t2)) (v2: ((x1: t1 { f x1 == true } ) -> validator (p2 x1))) (u: unit { and_then_cases_injective p2 }) : Tot (validator (parse_filter p1 f `and_then` p2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = let sinput = bytes_of_slice_from h input (uint64_to_uint32 pos) in valid_facts (parse_filter p1 f `and_then` p2) h input (uint64_to_uint32 pos); and_then_eq (parse_filter p1 f) p2 sinput; parse_filter_eq p1 f sinput; valid_facts p1 h input (uint64_to_uint32 pos) in let res = v1 input pos in if is_error res then res else let va = p1' input (uint64_to_uint32 pos) in if f' va then [@inline_let] let _ = valid_facts (p2 va) h input (uint64_to_uint32 res) in v2 va input res else validator_error_generic inline_for_extraction let validate_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (v2: validator p2) (sq: squash (k1 `is_weaker_than` k2)) : Tot (validator (weaken k1 p2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (weaken k1 p2) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos) in v2 input pos inline_for_extraction let jump_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (v2: jumper p2) (sq: squash (k1 `is_weaker_than` k2)) : Tot (jumper (weaken k1 p2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (weaken k1 p2) h input pos in [@inline_let] let _ = valid_facts p2 h input pos in v2 input pos inline_for_extraction let validate_strengthen (k2: parser_kind) (#k1: parser_kind) (#t: Type) (#p1: parser k1 t) (v1: validator p1) (sq: squash (parser_kind_prop k2 p1)) : Tot (validator (strengthen k2 p1)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (strengthen k2 p1) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p1 h input (uint64_to_uint32 pos) in v1 input pos inline_for_extraction let validate_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (v: ((k: kt1) -> Tot (validator (p k)))) (k: kt2) : Tot (validator (p (f k))) = fun #rrel #rel input pos -> v (f k) input pos inline_for_extraction let jump_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (v: ((k: kt1) -> Tot (jumper (p k)))) (k: kt2)
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (v: (k: kt1 -> Tot (jumper (p k)))) (k: kt2) : Tot (jumper (p (f k)))
[]
LowParse.Low.Combinators.jump_compose_context
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "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)) -> v: (k: kt1 -> LowParse.Low.Base.jumper (p k)) -> k: kt2 -> LowParse.Low.Base.jumper (p (f k))
{ "end_col": 47, "end_line": 1396, "start_col": 2, "start_line": 1396 }
Prims.Tot
val validate_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (v: (k: kt1 -> Tot (validator (p k)))) (k: kt2) : Tot (validator (p (f k)))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 validate_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (v: ((k: kt1) -> Tot (validator (p k)))) (k: kt2) : Tot (validator (p (f k))) = fun #rrel #rel input pos -> v (f k) input pos
val validate_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (v: (k: kt1 -> Tot (validator (p k)))) (k: kt2) : Tot (validator (p (f k))) let validate_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (v: (k: kt1 -> Tot (validator (p k)))) (k: kt2) : Tot (validator (p (f k))) =
false
null
false
fun #rrel #rel input pos -> v (f k) input pos
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Low.Base.validator", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt64.t" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" 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 _ #_ #_ _ _ -> 0ul inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun _ #_ #_ _ _ -> 0ul // dummy let valid_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) = valid_facts (p ()) h input pos; valid_facts (lift_parser p) h input pos inline_for_extraction let validate_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: validator #k #t (p ())) : Tot (validator #k #t (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input (uint64_to_uint32 pos); v input pos inline_for_extraction let jump_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: jumper (p ())) : Tot (jumper (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input pos; v input pos let clens_synth (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t1 t2) = { clens_cond = (fun (x: t1) -> True); clens_get = (fun (x: t1) -> f x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (parse_synth p1 f) p1 (clens_synth g f) input pos')) = synth_injective_synth_inverse_synth_inverse_recip f g (); parse_synth_eq p1 f input; 0 val gaccessor_synth (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor (parse_synth p1 f) p1 (clens_synth g f)) val gaccessor_synth_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth p1 f g u input == gaccessor_synth' p1 f g u input) inline_for_extraction let accessor_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_eq p1 f g u); slice_access_eq h (gaccessor_synth p1 f g u) input pos in pos let clens_synth_inv (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t2 t1) = { clens_cond = (fun (x: t2) -> True); clens_get = (fun (x: t2) -> g x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth_inv' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' p1 (parse_synth p1 f) (clens_synth_inv g f) input pos')) = parse_synth_eq p1 f input; 0 val gaccessor_synth_inv (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor p1 (parse_synth p1 f) (clens_synth_inv g f)) val gaccessor_synth_inv_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth_inv p1 f g u input == gaccessor_synth_inv' p1 f g u input) inline_for_extraction let accessor_synth_inv (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth_inv p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_inv_eq p1 f g u); slice_access_eq h (gaccessor_synth_inv p1 f g u) input pos in pos let clens_fst (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t1) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = fst; (* clens_put = (fun x y -> (y, snd x)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let clens_snd (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t2) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = snd; (* clens_put = (fun x y -> (fst x, y)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let gaccessor_fst' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires True) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p1 (clens_fst _ _) input pos')) = nondep_then_eq p1 p2 input; 0 [@"opaque_to_smt"] let gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p1 (clens_fst _ _)) = gaccessor_prop_equiv (p1 `nondep_then` p2) p1 (clens_fst _ _) (gaccessor_fst' p1 sq p2); gaccessor_fst' p1 sq p2 let gaccessor_fst_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_fst p1 sq p2 input == gaccessor_fst' p1 sq p2 input) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2 input) let gaccessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (g: gaccessor p1 p' cl) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (gaccessor (p1 `nondep_then` p2) p' (clens_fst _ _ `clens_compose` cl)) = gaccessor_fst p1 u p2 `gaccessor_compose` g let gaccessor_then_fst (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (g: gaccessor p0 (p1 `nondep_then` p2) cl) : Tot (gaccessor p0 p1 (cl `clens_compose` clens_fst _ _)) = g `gaccessor_compose` gaccessor_fst _ () _ let gaccessor_snd' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p2 (clens_snd _ _) input pos')) = nondep_then_eq p1 p2 input; match parse p1 input with | None -> 0 // dummy | Some (_, consumed) -> consumed let gaccessor_snd_injective (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (sl sl' : bytes) : Lemma (requires (gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ injective_precond (p1 `nondep_then` p2) sl sl')) (ensures (gaccessor_snd' p1 p2 sl == gaccessor_snd' p1 p2 sl')) = nondep_then_eq p1 p2 sl; nondep_then_eq p1 p2 sl'; parse_injective p1 sl sl' let gaccessor_snd_no_lookahead (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (sl sl' : bytes) : Lemma (requires ((and_then_kind k1 k2).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ no_lookahead_on_precond (p1 `nondep_then` p2) sl sl')) (ensures (gaccessor_snd' p1 p2 sl == gaccessor_snd' p1 p2 sl')) = nondep_then_eq p1 p2 sl; nondep_then_eq p1 p2 sl' ; parse_strong_prefix (p1 `nondep_then` p2) sl sl'; parse_injective p1 sl sl' ; parse_strong_prefix p1 sl sl' [@"opaque_to_smt"] let gaccessor_snd (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p2 (clens_snd _ _)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_snd_injective p1 p2 x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_snd_no_lookahead p1 p2 x)); gaccessor_prop_equiv (p1 `nondep_then` p2) p2 (clens_snd _ _) (gaccessor_snd' p1 p2); gaccessor_snd' p1 p2 let gaccessor_snd_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_snd p1 p2 input == gaccessor_snd' p1 p2 input) = reveal_opaque (`%gaccessor_snd) (gaccessor_snd p1 p2 input ) let gaccessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (g: gaccessor p0 (p1 `nondep_then` p2) cl) : Tot (gaccessor p0 p2 (cl `clens_compose` clens_snd _ _)) = g `gaccessor_compose` gaccessor_snd _ _ (* let clens_fst_snd_disjoint (t1 t2: Type) : Lemma (clens_disjoint (clens_fst t1 t2) (clens_snd t1 t2)) = clens_disjoint_l_intro (clens_fst t1 t2) (clens_snd t1 t2) (fun x1 x2 -> ()); clens_disjoint_l_intro (clens_snd t1 t2) (clens_fst t1 t2) (fun x1 x2 -> ()) *) (* abstract let gaccessor_fst_snd_disjoint (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash (k1.parser_kind_subkind == Some ParserStrong)) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Lemma (gaccessors_disjoint (gaccessor_fst p1 sq p2) (gaccessor_snd p1 p2)) = // clens_fst_snd_disjoint t1 t2; gaccessors_disjoint_intro (gaccessor_fst p1 sq p2) (gaccessor_snd p1 p2) (* *) (fun x -> ()) *) inline_for_extraction let accessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (accessor (gaccessor_fst p1 sq p2)) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2); fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_fst p1 sq p2) input pos in pos inline_for_extraction let accessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (#g: gaccessor p1 p' cl) (a: accessor g) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (accessor (gaccessor_fst_then g p2 u)) = accessor_compose (accessor_fst p1 u p2) a u inline_for_extraction let accessor_then_fst (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) : Tot (accessor (gaccessor_then_fst g)) = accessor_compose a (accessor_fst p1 () p2) () inline_for_extraction let accessor_snd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (j1: jumper p1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (accessor (gaccessor_snd p1 p2)) = reveal_opaque (`%gaccessor_snd) (gaccessor_snd p1 p2); fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in let res = j1 input pos in [@inline_let] let _ = slice_access_eq h (gaccessor_snd p1 p2) input pos; valid_facts p1 h input pos in res inline_for_extraction let accessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) (j1: jumper p1) : Tot (accessor (gaccessor_then_snd g)) = accessor_compose a (accessor_snd j1 p2) () inline_for_extraction let make_total_constant_size_reader (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' : ((#rrel: _) -> (#rel: _) -> (s: B.mbuffer byte rrel rel) -> (pos: U32.t) -> HST.Stack t (requires (fun h -> B.live h s /\ U32.v pos + sz <= B.length s)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == f (Seq.slice (B.as_seq h s) (U32.v pos) (U32.v pos + sz)) )))) : Tot (leaf_reader (make_total_constant_size_parser sz t f)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (make_total_constant_size_parser sz t f) h sl pos in f' sl.base pos let valid_filter (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t: Type) (p: parser k t) (f: (t -> GTot bool)) (input: slice rrel rel) (pos: U32.t) : Lemma ( (valid (parse_filter p f) h input pos \/ (valid p h input pos /\ f (contents p h input pos))) ==> ( valid p h input pos /\ f (contents p h input pos) == true /\ valid_content_pos (parse_filter p f) h input pos (contents p h input pos) (get_valid_pos p h input pos) )) = valid_facts (parse_filter p f) h input pos; valid_facts p h input pos; if U32.v pos <= U32.v input.len then parse_filter_eq p f (bytes_of_slice_from h input pos) inline_for_extraction let validate_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (v32: validator p) (p32: leaf_reader p) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) : Tot (validator (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input (uint64_to_uint32 pos) in let res = v32 input pos in if is_error res then res else let va = p32 input (uint64_to_uint32 pos) in if not (f' va) then validator_error_generic else res inline_for_extraction let validate_filter_with_error_code (#k: parser_kind) (#t: Type0) (#p: parser k t) (v32: validator p) (p32: leaf_reader p) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) (c: error_code) : Tot (validator (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input (uint64_to_uint32 pos) in let res = v32 input pos in if is_error res then maybe_set_validator_error_pos_and_code res pos c else let va = p32 input (uint64_to_uint32 pos) in if not (f' va) then set_validator_error_pos_and_code validator_error_generic pos c else res inline_for_extraction let validate_filter_ret (#t: Type0) (r: t) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) : Tot (validator (parse_filter (parse_ret r) f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h (parse_ret r) f input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_ret r) h input (uint64_to_uint32 pos) in if not (f' r) then validator_error_generic else pos inline_for_extraction let validate_filter_ret_with_error_code (#t: Type0) (r: t) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) (c: error_code) : Tot (validator (parse_filter (parse_ret r) f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h (parse_ret r) f input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_ret r) h input (uint64_to_uint32 pos) in if not (f' r) then set_validator_error_pos_and_code validator_error_generic pos c else pos inline_for_extraction let jump_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (j: jumper p) (f: (t -> GTot bool)) : Tot (jumper (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in j input pos inline_for_extraction let read_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> GTot bool)) : Tot (leaf_reader (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in (p32 input pos <: (res: t { f res == true } )) // FIXME: WHY WHY WHY do we need this coercion? inline_for_extraction let write_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: leaf_writer_strong s) (f: (t -> GTot bool)) : Tot (leaf_writer_strong (serialize_filter s f)) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialized_length_eq s x in [@inline_let] let _ = serialized_length_eq (serialize_filter s f) x in let res = s32 x input pos in let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in res inline_for_extraction let write_filter_weak (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: leaf_writer_weak s) (f: (t -> GTot bool)) : Tot (leaf_writer_weak (serialize_filter s f)) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialized_length_eq s x in [@inline_let] let _ = serialized_length_eq (serialize_filter s f) x in let res = s32 x input pos in let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in 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 (serialize_filter s f)) = fun x #rrel #rel input pos -> s32 x input pos inline_for_extraction let read_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' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in let res = p1' input pos in f2' res <: t2 // FIXME: WHY WHY WHY this coercion AND the separate let binding? inline_for_extraction let read_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = read_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let read_inline_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' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in [@inline_let] let f2'' (x: t1) : HST.Stack t2 (requires (fun _ -> True)) (ensures (fun h y h' -> h == h' /\ y == f2 x)) = f2' x in // FIXME: WHY WHY WHY do I need this stateful function here? why can't I directly use f2' ? f2'' (p1' input pos) inline_for_extraction let read_inline_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = read_inline_synth p1 f2 (fun x -> f2 x) p1' () inline_for_extraction let write_synth (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (#s1: serializer p1) (s1' : leaf_writer_strong s1) (#t2: Type) (f2: t1 -> GTot t2) (g1: t2 -> GTot t1) (g1' : (x2: t2) -> Tot (x1: t1 { x1 == g1 x2 } )) (u: squash (synth_injective f2 /\ synth_inverse f2 g1)) : Tot (leaf_writer_strong (serialize_synth p1 f2 s1 g1 ())) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 () x in [@inline_let] let _ = serialized_length_eq (serialize_synth p1 f2 s1 g1 ()) x in [@inline_let] let _ = serialized_length_eq s1 (g1 x) in let pos' = s1' (g1' x) input pos in let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in pos' inline_for_extraction let write_synth_weak (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (#s1: serializer p1) (s1' : leaf_writer_weak s1) (#t2: Type) (f2: t1 -> GTot t2) (g1: t2 -> GTot t1) (g1' : (x2: t2) -> Tot (x1: t1 { x1 == g1 x2 } )) (u: squash (synth_injective f2 /\ synth_inverse f2 g1)) : Tot (leaf_writer_weak (serialize_synth p1 f2 s1 g1 ())) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 () x in [@inline_let] let _ = serialized_length_eq (serialize_synth p1 f2 s1 g1 ()) x in [@inline_let] let _ = serialized_length_eq s1 (g1 x) in let pos' = s1' (g1' x) input pos in let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in pos' inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (#s1: serializer p1) (s1' : serializer32 s1) (#t2: Type) (f2: t1 -> GTot t2) (g1: t2 -> GTot t1) (g1' : (x2: t2) -> Tot (x1: t1 { x1 == g1 x2 } )) (u: squash (synth_injective f2 /\ synth_inverse f2 g1)) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 ())) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 () x in s1' (g1' x) input pos (* Special case for vldata and maybe also sum types *) inline_for_extraction let validate_filter_and_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (p1': leaf_reader p1) (f: (t1 -> GTot bool)) (f' : ((x: t1) -> Tot (y: bool { y == f x } ))) (#k2: parser_kind) (#t2: Type) (#p2: ((x: t1 { f x == true} ) -> parser k2 t2)) (v2: ((x1: t1 { f x1 == true } ) -> validator (p2 x1))) (u: unit { and_then_cases_injective p2 }) : Tot (validator (parse_filter p1 f `and_then` p2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = let sinput = bytes_of_slice_from h input (uint64_to_uint32 pos) in valid_facts (parse_filter p1 f `and_then` p2) h input (uint64_to_uint32 pos); and_then_eq (parse_filter p1 f) p2 sinput; parse_filter_eq p1 f sinput; valid_facts p1 h input (uint64_to_uint32 pos) in let res = v1 input pos in if is_error res then res else let va = p1' input (uint64_to_uint32 pos) in if f' va then [@inline_let] let _ = valid_facts (p2 va) h input (uint64_to_uint32 res) in v2 va input res else validator_error_generic inline_for_extraction let validate_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (v2: validator p2) (sq: squash (k1 `is_weaker_than` k2)) : Tot (validator (weaken k1 p2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (weaken k1 p2) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos) in v2 input pos inline_for_extraction let jump_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (v2: jumper p2) (sq: squash (k1 `is_weaker_than` k2)) : Tot (jumper (weaken k1 p2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (weaken k1 p2) h input pos in [@inline_let] let _ = valid_facts p2 h input pos in v2 input pos inline_for_extraction let validate_strengthen (k2: parser_kind) (#k1: parser_kind) (#t: Type) (#p1: parser k1 t) (v1: validator p1) (sq: squash (parser_kind_prop k2 p1)) : Tot (validator (strengthen k2 p1)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (strengthen k2 p1) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p1 h input (uint64_to_uint32 pos) in v1 input pos inline_for_extraction let validate_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (v: ((k: kt1) -> Tot (validator (p k)))) (k: kt2)
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: (k: kt1 -> Tot (parser pk (t k)))) (v: (k: kt1 -> Tot (validator (p k)))) (k: kt2) : Tot (validator (p (f k)))
[]
LowParse.Low.Combinators.validate_compose_context
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "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)) -> v: (k: kt1 -> LowParse.Low.Base.validator (p k)) -> k: kt2 -> LowParse.Low.Base.validator (p (f k))
{ "end_col": 47, "end_line": 1384, "start_col": 2, "start_line": 1384 }
Prims.Tot
val accessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) (j1: jumper p1) : Tot (accessor (gaccessor_then_snd g))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 accessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) (j1: jumper p1) : Tot (accessor (gaccessor_then_snd g)) = accessor_compose a (accessor_snd j1 p2) ()
val accessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) (j1: jumper p1) : Tot (accessor (gaccessor_then_snd g)) let accessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) (j1: jumper p1) : Tot (accessor (gaccessor_then_snd g)) =
false
null
false
accessor_compose a (accessor_snd j1 p2) ()
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Low.Base.Spec.clens", "FStar.Pervasives.Native.tuple2", "LowParse.Low.Base.Spec.gaccessor", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.nondep_then", "LowParse.Low.Base.accessor", "LowParse.Low.Base.jumper", "LowParse.Low.Base.accessor_compose", "LowParse.Low.Combinators.clens_snd", "LowParse.Low.Combinators.gaccessor_snd", "LowParse.Low.Combinators.accessor_snd", "LowParse.Low.Base.Spec.clens_compose", "LowParse.Low.Combinators.gaccessor_then_snd" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" 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 _ #_ #_ _ _ -> 0ul inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun _ #_ #_ _ _ -> 0ul // dummy let valid_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) = valid_facts (p ()) h input pos; valid_facts (lift_parser p) h input pos inline_for_extraction let validate_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: validator #k #t (p ())) : Tot (validator #k #t (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input (uint64_to_uint32 pos); v input pos inline_for_extraction let jump_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: jumper (p ())) : Tot (jumper (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input pos; v input pos let clens_synth (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t1 t2) = { clens_cond = (fun (x: t1) -> True); clens_get = (fun (x: t1) -> f x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (parse_synth p1 f) p1 (clens_synth g f) input pos')) = synth_injective_synth_inverse_synth_inverse_recip f g (); parse_synth_eq p1 f input; 0 val gaccessor_synth (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor (parse_synth p1 f) p1 (clens_synth g f)) val gaccessor_synth_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth p1 f g u input == gaccessor_synth' p1 f g u input) inline_for_extraction let accessor_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_eq p1 f g u); slice_access_eq h (gaccessor_synth p1 f g u) input pos in pos let clens_synth_inv (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t2 t1) = { clens_cond = (fun (x: t2) -> True); clens_get = (fun (x: t2) -> g x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth_inv' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' p1 (parse_synth p1 f) (clens_synth_inv g f) input pos')) = parse_synth_eq p1 f input; 0 val gaccessor_synth_inv (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor p1 (parse_synth p1 f) (clens_synth_inv g f)) val gaccessor_synth_inv_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth_inv p1 f g u input == gaccessor_synth_inv' p1 f g u input) inline_for_extraction let accessor_synth_inv (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth_inv p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_inv_eq p1 f g u); slice_access_eq h (gaccessor_synth_inv p1 f g u) input pos in pos let clens_fst (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t1) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = fst; (* clens_put = (fun x y -> (y, snd x)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let clens_snd (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t2) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = snd; (* clens_put = (fun x y -> (fst x, y)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let gaccessor_fst' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires True) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p1 (clens_fst _ _) input pos')) = nondep_then_eq p1 p2 input; 0 [@"opaque_to_smt"] let gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p1 (clens_fst _ _)) = gaccessor_prop_equiv (p1 `nondep_then` p2) p1 (clens_fst _ _) (gaccessor_fst' p1 sq p2); gaccessor_fst' p1 sq p2 let gaccessor_fst_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_fst p1 sq p2 input == gaccessor_fst' p1 sq p2 input) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2 input) let gaccessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (g: gaccessor p1 p' cl) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (gaccessor (p1 `nondep_then` p2) p' (clens_fst _ _ `clens_compose` cl)) = gaccessor_fst p1 u p2 `gaccessor_compose` g let gaccessor_then_fst (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (g: gaccessor p0 (p1 `nondep_then` p2) cl) : Tot (gaccessor p0 p1 (cl `clens_compose` clens_fst _ _)) = g `gaccessor_compose` gaccessor_fst _ () _ let gaccessor_snd' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p2 (clens_snd _ _) input pos')) = nondep_then_eq p1 p2 input; match parse p1 input with | None -> 0 // dummy | Some (_, consumed) -> consumed let gaccessor_snd_injective (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (sl sl' : bytes) : Lemma (requires (gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ injective_precond (p1 `nondep_then` p2) sl sl')) (ensures (gaccessor_snd' p1 p2 sl == gaccessor_snd' p1 p2 sl')) = nondep_then_eq p1 p2 sl; nondep_then_eq p1 p2 sl'; parse_injective p1 sl sl' let gaccessor_snd_no_lookahead (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (sl sl' : bytes) : Lemma (requires ((and_then_kind k1 k2).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ no_lookahead_on_precond (p1 `nondep_then` p2) sl sl')) (ensures (gaccessor_snd' p1 p2 sl == gaccessor_snd' p1 p2 sl')) = nondep_then_eq p1 p2 sl; nondep_then_eq p1 p2 sl' ; parse_strong_prefix (p1 `nondep_then` p2) sl sl'; parse_injective p1 sl sl' ; parse_strong_prefix p1 sl sl' [@"opaque_to_smt"] let gaccessor_snd (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p2 (clens_snd _ _)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_snd_injective p1 p2 x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_snd_no_lookahead p1 p2 x)); gaccessor_prop_equiv (p1 `nondep_then` p2) p2 (clens_snd _ _) (gaccessor_snd' p1 p2); gaccessor_snd' p1 p2 let gaccessor_snd_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_snd p1 p2 input == gaccessor_snd' p1 p2 input) = reveal_opaque (`%gaccessor_snd) (gaccessor_snd p1 p2 input ) let gaccessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (g: gaccessor p0 (p1 `nondep_then` p2) cl) : Tot (gaccessor p0 p2 (cl `clens_compose` clens_snd _ _)) = g `gaccessor_compose` gaccessor_snd _ _ (* let clens_fst_snd_disjoint (t1 t2: Type) : Lemma (clens_disjoint (clens_fst t1 t2) (clens_snd t1 t2)) = clens_disjoint_l_intro (clens_fst t1 t2) (clens_snd t1 t2) (fun x1 x2 -> ()); clens_disjoint_l_intro (clens_snd t1 t2) (clens_fst t1 t2) (fun x1 x2 -> ()) *) (* abstract let gaccessor_fst_snd_disjoint (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash (k1.parser_kind_subkind == Some ParserStrong)) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Lemma (gaccessors_disjoint (gaccessor_fst p1 sq p2) (gaccessor_snd p1 p2)) = // clens_fst_snd_disjoint t1 t2; gaccessors_disjoint_intro (gaccessor_fst p1 sq p2) (gaccessor_snd p1 p2) (* *) (fun x -> ()) *) inline_for_extraction let accessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (accessor (gaccessor_fst p1 sq p2)) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2); fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_fst p1 sq p2) input pos in pos inline_for_extraction let accessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (#g: gaccessor p1 p' cl) (a: accessor g) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (accessor (gaccessor_fst_then g p2 u)) = accessor_compose (accessor_fst p1 u p2) a u inline_for_extraction let accessor_then_fst (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) : Tot (accessor (gaccessor_then_fst g)) = accessor_compose a (accessor_fst p1 () p2) () inline_for_extraction let accessor_snd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (j1: jumper p1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (accessor (gaccessor_snd p1 p2)) = reveal_opaque (`%gaccessor_snd) (gaccessor_snd p1 p2); fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in let res = j1 input pos in [@inline_let] let _ = slice_access_eq h (gaccessor_snd p1 p2) input pos; valid_facts p1 h input pos in res inline_for_extraction let accessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) (j1: jumper p1)
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val accessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) (j1: jumper p1) : Tot (accessor (gaccessor_then_snd g))
[]
LowParse.Low.Combinators.accessor_then_snd
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
a: LowParse.Low.Base.accessor g -> j1: LowParse.Low.Base.jumper p1 -> LowParse.Low.Base.accessor (LowParse.Low.Combinators.gaccessor_then_snd g)
{ "end_col": 44, "end_line": 961, "start_col": 2, "start_line": 961 }
Prims.Tot
val clens_tagged_union_tag (#tag_t #data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) : Tot (clens data_t tag_t)
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 clens_tagged_union_tag (#tag_t: Type) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) : Tot (clens data_t tag_t) = { clens_cond = (fun _ -> True); clens_get = tag_of_data; }
val clens_tagged_union_tag (#tag_t #data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) : Tot (clens data_t tag_t) let clens_tagged_union_tag (#tag_t #data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) : Tot (clens data_t tag_t) =
false
null
false
{ clens_cond = (fun _ -> True); clens_get = tag_of_data }
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Low.Base.Spec.Mkclens", "Prims.l_True", "LowParse.Low.Base.Spec.clens" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" 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 _ #_ #_ _ _ -> 0ul inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun _ #_ #_ _ _ -> 0ul // dummy let valid_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) = valid_facts (p ()) h input pos; valid_facts (lift_parser p) h input pos inline_for_extraction let validate_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: validator #k #t (p ())) : Tot (validator #k #t (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input (uint64_to_uint32 pos); v input pos inline_for_extraction let jump_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: jumper (p ())) : Tot (jumper (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input pos; v input pos let clens_synth (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t1 t2) = { clens_cond = (fun (x: t1) -> True); clens_get = (fun (x: t1) -> f x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (parse_synth p1 f) p1 (clens_synth g f) input pos')) = synth_injective_synth_inverse_synth_inverse_recip f g (); parse_synth_eq p1 f input; 0 val gaccessor_synth (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor (parse_synth p1 f) p1 (clens_synth g f)) val gaccessor_synth_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth p1 f g u input == gaccessor_synth' p1 f g u input) inline_for_extraction let accessor_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_eq p1 f g u); slice_access_eq h (gaccessor_synth p1 f g u) input pos in pos let clens_synth_inv (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t2 t1) = { clens_cond = (fun (x: t2) -> True); clens_get = (fun (x: t2) -> g x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth_inv' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' p1 (parse_synth p1 f) (clens_synth_inv g f) input pos')) = parse_synth_eq p1 f input; 0 val gaccessor_synth_inv (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor p1 (parse_synth p1 f) (clens_synth_inv g f)) val gaccessor_synth_inv_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth_inv p1 f g u input == gaccessor_synth_inv' p1 f g u input) inline_for_extraction let accessor_synth_inv (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth_inv p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_inv_eq p1 f g u); slice_access_eq h (gaccessor_synth_inv p1 f g u) input pos in pos let clens_fst (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t1) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = fst; (* clens_put = (fun x y -> (y, snd x)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let clens_snd (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t2) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = snd; (* clens_put = (fun x y -> (fst x, y)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let gaccessor_fst' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires True) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p1 (clens_fst _ _) input pos')) = nondep_then_eq p1 p2 input; 0 [@"opaque_to_smt"] let gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p1 (clens_fst _ _)) = gaccessor_prop_equiv (p1 `nondep_then` p2) p1 (clens_fst _ _) (gaccessor_fst' p1 sq p2); gaccessor_fst' p1 sq p2 let gaccessor_fst_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_fst p1 sq p2 input == gaccessor_fst' p1 sq p2 input) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2 input) let gaccessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (g: gaccessor p1 p' cl) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (gaccessor (p1 `nondep_then` p2) p' (clens_fst _ _ `clens_compose` cl)) = gaccessor_fst p1 u p2 `gaccessor_compose` g let gaccessor_then_fst (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (g: gaccessor p0 (p1 `nondep_then` p2) cl) : Tot (gaccessor p0 p1 (cl `clens_compose` clens_fst _ _)) = g `gaccessor_compose` gaccessor_fst _ () _ let gaccessor_snd' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p2 (clens_snd _ _) input pos')) = nondep_then_eq p1 p2 input; match parse p1 input with | None -> 0 // dummy | Some (_, consumed) -> consumed let gaccessor_snd_injective (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (sl sl' : bytes) : Lemma (requires (gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ injective_precond (p1 `nondep_then` p2) sl sl')) (ensures (gaccessor_snd' p1 p2 sl == gaccessor_snd' p1 p2 sl')) = nondep_then_eq p1 p2 sl; nondep_then_eq p1 p2 sl'; parse_injective p1 sl sl' let gaccessor_snd_no_lookahead (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (sl sl' : bytes) : Lemma (requires ((and_then_kind k1 k2).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ no_lookahead_on_precond (p1 `nondep_then` p2) sl sl')) (ensures (gaccessor_snd' p1 p2 sl == gaccessor_snd' p1 p2 sl')) = nondep_then_eq p1 p2 sl; nondep_then_eq p1 p2 sl' ; parse_strong_prefix (p1 `nondep_then` p2) sl sl'; parse_injective p1 sl sl' ; parse_strong_prefix p1 sl sl' [@"opaque_to_smt"] let gaccessor_snd (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p2 (clens_snd _ _)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_snd_injective p1 p2 x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_snd_no_lookahead p1 p2 x)); gaccessor_prop_equiv (p1 `nondep_then` p2) p2 (clens_snd _ _) (gaccessor_snd' p1 p2); gaccessor_snd' p1 p2 let gaccessor_snd_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_snd p1 p2 input == gaccessor_snd' p1 p2 input) = reveal_opaque (`%gaccessor_snd) (gaccessor_snd p1 p2 input ) let gaccessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (g: gaccessor p0 (p1 `nondep_then` p2) cl) : Tot (gaccessor p0 p2 (cl `clens_compose` clens_snd _ _)) = g `gaccessor_compose` gaccessor_snd _ _ (* let clens_fst_snd_disjoint (t1 t2: Type) : Lemma (clens_disjoint (clens_fst t1 t2) (clens_snd t1 t2)) = clens_disjoint_l_intro (clens_fst t1 t2) (clens_snd t1 t2) (fun x1 x2 -> ()); clens_disjoint_l_intro (clens_snd t1 t2) (clens_fst t1 t2) (fun x1 x2 -> ()) *) (* abstract let gaccessor_fst_snd_disjoint (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash (k1.parser_kind_subkind == Some ParserStrong)) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Lemma (gaccessors_disjoint (gaccessor_fst p1 sq p2) (gaccessor_snd p1 p2)) = // clens_fst_snd_disjoint t1 t2; gaccessors_disjoint_intro (gaccessor_fst p1 sq p2) (gaccessor_snd p1 p2) (* *) (fun x -> ()) *) inline_for_extraction let accessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (accessor (gaccessor_fst p1 sq p2)) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2); fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_fst p1 sq p2) input pos in pos inline_for_extraction let accessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (#g: gaccessor p1 p' cl) (a: accessor g) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (accessor (gaccessor_fst_then g p2 u)) = accessor_compose (accessor_fst p1 u p2) a u inline_for_extraction let accessor_then_fst (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) : Tot (accessor (gaccessor_then_fst g)) = accessor_compose a (accessor_fst p1 () p2) () inline_for_extraction let accessor_snd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (j1: jumper p1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (accessor (gaccessor_snd p1 p2)) = reveal_opaque (`%gaccessor_snd) (gaccessor_snd p1 p2); fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in let res = j1 input pos in [@inline_let] let _ = slice_access_eq h (gaccessor_snd p1 p2) input pos; valid_facts p1 h input pos in res inline_for_extraction let accessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) (j1: jumper p1) : Tot (accessor (gaccessor_then_snd g)) = accessor_compose a (accessor_snd j1 p2) () inline_for_extraction let make_total_constant_size_reader (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' : ((#rrel: _) -> (#rel: _) -> (s: B.mbuffer byte rrel rel) -> (pos: U32.t) -> HST.Stack t (requires (fun h -> B.live h s /\ U32.v pos + sz <= B.length s)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == f (Seq.slice (B.as_seq h s) (U32.v pos) (U32.v pos + sz)) )))) : Tot (leaf_reader (make_total_constant_size_parser sz t f)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (make_total_constant_size_parser sz t f) h sl pos in f' sl.base pos let valid_filter (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t: Type) (p: parser k t) (f: (t -> GTot bool)) (input: slice rrel rel) (pos: U32.t) : Lemma ( (valid (parse_filter p f) h input pos \/ (valid p h input pos /\ f (contents p h input pos))) ==> ( valid p h input pos /\ f (contents p h input pos) == true /\ valid_content_pos (parse_filter p f) h input pos (contents p h input pos) (get_valid_pos p h input pos) )) = valid_facts (parse_filter p f) h input pos; valid_facts p h input pos; if U32.v pos <= U32.v input.len then parse_filter_eq p f (bytes_of_slice_from h input pos) inline_for_extraction let validate_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (v32: validator p) (p32: leaf_reader p) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) : Tot (validator (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input (uint64_to_uint32 pos) in let res = v32 input pos in if is_error res then res else let va = p32 input (uint64_to_uint32 pos) in if not (f' va) then validator_error_generic else res inline_for_extraction let validate_filter_with_error_code (#k: parser_kind) (#t: Type0) (#p: parser k t) (v32: validator p) (p32: leaf_reader p) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) (c: error_code) : Tot (validator (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input (uint64_to_uint32 pos) in let res = v32 input pos in if is_error res then maybe_set_validator_error_pos_and_code res pos c else let va = p32 input (uint64_to_uint32 pos) in if not (f' va) then set_validator_error_pos_and_code validator_error_generic pos c else res inline_for_extraction let validate_filter_ret (#t: Type0) (r: t) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) : Tot (validator (parse_filter (parse_ret r) f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h (parse_ret r) f input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_ret r) h input (uint64_to_uint32 pos) in if not (f' r) then validator_error_generic else pos inline_for_extraction let validate_filter_ret_with_error_code (#t: Type0) (r: t) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) (c: error_code) : Tot (validator (parse_filter (parse_ret r) f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h (parse_ret r) f input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_ret r) h input (uint64_to_uint32 pos) in if not (f' r) then set_validator_error_pos_and_code validator_error_generic pos c else pos inline_for_extraction let jump_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (j: jumper p) (f: (t -> GTot bool)) : Tot (jumper (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in j input pos inline_for_extraction let read_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> GTot bool)) : Tot (leaf_reader (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in (p32 input pos <: (res: t { f res == true } )) // FIXME: WHY WHY WHY do we need this coercion? inline_for_extraction let write_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: leaf_writer_strong s) (f: (t -> GTot bool)) : Tot (leaf_writer_strong (serialize_filter s f)) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialized_length_eq s x in [@inline_let] let _ = serialized_length_eq (serialize_filter s f) x in let res = s32 x input pos in let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in res inline_for_extraction let write_filter_weak (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: leaf_writer_weak s) (f: (t -> GTot bool)) : Tot (leaf_writer_weak (serialize_filter s f)) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialized_length_eq s x in [@inline_let] let _ = serialized_length_eq (serialize_filter s f) x in let res = s32 x input pos in let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in 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 (serialize_filter s f)) = fun x #rrel #rel input pos -> s32 x input pos inline_for_extraction let read_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' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in let res = p1' input pos in f2' res <: t2 // FIXME: WHY WHY WHY this coercion AND the separate let binding? inline_for_extraction let read_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = read_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let read_inline_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' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in [@inline_let] let f2'' (x: t1) : HST.Stack t2 (requires (fun _ -> True)) (ensures (fun h y h' -> h == h' /\ y == f2 x)) = f2' x in // FIXME: WHY WHY WHY do I need this stateful function here? why can't I directly use f2' ? f2'' (p1' input pos) inline_for_extraction let read_inline_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = read_inline_synth p1 f2 (fun x -> f2 x) p1' () inline_for_extraction let write_synth (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (#s1: serializer p1) (s1' : leaf_writer_strong s1) (#t2: Type) (f2: t1 -> GTot t2) (g1: t2 -> GTot t1) (g1' : (x2: t2) -> Tot (x1: t1 { x1 == g1 x2 } )) (u: squash (synth_injective f2 /\ synth_inverse f2 g1)) : Tot (leaf_writer_strong (serialize_synth p1 f2 s1 g1 ())) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 () x in [@inline_let] let _ = serialized_length_eq (serialize_synth p1 f2 s1 g1 ()) x in [@inline_let] let _ = serialized_length_eq s1 (g1 x) in let pos' = s1' (g1' x) input pos in let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in pos' inline_for_extraction let write_synth_weak (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (#s1: serializer p1) (s1' : leaf_writer_weak s1) (#t2: Type) (f2: t1 -> GTot t2) (g1: t2 -> GTot t1) (g1' : (x2: t2) -> Tot (x1: t1 { x1 == g1 x2 } )) (u: squash (synth_injective f2 /\ synth_inverse f2 g1)) : Tot (leaf_writer_weak (serialize_synth p1 f2 s1 g1 ())) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 () x in [@inline_let] let _ = serialized_length_eq (serialize_synth p1 f2 s1 g1 ()) x in [@inline_let] let _ = serialized_length_eq s1 (g1 x) in let pos' = s1' (g1' x) input pos in let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in pos' inline_for_extraction let serialize32_synth (#k: parser_kind) (#t1: Type) (#p1: parser k t1) (#s1: serializer p1) (s1' : serializer32 s1) (#t2: Type) (f2: t1 -> GTot t2) (g1: t2 -> GTot t1) (g1' : (x2: t2) -> Tot (x1: t1 { x1 == g1 x2 } )) (u: squash (synth_injective f2 /\ synth_inverse f2 g1)) : Tot (serializer32 (serialize_synth p1 f2 s1 g1 ())) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialize_synth_eq p1 f2 s1 g1 () x in s1' (g1' x) input pos (* Special case for vldata and maybe also sum types *) inline_for_extraction let validate_filter_and_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (p1': leaf_reader p1) (f: (t1 -> GTot bool)) (f' : ((x: t1) -> Tot (y: bool { y == f x } ))) (#k2: parser_kind) (#t2: Type) (#p2: ((x: t1 { f x == true} ) -> parser k2 t2)) (v2: ((x1: t1 { f x1 == true } ) -> validator (p2 x1))) (u: unit { and_then_cases_injective p2 }) : Tot (validator (parse_filter p1 f `and_then` p2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = let sinput = bytes_of_slice_from h input (uint64_to_uint32 pos) in valid_facts (parse_filter p1 f `and_then` p2) h input (uint64_to_uint32 pos); and_then_eq (parse_filter p1 f) p2 sinput; parse_filter_eq p1 f sinput; valid_facts p1 h input (uint64_to_uint32 pos) in let res = v1 input pos in if is_error res then res else let va = p1' input (uint64_to_uint32 pos) in if f' va then [@inline_let] let _ = valid_facts (p2 va) h input (uint64_to_uint32 res) in v2 va input res else validator_error_generic inline_for_extraction let validate_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (v2: validator p2) (sq: squash (k1 `is_weaker_than` k2)) : Tot (validator (weaken k1 p2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (weaken k1 p2) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos) in v2 input pos inline_for_extraction let jump_weaken (k1: parser_kind) (#k2: parser_kind) (#t: Type) (#p2: parser k2 t) (v2: jumper p2) (sq: squash (k1 `is_weaker_than` k2)) : Tot (jumper (weaken k1 p2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (weaken k1 p2) h input pos in [@inline_let] let _ = valid_facts p2 h input pos in v2 input pos inline_for_extraction let validate_strengthen (k2: parser_kind) (#k1: parser_kind) (#t: Type) (#p1: parser k1 t) (v1: validator p1) (sq: squash (parser_kind_prop k2 p1)) : Tot (validator (strengthen k2 p1)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (strengthen k2 p1) h input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts p1 h input (uint64_to_uint32 pos) in v1 input pos inline_for_extraction let validate_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (v: ((k: kt1) -> Tot (validator (p k)))) (k: kt2) : Tot (validator (p (f k))) = fun #rrel #rel input pos -> v (f k) input pos inline_for_extraction let jump_compose_context (#pk: parser_kind) (#kt1 #kt2: Type) (f: (kt2 -> Tot kt1)) (t: (kt1 -> Tot Type)) (p: ((k: kt1) -> Tot (parser pk (t k)))) (v: ((k: kt1) -> Tot (jumper (p k)))) (k: kt2) : Tot (jumper (p (f k))) = fun #rrel #rel input pos -> v (f k) input pos let clens_tagged_union_tag (#tag_t: Type) (#data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) : Tot (clens data_t tag_t)
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val clens_tagged_union_tag (#tag_t #data_t: Type) (tag_of_data: (data_t -> GTot tag_t)) : Tot (clens data_t tag_t)
[]
LowParse.Low.Combinators.clens_tagged_union_tag
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
tag_of_data: (_: data_t -> Prims.GTot tag_t) -> LowParse.Low.Base.Spec.clens data_t tag_t
{ "end_col": 29, "end_line": 1405, "start_col": 4, "start_line": 1404 }
Prims.Tot
val read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v
val read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) =
false
null
false
fun #rrel #rel sl pos -> let h = HST.get () in [@@ inline_let ]let _ = valid_facts (parse_ret v) h sl pos in v
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "Prims.unit", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Spec.Combinators.parse_ret_kind", "LowParse.Spec.Combinators.parse_ret", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Low.Base.leaf_reader" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t)
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v))
[]
LowParse.Low.Combinators.read_ret
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v: t -> LowParse.Low.Base.leaf_reader (LowParse.Spec.Combinators.parse_ret v)
{ "end_col": 3, "end_line": 447, "start_col": 2, "start_line": 444 }
FStar.Pervasives.Lemma
val valid_lift_parser (#k: parser_kind) (#t: Type) (p: (unit -> Tot (parser k t))) (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) = valid_facts (p ()) h input pos; valid_facts (lift_parser p) h input pos
val valid_lift_parser (#k: parser_kind) (#t: Type) (p: (unit -> Tot (parser k t))) (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) let valid_lift_parser (#k: parser_kind) (#t: Type) (p: (unit -> Tot (parser k t))) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) =
false
null
true
valid_facts (p ()) h input pos; valid_facts (lift_parser p) h input pos
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "lemma" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.unit", "LowParse.Spec.Base.parser", "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Spec.Combinators.lift_parser", "Prims.l_True", "Prims.squash", "Prims.l_imp", "Prims.l_or", "LowParse.Low.Base.Spec.valid", "Prims.l_and", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Low.Base.Spec.contents", "LowParse.Low.Base.Spec.get_valid_pos", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" 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 _ #_ #_ _ _ -> 0ul inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun _ #_ #_ _ _ -> 0ul // dummy let valid_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_lift_parser (#k: parser_kind) (#t: Type) (p: (unit -> Tot (parser k t))) (h: HS.mem) (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos))
[]
LowParse.Low.Combinators.valid_lift_parser
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: (_: Prims.unit -> LowParse.Spec.Base.parser k t) -> h: FStar.Monotonic.HyperStack.mem -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> FStar.Pervasives.Lemma (ensures LowParse.Low.Base.Spec.valid (LowParse.Spec.Combinators.lift_parser p) h input pos \/ LowParse.Low.Base.Spec.valid (p ()) h input pos ==> LowParse.Low.Base.Spec.valid (p ()) h input pos /\ LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.Combinators.lift_parser p) h input pos (LowParse.Low.Base.Spec.contents (p ()) h input pos) (LowParse.Low.Base.Spec.get_valid_pos (p ()) h input pos))
{ "end_col": 41, "end_line": 485, "start_col": 2, "start_line": 484 }
Prims.Tot
val serialize32_empty:serializer32 #_ #_ #parse_empty serialize_empty
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Low.Combinators.serialize32_ret", "Prims.unit" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" 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 _ #_ #_ _ _ -> 0ul inline_for_extraction
false
true
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_empty:serializer32 #_ #_ #parse_empty serialize_empty
[]
LowParse.Low.Combinators.serialize32_empty
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.Low.Base.serializer32 LowParse.Spec.Combinators.serialize_empty
{ "end_col": 34, "end_line": 466, "start_col": 2, "start_line": 466 }
Prims.Tot
val jump_lift_parser (#k: parser_kind) (#t: Type) (p: (unit -> Tot (parser k t))) (v: jumper (p ())) : Tot (jumper (lift_parser p))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 jump_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: jumper (p ())) : Tot (jumper (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input pos; v input pos
val jump_lift_parser (#k: parser_kind) (#t: Type) (p: (unit -> Tot (parser k t))) (v: jumper (p ())) : Tot (jumper (lift_parser p)) let jump_lift_parser (#k: parser_kind) (#t: Type) (p: (unit -> Tot (parser k t))) (v: jumper (p ())) : Tot (jumper (lift_parser p)) =
false
null
false
fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input pos; v input pos
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "Prims.unit", "LowParse.Spec.Base.parser", "LowParse.Low.Base.jumper", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "LowParse.Low.Combinators.valid_lift_parser", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Spec.Combinators.lift_parser" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" 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 _ #_ #_ _ _ -> 0ul inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun _ #_ #_ _ _ -> 0ul // dummy let valid_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) = valid_facts (p ()) h input pos; valid_facts (lift_parser p) h input pos inline_for_extraction let validate_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: validator #k #t (p ())) : Tot (validator #k #t (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input (uint64_to_uint32 pos); v input pos inline_for_extraction let jump_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: jumper (p ()))
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_lift_parser (#k: parser_kind) (#t: Type) (p: (unit -> Tot (parser k t))) (v: jumper (p ())) : Tot (jumper (lift_parser p))
[]
LowParse.Low.Combinators.jump_lift_parser
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: (_: Prims.unit -> LowParse.Spec.Base.parser k t) -> v: LowParse.Low.Base.jumper (p ()) -> LowParse.Low.Base.jumper (LowParse.Spec.Combinators.lift_parser p)
{ "end_col": 13, "end_line": 509, "start_col": 2, "start_line": 506 }
Prims.Tot
val jump_empty:jumper parse_empty
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul ()
val jump_empty:jumper parse_empty let jump_empty:jumper parse_empty =
false
null
false
jump_constant_size parse_empty 0ul ()
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Low.Base.jump_constant_size", "LowParse.Spec.Combinators.parse_ret_kind", "Prims.unit", "LowParse.Spec.Combinators.parse_empty", "FStar.UInt32.__uint_to_t" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction
false
true
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_empty:jumper parse_empty
[]
LowParse.Low.Combinators.jump_empty
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.Low.Base.jumper LowParse.Spec.Combinators.parse_empty
{ "end_col": 39, "end_line": 433, "start_col": 2, "start_line": 433 }
Prims.Tot
val read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1': jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2)
val read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1': jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1': jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) =
false
null
false
fun #_ #_ sl pos -> let h = HST.get () in [@@ inline_let ]let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2)
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Low.Base.jumper", "LowParse.Low.Base.leaf_reader", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "Prims.unit", "LowParse.Low.Combinators.valid_nondep_then", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.nondep_then" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2)
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1': jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2))
[]
LowParse.Low.Combinators.read_nondep_then
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1': LowParse.Low.Base.jumper p1 -> r1: LowParse.Low.Base.leaf_reader p1 -> r2: LowParse.Low.Base.leaf_reader p2 -> LowParse.Low.Base.leaf_reader (LowParse.Spec.Combinators.nondep_then p1 p2)
{ "end_col": 10, "end_line": 125, "start_col": 2, "start_line": 119 }
FStar.Pervasives.Lemma
val gaccessor_snd_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_snd p1 p2 input == gaccessor_snd' p1 p2 input)
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 gaccessor_snd_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_snd p1 p2 input == gaccessor_snd' p1 p2 input) = reveal_opaque (`%gaccessor_snd) (gaccessor_snd p1 p2 input )
val gaccessor_snd_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_snd p1 p2 input == gaccessor_snd' p1 p2 input) let gaccessor_snd_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_snd p1 p2 input == gaccessor_snd' p1 p2 input) =
false
null
true
reveal_opaque (`%gaccessor_snd) (gaccessor_snd p1 p2 input)
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "lemma" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Bytes.bytes", "FStar.Pervasives.reveal_opaque", "Prims.nat", "LowParse.Low.Combinators.gaccessor_snd", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "LowParse.Low.Combinators.gaccessor_snd'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" 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 _ #_ #_ _ _ -> 0ul inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun _ #_ #_ _ _ -> 0ul // dummy let valid_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) = valid_facts (p ()) h input pos; valid_facts (lift_parser p) h input pos inline_for_extraction let validate_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: validator #k #t (p ())) : Tot (validator #k #t (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input (uint64_to_uint32 pos); v input pos inline_for_extraction let jump_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: jumper (p ())) : Tot (jumper (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input pos; v input pos let clens_synth (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t1 t2) = { clens_cond = (fun (x: t1) -> True); clens_get = (fun (x: t1) -> f x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (parse_synth p1 f) p1 (clens_synth g f) input pos')) = synth_injective_synth_inverse_synth_inverse_recip f g (); parse_synth_eq p1 f input; 0 val gaccessor_synth (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor (parse_synth p1 f) p1 (clens_synth g f)) val gaccessor_synth_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth p1 f g u input == gaccessor_synth' p1 f g u input) inline_for_extraction let accessor_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_eq p1 f g u); slice_access_eq h (gaccessor_synth p1 f g u) input pos in pos let clens_synth_inv (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t2 t1) = { clens_cond = (fun (x: t2) -> True); clens_get = (fun (x: t2) -> g x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth_inv' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' p1 (parse_synth p1 f) (clens_synth_inv g f) input pos')) = parse_synth_eq p1 f input; 0 val gaccessor_synth_inv (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor p1 (parse_synth p1 f) (clens_synth_inv g f)) val gaccessor_synth_inv_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth_inv p1 f g u input == gaccessor_synth_inv' p1 f g u input) inline_for_extraction let accessor_synth_inv (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth_inv p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_inv_eq p1 f g u); slice_access_eq h (gaccessor_synth_inv p1 f g u) input pos in pos let clens_fst (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t1) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = fst; (* clens_put = (fun x y -> (y, snd x)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let clens_snd (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t2) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = snd; (* clens_put = (fun x y -> (fst x, y)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let gaccessor_fst' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires True) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p1 (clens_fst _ _) input pos')) = nondep_then_eq p1 p2 input; 0 [@"opaque_to_smt"] let gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p1 (clens_fst _ _)) = gaccessor_prop_equiv (p1 `nondep_then` p2) p1 (clens_fst _ _) (gaccessor_fst' p1 sq p2); gaccessor_fst' p1 sq p2 let gaccessor_fst_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_fst p1 sq p2 input == gaccessor_fst' p1 sq p2 input) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2 input) let gaccessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (g: gaccessor p1 p' cl) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (gaccessor (p1 `nondep_then` p2) p' (clens_fst _ _ `clens_compose` cl)) = gaccessor_fst p1 u p2 `gaccessor_compose` g let gaccessor_then_fst (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (g: gaccessor p0 (p1 `nondep_then` p2) cl) : Tot (gaccessor p0 p1 (cl `clens_compose` clens_fst _ _)) = g `gaccessor_compose` gaccessor_fst _ () _ let gaccessor_snd' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p2 (clens_snd _ _) input pos')) = nondep_then_eq p1 p2 input; match parse p1 input with | None -> 0 // dummy | Some (_, consumed) -> consumed let gaccessor_snd_injective (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (sl sl' : bytes) : Lemma (requires (gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ injective_precond (p1 `nondep_then` p2) sl sl')) (ensures (gaccessor_snd' p1 p2 sl == gaccessor_snd' p1 p2 sl')) = nondep_then_eq p1 p2 sl; nondep_then_eq p1 p2 sl'; parse_injective p1 sl sl' let gaccessor_snd_no_lookahead (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (sl sl' : bytes) : Lemma (requires ((and_then_kind k1 k2).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ no_lookahead_on_precond (p1 `nondep_then` p2) sl sl')) (ensures (gaccessor_snd' p1 p2 sl == gaccessor_snd' p1 p2 sl')) = nondep_then_eq p1 p2 sl; nondep_then_eq p1 p2 sl' ; parse_strong_prefix (p1 `nondep_then` p2) sl sl'; parse_injective p1 sl sl' ; parse_strong_prefix p1 sl sl' [@"opaque_to_smt"] let gaccessor_snd (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p2 (clens_snd _ _)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_snd_injective p1 p2 x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_snd_no_lookahead p1 p2 x)); gaccessor_prop_equiv (p1 `nondep_then` p2) p2 (clens_snd _ _) (gaccessor_snd' p1 p2); gaccessor_snd' p1 p2 let gaccessor_snd_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_snd_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_snd p1 p2 input == gaccessor_snd' p1 p2 input)
[]
LowParse.Low.Combinators.gaccessor_snd_eq
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1: LowParse.Spec.Base.parser k1 t1 -> p2: LowParse.Spec.Base.parser k2 t2 -> input: LowParse.Bytes.bytes -> FStar.Pervasives.Lemma (ensures LowParse.Low.Combinators.gaccessor_snd p1 p2 input == LowParse.Low.Combinators.gaccessor_snd' p1 p2 input)
{ "end_col": 62, "end_line": 830, "start_col": 2, "start_line": 830 }
Prims.Tot
val jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: (t1 -> Type)) (#p2: (x: t1 -> parser k2 (t2 x))) (v2: (x: t1 -> Tot (jumper (p2 x)))) : Tot (jumper (parse_dtuple2 p1 p2))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1
val jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: (t1 -> Type)) (#p2: (x: t1 -> parser k2 (t2 x))) (v2: (x: t1 -> Tot (jumper (p2 x)))) : Tot (jumper (parse_dtuple2 p1 p2)) let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: (t1 -> Type)) (#p2: (x: t1 -> parser k2 (t2 x))) (v2: (x: t1 -> Tot (jumper (p2 x)))) : Tot (jumper (parse_dtuple2 p1 p2)) =
false
null
false
fun (#rrel: _) (#rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@@ inline_let ]let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@@ inline_let ]let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Low.Base.jumper", "LowParse.Low.Base.leaf_reader", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "Prims.unit", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Low.Combinators.valid_dtuple2", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Spec.Combinators.and_then_kind", "Prims.dtuple2", "LowParse.Spec.Combinators.parse_dtuple2" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x)))
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: (t1 -> Type)) (#p2: (x: t1 -> parser k2 (t2 x))) (v2: (x: t1 -> Tot (jumper (p2 x)))) : Tot (jumper (parse_dtuple2 p1 p2))
[]
LowParse.Low.Combinators.jump_dtuple2
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v1: LowParse.Low.Base.jumper p1 -> r1: LowParse.Low.Base.leaf_reader p1 -> v2: (x: t1 -> LowParse.Low.Base.jumper (p2 x)) -> LowParse.Low.Base.jumper (LowParse.Spec.Combinators.parse_dtuple2 p1 p2)
{ "end_col": 17, "end_line": 350, "start_col": 2, "start_line": 343 }
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) : Tot (serializer32 (s1 `serialize_nondep_then` s2))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos
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) : Tot (serializer32 (s1 `serialize_nondep_then` 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) =
false
null
false
fun x #rrel #rel b pos -> [@@ inline_let ]let x1, x2 = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.Low.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", "FStar.Pervasives.Native.tuple2", "LowStar.Monotonic.Buffer.srel", "LowParse.Bytes.byte", "LowStar.Monotonic.Buffer.mbuffer", "FStar.UInt32.t", "LowParse.Low.Combinators.serialize32_nondep_then_aux", "Prims.unit", "LowParse.Spec.Combinators.serialize_nondep_then_eq", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.nondep_then", "LowParse.Spec.Combinators.serialize_nondep_then" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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)
false
false
LowParse.Low.Combinators.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": 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2))
[]
LowParse.Low.Combinators.serialize32_nondep_then
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
s1': LowParse.Low.Base.serializer32 s1 { Mkparser_kind'?.parser_kind_subkind k1 == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> s2': LowParse.Low.Base.serializer32 s2 -> LowParse.Low.Base.serializer32 (LowParse.Spec.Combinators.serialize_nondep_then s1 s2)
{ "end_col": 49, "end_line": 187, "start_col": 2, "start_line": 183 }
Prims.Tot
val gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p1 (clens_fst _ _))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p1 (clens_fst _ _)) = gaccessor_prop_equiv (p1 `nondep_then` p2) p1 (clens_fst _ _) (gaccessor_fst' p1 sq p2); gaccessor_fst' p1 sq p2
val gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p1 (clens_fst _ _)) let gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p1 (clens_fst _ _)) =
false
null
false
gaccessor_prop_equiv (p1 `nondep_then` p2) p1 (clens_fst _ _) (gaccessor_fst' p1 sq p2); gaccessor_fst' p1 sq p2
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "Prims.squash", "Prims.unit", "LowParse.Low.Combinators.gaccessor_fst'", "LowParse.Low.Base.Spec.gaccessor_prop_equiv", "LowParse.Spec.Combinators.and_then_kind", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Combinators.nondep_then", "LowParse.Low.Combinators.clens_fst", "LowParse.Low.Base.Spec.gaccessor" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" 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 _ #_ #_ _ _ -> 0ul inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun _ #_ #_ _ _ -> 0ul // dummy let valid_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) = valid_facts (p ()) h input pos; valid_facts (lift_parser p) h input pos inline_for_extraction let validate_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: validator #k #t (p ())) : Tot (validator #k #t (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input (uint64_to_uint32 pos); v input pos inline_for_extraction let jump_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: jumper (p ())) : Tot (jumper (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input pos; v input pos let clens_synth (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t1 t2) = { clens_cond = (fun (x: t1) -> True); clens_get = (fun (x: t1) -> f x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (parse_synth p1 f) p1 (clens_synth g f) input pos')) = synth_injective_synth_inverse_synth_inverse_recip f g (); parse_synth_eq p1 f input; 0 val gaccessor_synth (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor (parse_synth p1 f) p1 (clens_synth g f)) val gaccessor_synth_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth p1 f g u input == gaccessor_synth' p1 f g u input) inline_for_extraction let accessor_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_eq p1 f g u); slice_access_eq h (gaccessor_synth p1 f g u) input pos in pos let clens_synth_inv (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t2 t1) = { clens_cond = (fun (x: t2) -> True); clens_get = (fun (x: t2) -> g x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth_inv' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' p1 (parse_synth p1 f) (clens_synth_inv g f) input pos')) = parse_synth_eq p1 f input; 0 val gaccessor_synth_inv (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor p1 (parse_synth p1 f) (clens_synth_inv g f)) val gaccessor_synth_inv_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth_inv p1 f g u input == gaccessor_synth_inv' p1 f g u input) inline_for_extraction let accessor_synth_inv (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth_inv p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_inv_eq p1 f g u); slice_access_eq h (gaccessor_synth_inv p1 f g u) input pos in pos let clens_fst (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t1) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = fst; (* clens_put = (fun x y -> (y, snd x)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let clens_snd (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t2) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = snd; (* clens_put = (fun x y -> (fst x, y)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let gaccessor_fst' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires True) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p1 (clens_fst _ _) input pos')) = nondep_then_eq p1 p2 input; 0 [@"opaque_to_smt"] let gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2)
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p1 (clens_fst _ _))
[]
LowParse.Low.Combinators.gaccessor_fst
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1: LowParse.Spec.Base.parser k1 t1 -> sq: Prims.squash Prims.unit -> p2: LowParse.Spec.Base.parser k2 t2 -> LowParse.Low.Base.Spec.gaccessor (LowParse.Spec.Combinators.nondep_then p1 p2) p1 (LowParse.Low.Combinators.clens_fst t1 t2)
{ "end_col": 25, "end_line": 712, "start_col": 2, "start_line": 711 }
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.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 _ #_ #_ _ _ -> 0ul
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 _ #_ #_ _ _ -> 0ul
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern", "LowStar.Monotonic.Buffer.srel", "LowParse.Bytes.byte", "LowStar.Monotonic.Buffer.mbuffer", "FStar.UInt32.t", "FStar.UInt32.__uint_to_t", "LowParse.Low.Base.serializer32", "LowParse.Spec.Combinators.parse_ret_kind", "LowParse.Spec.Combinators.parse_ret", "LowParse.Spec.Combinators.serialize_ret" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" inline_for_extraction let serialize32_ret (#t: Type) (v: t) (v_unique: (v' : t) -> Lemma (v == v'))
false
false
LowParse.Low.Combinators.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": 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.Low.Combinators.serialize32_ret
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "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.Low.Base.serializer32 (LowParse.Spec.Combinators.serialize_ret v v_unique)
{ "end_col": 24, "end_line": 462, "start_col": 2, "start_line": 462 }
Prims.Tot
val read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: (t1 -> Type)) (#p2: (x: t1 -> parser k2 (t2 x))) (r2: (x: t1 -> Tot (leaf_reader (p2 x)))) : Tot (leaf_reader (parse_dtuple2 p1 p2))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |)
val read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: (t1 -> Type)) (#p2: (x: t1 -> parser k2 (t2 x))) (r2: (x: t1 -> Tot (leaf_reader (p2 x)))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: (t1 -> Type)) (#p2: (x: t1 -> parser k2 (t2 x))) (r2: (x: t1 -> Tot (leaf_reader (p2 x)))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) =
false
null
false
fun #_ #_ sl pos -> let h = HST.get () in [@@ inline_let ]let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |)
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Low.Base.jumper", "LowParse.Low.Base.leaf_reader", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "Prims.Mkdtuple2", "Prims.dtuple2", "Prims.unit", "LowParse.Low.Combinators.valid_dtuple2", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Spec.Combinators.and_then_kind", "LowParse.Spec.Combinators.parse_dtuple2" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x)))
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: (t1 -> Type)) (#p2: (x: t1 -> parser k2 (t2 x))) (r2: (x: t1 -> Tot (leaf_reader (p2 x)))) : Tot (leaf_reader (parse_dtuple2 p1 p2))
[]
LowParse.Low.Combinators.read_dtuple2
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v1: LowParse.Low.Base.jumper p1 -> r1: LowParse.Low.Base.leaf_reader p1 -> r2: (x: t1 -> LowParse.Low.Base.leaf_reader (p2 x)) -> LowParse.Low.Base.leaf_reader (LowParse.Spec.Combinators.parse_dtuple2 p1 p2)
{ "end_col": 14, "end_line": 390, "start_col": 2, "start_line": 384 }
Prims.Ghost
val gaccessor_snd' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p2 (clens_snd _ _) input pos'))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 gaccessor_snd' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p2 (clens_snd _ _) input pos')) = nondep_then_eq p1 p2 input; match parse p1 input with | None -> 0 // dummy | Some (_, consumed) -> consumed
val gaccessor_snd' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p2 (clens_snd _ _) input pos')) let gaccessor_snd' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p2 (clens_snd _ _) input pos')) =
false
null
false
nondep_then_eq p1 p2 input; match parse p1 input with | None -> 0 | Some (_, consumed) -> consumed
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Bytes.bytes", "LowParse.Spec.Base.parse", "LowParse.Spec.Base.consumed_length", "Prims.nat", "Prims.unit", "LowParse.Spec.Combinators.nondep_then_eq", "Prims.l_True", "LowParse.Low.Base.Spec.gaccessor_post'", "LowParse.Spec.Combinators.and_then_kind", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Combinators.nondep_then", "LowParse.Low.Combinators.clens_snd" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" 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 _ #_ #_ _ _ -> 0ul inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun _ #_ #_ _ _ -> 0ul // dummy let valid_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) = valid_facts (p ()) h input pos; valid_facts (lift_parser p) h input pos inline_for_extraction let validate_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: validator #k #t (p ())) : Tot (validator #k #t (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input (uint64_to_uint32 pos); v input pos inline_for_extraction let jump_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: jumper (p ())) : Tot (jumper (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input pos; v input pos let clens_synth (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t1 t2) = { clens_cond = (fun (x: t1) -> True); clens_get = (fun (x: t1) -> f x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (parse_synth p1 f) p1 (clens_synth g f) input pos')) = synth_injective_synth_inverse_synth_inverse_recip f g (); parse_synth_eq p1 f input; 0 val gaccessor_synth (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor (parse_synth p1 f) p1 (clens_synth g f)) val gaccessor_synth_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth p1 f g u input == gaccessor_synth' p1 f g u input) inline_for_extraction let accessor_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_eq p1 f g u); slice_access_eq h (gaccessor_synth p1 f g u) input pos in pos let clens_synth_inv (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t2 t1) = { clens_cond = (fun (x: t2) -> True); clens_get = (fun (x: t2) -> g x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth_inv' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' p1 (parse_synth p1 f) (clens_synth_inv g f) input pos')) = parse_synth_eq p1 f input; 0 val gaccessor_synth_inv (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor p1 (parse_synth p1 f) (clens_synth_inv g f)) val gaccessor_synth_inv_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth_inv p1 f g u input == gaccessor_synth_inv' p1 f g u input) inline_for_extraction let accessor_synth_inv (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth_inv p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_inv_eq p1 f g u); slice_access_eq h (gaccessor_synth_inv p1 f g u) input pos in pos let clens_fst (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t1) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = fst; (* clens_put = (fun x y -> (y, snd x)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let clens_snd (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t2) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = snd; (* clens_put = (fun x y -> (fst x, y)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let gaccessor_fst' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires True) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p1 (clens_fst _ _) input pos')) = nondep_then_eq p1 p2 input; 0 [@"opaque_to_smt"] let gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p1 (clens_fst _ _)) = gaccessor_prop_equiv (p1 `nondep_then` p2) p1 (clens_fst _ _) (gaccessor_fst' p1 sq p2); gaccessor_fst' p1 sq p2 let gaccessor_fst_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_fst p1 sq p2 input == gaccessor_fst' p1 sq p2 input) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2 input) let gaccessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (g: gaccessor p1 p' cl) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (gaccessor (p1 `nondep_then` p2) p' (clens_fst _ _ `clens_compose` cl)) = gaccessor_fst p1 u p2 `gaccessor_compose` g let gaccessor_then_fst (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (g: gaccessor p0 (p1 `nondep_then` p2) cl) : Tot (gaccessor p0 p1 (cl `clens_compose` clens_fst _ _)) = g `gaccessor_compose` gaccessor_fst _ () _ let gaccessor_snd' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires (True))
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gaccessor_snd' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p2 (clens_snd _ _) input pos'))
[]
LowParse.Low.Combinators.gaccessor_snd'
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1: LowParse.Spec.Base.parser k1 t1 -> p2: LowParse.Spec.Base.parser k2 t2 -> input: LowParse.Bytes.bytes -> Prims.Ghost Prims.nat
{ "end_col": 34, "end_line": 772, "start_col": 2, "start_line": 769 }
FStar.Pervasives.Lemma
val valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures ((let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1))))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos
val valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures ((let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1)))) let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures ((let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1)))) =
false
null
true
valid_nondep_then h p1 p2 s pos
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "lemma" ]
[ "LowParse.Slice.srel", "LowParse.Bytes.byte", "FStar.Monotonic.HyperStack.mem", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Slice.slice", "FStar.UInt32.t", "LowParse.Low.Combinators.valid_nondep_then", "Prims.unit", "Prims.l_and", "LowParse.Low.Base.Spec.valid", "LowParse.Low.Base.Spec.get_valid_pos", "Prims.squash", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Spec.Combinators.and_then_kind", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Combinators.nondep_then", "FStar.Pervasives.Native.Mktuple2", "LowParse.Low.Base.Spec.contents", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1)
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures ((let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1))))
[]
LowParse.Low.Combinators.valid_nondep_then_intro
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
h: FStar.Monotonic.HyperStack.mem -> p1: LowParse.Spec.Base.parser k1 t1 -> p2: LowParse.Spec.Base.parser k2 t2 -> s: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.valid p1 h s pos /\ LowParse.Low.Base.Spec.valid p2 h s (LowParse.Low.Base.Spec.get_valid_pos p1 h s pos)) (ensures (let pos1 = LowParse.Low.Base.Spec.get_valid_pos p1 h s pos in LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.Combinators.nondep_then p1 p2) h s pos (LowParse.Low.Base.Spec.contents p1 h s pos, LowParse.Low.Base.Spec.contents p2 h s pos1 ) (LowParse.Low.Base.Spec.get_valid_pos p2 h s pos1)))
{ "end_col": 33, "end_line": 64, "start_col": 2, "start_line": 64 }
Prims.Tot
val jump_synth (#k: parser_kind) (#t1 #t2: Type) (#p1: parser k t1) (p1': jumper p1) (f2: (t1 -> GTot t2)) (u: unit{synth_injective f2}) : Tot (jumper (parse_synth p1 f2))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos
val jump_synth (#k: parser_kind) (#t1 #t2: Type) (#p1: parser k t1) (p1': jumper p1) (f2: (t1 -> GTot t2)) (u: unit{synth_injective f2}) : Tot (jumper (parse_synth p1 f2)) let jump_synth (#k: parser_kind) (#t1 #t2: Type) (#p1: parser k t1) (p1': jumper p1) (f2: (t1 -> GTot t2)) (u: unit{synth_injective f2}) : Tot (jumper (parse_synth p1 f2)) =
false
null
false
fun (#rrel: _) (#rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@@ inline_let ]let _ = valid_synth h p1 f2 input pos in p1' input pos
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Low.Base.jumper", "Prims.unit", "LowParse.Spec.Combinators.synth_injective", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "LowParse.Low.Combinators.valid_synth", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Spec.Combinators.parse_synth" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 })
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_synth (#k: parser_kind) (#t1 #t2: Type) (#p1: parser k t1) (p1': jumper p1) (f2: (t1 -> GTot t2)) (u: unit{synth_injective f2}) : Tot (jumper (parse_synth p1 f2))
[]
LowParse.Low.Combinators.jump_synth
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1': LowParse.Low.Base.jumper p1 -> f2: (_: t1 -> Prims.GTot t2) -> u113: u115: Prims.unit{LowParse.Spec.Combinators.synth_injective f2} -> LowParse.Low.Base.jumper (LowParse.Spec.Combinators.parse_synth p1 f2)
{ "end_col": 15, "end_line": 267, "start_col": 2, "start_line": 263 }
Prims.Tot
val jump_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (j: jumper p) (f: (t -> GTot bool)) : Tot (jumper (parse_filter p f))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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 jump_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (j: jumper p) (f: (t -> GTot bool)) : Tot (jumper (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in j input pos
val jump_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (j: jumper p) (f: (t -> GTot bool)) : Tot (jumper (parse_filter p f)) let jump_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (j: jumper p) (f: (t -> GTot bool)) : Tot (jumper (parse_filter p f)) =
false
null
false
fun #rrel #rel input pos -> let h = HST.get () in [@@ inline_let ]let _ = valid_filter h p f input pos in j input pos
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Low.Base.jumper", "Prims.bool", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "Prims.unit", "LowParse.Low.Combinators.valid_filter", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.Combinators.parse_filter" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" 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 _ #_ #_ _ _ -> 0ul inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun _ #_ #_ _ _ -> 0ul // dummy let valid_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) = valid_facts (p ()) h input pos; valid_facts (lift_parser p) h input pos inline_for_extraction let validate_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: validator #k #t (p ())) : Tot (validator #k #t (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input (uint64_to_uint32 pos); v input pos inline_for_extraction let jump_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: jumper (p ())) : Tot (jumper (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input pos; v input pos let clens_synth (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t1 t2) = { clens_cond = (fun (x: t1) -> True); clens_get = (fun (x: t1) -> f x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (parse_synth p1 f) p1 (clens_synth g f) input pos')) = synth_injective_synth_inverse_synth_inverse_recip f g (); parse_synth_eq p1 f input; 0 val gaccessor_synth (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor (parse_synth p1 f) p1 (clens_synth g f)) val gaccessor_synth_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth p1 f g u input == gaccessor_synth' p1 f g u input) inline_for_extraction let accessor_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_eq p1 f g u); slice_access_eq h (gaccessor_synth p1 f g u) input pos in pos let clens_synth_inv (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t2 t1) = { clens_cond = (fun (x: t2) -> True); clens_get = (fun (x: t2) -> g x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth_inv' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' p1 (parse_synth p1 f) (clens_synth_inv g f) input pos')) = parse_synth_eq p1 f input; 0 val gaccessor_synth_inv (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor p1 (parse_synth p1 f) (clens_synth_inv g f)) val gaccessor_synth_inv_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth_inv p1 f g u input == gaccessor_synth_inv' p1 f g u input) inline_for_extraction let accessor_synth_inv (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth_inv p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_inv_eq p1 f g u); slice_access_eq h (gaccessor_synth_inv p1 f g u) input pos in pos let clens_fst (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t1) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = fst; (* clens_put = (fun x y -> (y, snd x)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let clens_snd (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t2) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = snd; (* clens_put = (fun x y -> (fst x, y)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let gaccessor_fst' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires True) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p1 (clens_fst _ _) input pos')) = nondep_then_eq p1 p2 input; 0 [@"opaque_to_smt"] let gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p1 (clens_fst _ _)) = gaccessor_prop_equiv (p1 `nondep_then` p2) p1 (clens_fst _ _) (gaccessor_fst' p1 sq p2); gaccessor_fst' p1 sq p2 let gaccessor_fst_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_fst p1 sq p2 input == gaccessor_fst' p1 sq p2 input) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2 input) let gaccessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (g: gaccessor p1 p' cl) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (gaccessor (p1 `nondep_then` p2) p' (clens_fst _ _ `clens_compose` cl)) = gaccessor_fst p1 u p2 `gaccessor_compose` g let gaccessor_then_fst (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (g: gaccessor p0 (p1 `nondep_then` p2) cl) : Tot (gaccessor p0 p1 (cl `clens_compose` clens_fst _ _)) = g `gaccessor_compose` gaccessor_fst _ () _ let gaccessor_snd' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p2 (clens_snd _ _) input pos')) = nondep_then_eq p1 p2 input; match parse p1 input with | None -> 0 // dummy | Some (_, consumed) -> consumed let gaccessor_snd_injective (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (sl sl' : bytes) : Lemma (requires (gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ injective_precond (p1 `nondep_then` p2) sl sl')) (ensures (gaccessor_snd' p1 p2 sl == gaccessor_snd' p1 p2 sl')) = nondep_then_eq p1 p2 sl; nondep_then_eq p1 p2 sl'; parse_injective p1 sl sl' let gaccessor_snd_no_lookahead (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (sl sl' : bytes) : Lemma (requires ((and_then_kind k1 k2).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ no_lookahead_on_precond (p1 `nondep_then` p2) sl sl')) (ensures (gaccessor_snd' p1 p2 sl == gaccessor_snd' p1 p2 sl')) = nondep_then_eq p1 p2 sl; nondep_then_eq p1 p2 sl' ; parse_strong_prefix (p1 `nondep_then` p2) sl sl'; parse_injective p1 sl sl' ; parse_strong_prefix p1 sl sl' [@"opaque_to_smt"] let gaccessor_snd (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p2 (clens_snd _ _)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_snd_injective p1 p2 x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_snd_no_lookahead p1 p2 x)); gaccessor_prop_equiv (p1 `nondep_then` p2) p2 (clens_snd _ _) (gaccessor_snd' p1 p2); gaccessor_snd' p1 p2 let gaccessor_snd_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_snd p1 p2 input == gaccessor_snd' p1 p2 input) = reveal_opaque (`%gaccessor_snd) (gaccessor_snd p1 p2 input ) let gaccessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (g: gaccessor p0 (p1 `nondep_then` p2) cl) : Tot (gaccessor p0 p2 (cl `clens_compose` clens_snd _ _)) = g `gaccessor_compose` gaccessor_snd _ _ (* let clens_fst_snd_disjoint (t1 t2: Type) : Lemma (clens_disjoint (clens_fst t1 t2) (clens_snd t1 t2)) = clens_disjoint_l_intro (clens_fst t1 t2) (clens_snd t1 t2) (fun x1 x2 -> ()); clens_disjoint_l_intro (clens_snd t1 t2) (clens_fst t1 t2) (fun x1 x2 -> ()) *) (* abstract let gaccessor_fst_snd_disjoint (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash (k1.parser_kind_subkind == Some ParserStrong)) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Lemma (gaccessors_disjoint (gaccessor_fst p1 sq p2) (gaccessor_snd p1 p2)) = // clens_fst_snd_disjoint t1 t2; gaccessors_disjoint_intro (gaccessor_fst p1 sq p2) (gaccessor_snd p1 p2) (* *) (fun x -> ()) *) inline_for_extraction let accessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (accessor (gaccessor_fst p1 sq p2)) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2); fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_fst p1 sq p2) input pos in pos inline_for_extraction let accessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (#g: gaccessor p1 p' cl) (a: accessor g) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (accessor (gaccessor_fst_then g p2 u)) = accessor_compose (accessor_fst p1 u p2) a u inline_for_extraction let accessor_then_fst (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) : Tot (accessor (gaccessor_then_fst g)) = accessor_compose a (accessor_fst p1 () p2) () inline_for_extraction let accessor_snd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (j1: jumper p1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (accessor (gaccessor_snd p1 p2)) = reveal_opaque (`%gaccessor_snd) (gaccessor_snd p1 p2); fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in let res = j1 input pos in [@inline_let] let _ = slice_access_eq h (gaccessor_snd p1 p2) input pos; valid_facts p1 h input pos in res inline_for_extraction let accessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) (j1: jumper p1) : Tot (accessor (gaccessor_then_snd g)) = accessor_compose a (accessor_snd j1 p2) () inline_for_extraction let make_total_constant_size_reader (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' : ((#rrel: _) -> (#rel: _) -> (s: B.mbuffer byte rrel rel) -> (pos: U32.t) -> HST.Stack t (requires (fun h -> B.live h s /\ U32.v pos + sz <= B.length s)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == f (Seq.slice (B.as_seq h s) (U32.v pos) (U32.v pos + sz)) )))) : Tot (leaf_reader (make_total_constant_size_parser sz t f)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (make_total_constant_size_parser sz t f) h sl pos in f' sl.base pos let valid_filter (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t: Type) (p: parser k t) (f: (t -> GTot bool)) (input: slice rrel rel) (pos: U32.t) : Lemma ( (valid (parse_filter p f) h input pos \/ (valid p h input pos /\ f (contents p h input pos))) ==> ( valid p h input pos /\ f (contents p h input pos) == true /\ valid_content_pos (parse_filter p f) h input pos (contents p h input pos) (get_valid_pos p h input pos) )) = valid_facts (parse_filter p f) h input pos; valid_facts p h input pos; if U32.v pos <= U32.v input.len then parse_filter_eq p f (bytes_of_slice_from h input pos) inline_for_extraction let validate_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (v32: validator p) (p32: leaf_reader p) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) : Tot (validator (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input (uint64_to_uint32 pos) in let res = v32 input pos in if is_error res then res else let va = p32 input (uint64_to_uint32 pos) in if not (f' va) then validator_error_generic else res inline_for_extraction let validate_filter_with_error_code (#k: parser_kind) (#t: Type0) (#p: parser k t) (v32: validator p) (p32: leaf_reader p) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) (c: error_code) : Tot (validator (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input (uint64_to_uint32 pos) in let res = v32 input pos in if is_error res then maybe_set_validator_error_pos_and_code res pos c else let va = p32 input (uint64_to_uint32 pos) in if not (f' va) then set_validator_error_pos_and_code validator_error_generic pos c else res inline_for_extraction let validate_filter_ret (#t: Type0) (r: t) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) : Tot (validator (parse_filter (parse_ret r) f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h (parse_ret r) f input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_ret r) h input (uint64_to_uint32 pos) in if not (f' r) then validator_error_generic else pos inline_for_extraction let validate_filter_ret_with_error_code (#t: Type0) (r: t) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) (c: error_code) : Tot (validator (parse_filter (parse_ret r) f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h (parse_ret r) f input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_ret r) h input (uint64_to_uint32 pos) in if not (f' r) then set_validator_error_pos_and_code validator_error_generic pos c else pos inline_for_extraction let jump_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (j: jumper p) (f: (t -> GTot bool))
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (j: jumper p) (f: (t -> GTot bool)) : Tot (jumper (parse_filter p f))
[]
LowParse.Low.Combinators.jump_filter
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
j: LowParse.Low.Base.jumper p -> f: (_: t -> Prims.GTot Prims.bool) -> LowParse.Low.Base.jumper (LowParse.Spec.Combinators.parse_filter p f)
{ "end_col": 13, "end_line": 1092, "start_col": 2, "start_line": 1089 }
FStar.Pervasives.Lemma
val valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h input /\ synth_injective f2)) (ensures ((valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> (valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos))))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos)
val valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h input /\ synth_injective f2)) (ensures ((valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> (valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos)))) let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h input /\ synth_injective f2)) (ensures ((valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> (valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos)))) =
false
null
true
valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos)
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "lemma" ]
[ "LowParse.Slice.srel", "LowParse.Bytes.byte", "FStar.Monotonic.HyperStack.mem", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Slice.slice", "FStar.UInt32.t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "LowParse.Slice.__proj__Mkslice__item__len", "LowParse.Spec.Combinators.parse_synth_eq", "LowParse.Slice.bytes_of_slice_from", "Prims.bool", "Prims.unit", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Spec.Combinators.parse_synth", "Prims.l_and", "LowParse.Slice.live_slice", "LowParse.Spec.Combinators.synth_injective", "Prims.squash", "Prims.l_imp", "Prims.l_or", "LowParse.Low.Base.Spec.valid", "LowParse.Low.Base.Spec.valid_content_pos", "LowParse.Low.Base.Spec.contents", "LowParse.Low.Base.Spec.get_valid_pos", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos)
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1 #t2: Type) (p1: parser k t1) (f2: (t1 -> GTot t2)) (input: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h input /\ synth_injective f2)) (ensures ((valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> (valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos))))
[]
LowParse.Low.Combinators.valid_synth
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
h: FStar.Monotonic.HyperStack.mem -> p1: LowParse.Spec.Base.parser k t1 -> f2: (_: t1 -> Prims.GTot t2) -> input: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires LowParse.Slice.live_slice h input /\ LowParse.Spec.Combinators.synth_injective f2) (ensures LowParse.Low.Base.Spec.valid (LowParse.Spec.Combinators.parse_synth p1 f2) h input pos \/ LowParse.Low.Base.Spec.valid p1 h input pos ==> LowParse.Low.Base.Spec.valid p1 h input pos /\ LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.Combinators.parse_synth p1 f2) h input pos (f2 (LowParse.Low.Base.Spec.contents p1 h input pos)) (LowParse.Low.Base.Spec.get_valid_pos p1 h input pos))
{ "end_col": 61, "end_line": 211, "start_col": 2, "start_line": 208 }
Prims.Tot
val read_inline_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': leaf_reader p1) (u: unit{synth_injective f2}) : Tot (leaf_reader (parse_synth p1 f2))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B0" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low", "short_module": null }, { "abbrev": 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_inline_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' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in [@inline_let] let f2'' (x: t1) : HST.Stack t2 (requires (fun _ -> True)) (ensures (fun h y h' -> h == h' /\ y == f2 x)) = f2' x in // FIXME: WHY WHY WHY do I need this stateful function here? why can't I directly use f2' ? f2'' (p1' input pos)
val read_inline_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': leaf_reader p1) (u: unit{synth_injective f2}) : Tot (leaf_reader (parse_synth p1 f2)) let read_inline_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': leaf_reader p1) (u: unit{synth_injective f2}) : Tot (leaf_reader (parse_synth p1 f2)) =
false
null
false
fun #rrel #rel input pos -> let h = HST.get () in [@@ inline_let ]let _ = valid_synth h p1 f2 input pos in [@@ inline_let ]let f2'' (x: t1) : HST.Stack t2 (requires (fun _ -> True)) (ensures (fun h y h' -> h == h' /\ y == f2 x)) = f2' x in f2'' (p1' input pos)
{ "checked_file": "LowParse.Low.Combinators.fsti.checked", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.Failure.fsti.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Combinators.fsti" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "Prims.eq2", "LowParse.Low.Base.leaf_reader", "Prims.unit", "LowParse.Spec.Combinators.synth_injective", "LowParse.Slice.srel", "LowParse.Bytes.byte", "LowParse.Slice.slice", "FStar.UInt32.t", "FStar.Monotonic.HyperStack.mem", "Prims.l_True", "Prims.l_and", "LowParse.Low.Combinators.valid_synth", "FStar.HyperStack.ST.get", "LowParse.Spec.Combinators.parse_synth" ]
[]
module LowParse.Low.Combinators include LowParse.Low.Base include LowParse.Spec.Combinators module B = LowStar.Monotonic.Buffer module B0 = LowStar.Buffer module U32 = FStar.UInt32 module HS = FStar.HyperStack module HST = FStar.HyperStack.ST #set-options "--z3rlimit 16" let valid_nondep_then (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (nondep_then p1 p2) h s pos \/ (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in valid p2 h s (get_valid_pos p1 h s pos) /\ valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) )))) = valid_facts p1 h s pos; valid_facts (nondep_then p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin nondep_then_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in valid_facts p2 h s pos1 end end let valid_nondep_then_intro (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (valid p1 h s pos /\ valid p2 h s (get_valid_pos p1 h s pos))) (ensures (( let pos1 = get_valid_pos p1 h s pos in valid_content_pos (nondep_then p1 p2) h s pos (contents p1 h s pos, contents p2 h s pos1) (get_valid_pos p2 h s pos1) ))) = valid_nondep_then h p1 p2 s pos inline_for_extraction let validate_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : validator p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : validator p2) : Tot (validator (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input (uint64_to_uint32 pos) in let pos1 = p1' input pos in if is_error pos1 then begin pos1 end else [@inline_let] let _ = valid_facts p2 h input (uint64_to_uint32 pos1) in p2' input pos1 inline_for_extraction let jump_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (p2' : jumper p2) : Tot (jumper (nondep_then p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in p2' input (p1' input pos) inline_for_extraction let read_nondep_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (p1' : jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (r2: leaf_reader p2) : Tot (leaf_reader (nondep_then p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = p1' sl pos in let x2 = r2 sl pos2 in (x1, x2) inline_for_extraction let serialize32_nondep_then_aux (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1) (s1' : serializer32 s1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2) (s2' : serializer32 s2) (x1: t1) (x2: t2) (#rrel: _) (#rel: _) (b: B.mbuffer byte rrel rel) (pos: U32.t) : HST.Stack U32.t (requires (fun h -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in let len = len1 + len2 in let sq = B.as_seq h b in B.live h b /\ U32.v pos + len <= B.length b /\ writable b (U32.v pos) (U32.v pos + len) h )) (ensures (fun h len h' -> let len1 = Seq.length (serialize s1 x1) in let len2 = Seq.length (serialize s2 x2) in len1 + len2 == U32.v len /\ ( B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` len)) h h' /\ B.live h b /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v len) `Seq.equal` (serialize s1 x1 `Seq.append` serialize s2 x2) ))) = let gpos' = Ghost.hide (pos `U32.add` U32.uint_to_t (Seq.length (serialize s1 x1) + Seq.length (serialize s2 x2))) in let len1 = frame_serializer32 s1' x1 b (Ghost.hide pos) gpos' pos in let pos1 = pos `U32.add` len1 in let len2 = frame_serializer32 s2' x2 b (Ghost.hide pos) gpos' pos1 in let h1 = HST.get () in len1 `U32.add` len2 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) : Tot (serializer32 (s1 `serialize_nondep_then` s2)) = fun x #rrel #rel b pos -> [@inline_let] let (x1, x2) = x in serialize_nondep_then_eq s1 s2 x; serialize32_nondep_then_aux s1' s2' x1 x2 b pos let valid_synth (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( live_slice h input /\ synth_injective f2 )) (ensures ( (valid (parse_synth p1 f2) h input pos \/ valid p1 h input pos) ==> ( valid p1 h input pos /\ valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) ))) = valid_facts p1 h input pos; valid_facts (parse_synth p1 f2) h input pos; if U32.v pos <= U32.v input.len then parse_synth_eq p1 f2 (bytes_of_slice_from h input pos) let valid_synth_intro (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> GTot t2) (input: slice rrel rel) (pos: U32.t) : Lemma (requires ( synth_injective f2 /\ valid p1 h input pos )) (ensures ( valid_content_pos (parse_synth p1 f2) h input pos (f2 (contents p1 h input pos)) (get_valid_pos p1 h input pos) )) = valid_synth h p1 f2 input pos inline_for_extraction let validate_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : validator p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (validator (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input (uint64_to_uint32 pos) in p1' input pos inline_for_extraction let jump_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (#p1: parser k t1) (p1' : jumper p1) (f2: t1 -> GTot t2) (u: unit { synth_injective f2 }) : Tot (jumper (parse_synth p1 f2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in p1' input pos let valid_dtuple2 (#rrel #rel: _) (h: HS.mem) (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (s: slice rrel rel) (pos: U32.t) : Lemma (requires (live_slice h s)) (ensures (( valid (parse_dtuple2 p1 p2) h s pos \/ (valid p1 h s pos /\ valid (p2 (contents p1 h s pos)) h s (get_valid_pos p1 h s pos)) ) ==> ( valid p1 h s pos /\ ( let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid (p2 x) h s (get_valid_pos p1 h s pos) /\ valid_content_pos (parse_dtuple2 p1 p2) h s pos (| x, contents (p2 x) h s pos1 |) (get_valid_pos (p2 x) h s pos1) )))) = valid_facts p1 h s pos; valid_facts (parse_dtuple2 p1 p2) h s pos; if U32.v pos <= U32.v s.len then begin parse_dtuple2_eq p1 p2 (bytes_of_slice_from h s pos); if valid_dec p1 h s pos then begin let pos1 = get_valid_pos p1 h s pos in let x = contents p1 h s pos in valid_facts (p2 x) h s pos1 end end inline_for_extraction let validate_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: validator p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (validator (p2 x))) : Tot (validator (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input (uint64_to_uint32 pos) in let pos1 = v1 input pos in if is_error pos1 then begin pos1 end else let x = r1 input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (p2 x) h input (uint64_to_uint32 pos1) in v2 x input pos1 inline_for_extraction let jump_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (v2: (x: t1) -> Tot (jumper (p2 x))) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in let x = r1 input pos in [@inline_let] let _ = valid_facts (p2 x) h input pos1 in v2 x input pos1 inline_for_extraction let jump_dtuple2_constant_size_dsnd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (#k2: parser_kind) (#t2: t1 -> Type) (p2: (x: t1) -> parser k2 (t2 x)) (sz: U32.t { U32.v sz == k2.parser_kind_low /\ k2.parser_kind_high == Some k2.parser_kind_low }) : Tot (jumper (parse_dtuple2 p1 p2)) = fun (#rrel #rel: _) (input: slice rrel rel) (pos: U32.t) -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 input pos in let pos1 = v1 input pos in [@inline_let] let p2x = Ghost.hide (p2 (contents p1 h input pos)) in [@inline_let] let _ = valid_facts (Ghost.reveal p2x) h input pos1 in jump_constant_size' (fun _ -> Ghost.reveal p2x) sz () input pos1 inline_for_extraction let read_dtuple2 (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (v1: jumper p1) (r1: leaf_reader p1) (#k2: parser_kind) (#t2: t1 -> Type) (#p2: (x: t1) -> parser k2 (t2 x)) (r2: (x: t1) -> Tot (leaf_reader (p2 x))) : Tot (leaf_reader (parse_dtuple2 p1 p2)) = fun #_ #_ sl pos -> let h = HST.get () in [@inline_let] let _ = valid_dtuple2 h p1 p2 sl pos in let x1 = r1 sl pos in let pos2 = v1 sl pos in let x2 = r2 x1 sl pos2 in (| x1, x2 |) 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) (#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 (x: dtuple2 t1 t2) #_ #_ b pos -> [@inline_let] let _ = serialize_dtuple2_eq s1 s2 x in match x with | (| x1, x2 |) -> serialize32_nondep_then_aux s1' (s2' x1) x1 x2 b pos inline_for_extraction let validate_ret (#t: Type) (v: t) : Tot (validator (parse_ret v)) = validate_total_constant_size (parse_ret v) 0uL () inline_for_extraction let validate_empty () : Tot (validator parse_empty) = validate_ret () inline_for_extraction let validate_false () : Tot (validator parse_false) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_facts parse_false h input (uint64_to_uint32 pos) in validator_error_generic inline_for_extraction let jump_empty : jumper parse_empty = jump_constant_size parse_empty 0ul () inline_for_extraction let jump_false : jumper parse_false = jump_constant_size parse_false 0ul () inline_for_extraction let read_ret (#t: Type) (v: t) : Tot (leaf_reader (parse_ret v)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (parse_ret v) h sl pos in v inline_for_extraction let read_empty : leaf_reader parse_empty = read_ret () inline_for_extraction let read_false : leaf_reader parse_false = fun #rrel #rel sl pos -> LowStar.Failure.failwith "read_false: should not be called" 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 _ #_ #_ _ _ -> 0ul inline_for_extraction let serialize32_empty : serializer32 #_ #_ #parse_empty serialize_empty = serialize32_ret () (fun _ -> ()) inline_for_extraction let serialize32_false : serializer32 #_ #_ #parse_false serialize_false = fun _ #_ #_ _ _ -> 0ul // dummy let valid_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (h: HS.mem) #rrel #rel (input: slice rrel rel) (pos: U32.t) : Lemma ((valid (lift_parser p) h input pos \/ valid (p ()) h input pos) ==> valid (p ()) h input pos /\ valid_content_pos (lift_parser p) h input pos (contents (p ()) h input pos) (get_valid_pos (p ()) h input pos)) = valid_facts (p ()) h input pos; valid_facts (lift_parser p) h input pos inline_for_extraction let validate_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: validator #k #t (p ())) : Tot (validator #k #t (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input (uint64_to_uint32 pos); v input pos inline_for_extraction let jump_lift_parser (#k: parser_kind) (#t: Type) (p: unit -> Tot (parser k t)) (v: jumper (p ())) : Tot (jumper (lift_parser p)) = fun #rrel #rel input pos -> let h = HST.get () in valid_lift_parser p h input pos; v input pos let clens_synth (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t1 t2) = { clens_cond = (fun (x: t1) -> True); clens_get = (fun (x: t1) -> f x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (parse_synth p1 f) p1 (clens_synth g f) input pos')) = synth_injective_synth_inverse_synth_inverse_recip f g (); parse_synth_eq p1 f input; 0 val gaccessor_synth (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor (parse_synth p1 f) p1 (clens_synth g f)) val gaccessor_synth_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth p1 f g u input == gaccessor_synth' p1 f g u input) inline_for_extraction let accessor_synth (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_eq p1 f g u); slice_access_eq h (gaccessor_synth p1 f g u) input pos in pos let clens_synth_inv (#t1: Type) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) : Tot (clens t2 t1) = { clens_cond = (fun (x: t2) -> True); clens_get = (fun (x: t2) -> g x); (* clens_put = (fun (x: t1) (y: t2) -> g y); clens_get_put = (fun (x: t1) (y: t2) -> ()); clens_put_put = (fun (x: t1) (y y' : t2) -> ()); clens_put_get = (fun (x: t1) -> ()); *) } let gaccessor_synth_inv' (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' p1 (parse_synth p1 f) (clens_synth_inv g f) input pos')) = parse_synth_eq p1 f input; 0 val gaccessor_synth_inv (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: squash (synth_inverse f g /\ synth_injective f)) : Tot (gaccessor p1 (parse_synth p1 f) (clens_synth_inv g f)) val gaccessor_synth_inv_eq (#k: parser_kind) (#t1: Type) (p1: parser k t1) (#t2: Type) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) (input: bytes) : Lemma (gaccessor_synth_inv p1 f g u input == gaccessor_synth_inv' p1 f g u input) inline_for_extraction let accessor_synth_inv (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f: t1 -> GTot t2) (g: t2 -> GTot t1) (u: unit { synth_inverse f g /\ synth_injective f } ) : Tot (accessor (gaccessor_synth_inv p1 f g u)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = Classical.forall_intro (gaccessor_synth_inv_eq p1 f g u); slice_access_eq h (gaccessor_synth_inv p1 f g u) input pos in pos let clens_fst (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t1) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = fst; (* clens_put = (fun x y -> (y, snd x)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let clens_snd (t1: Type) (t2: Type) : Tot (clens (t1 & t2) t2) = { clens_cond = (fun (x: (t1 & t2)) -> True); clens_get = snd; (* clens_put = (fun x y -> (fst x, y)); clens_get_put = (fun x y -> ()); clens_put_put = (fun x y y' -> ()); clens_put_get = (fun x -> ()); *) } let gaccessor_fst' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires True) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p1 (clens_fst _ _) input pos')) = nondep_then_eq p1 p2 input; 0 [@"opaque_to_smt"] let gaccessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p1 (clens_fst _ _)) = gaccessor_prop_equiv (p1 `nondep_then` p2) p1 (clens_fst _ _) (gaccessor_fst' p1 sq p2); gaccessor_fst' p1 sq p2 let gaccessor_fst_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_fst p1 sq p2 input == gaccessor_fst' p1 sq p2 input) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2 input) let gaccessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (g: gaccessor p1 p' cl) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (gaccessor (p1 `nondep_then` p2) p' (clens_fst _ _ `clens_compose` cl)) = gaccessor_fst p1 u p2 `gaccessor_compose` g let gaccessor_then_fst (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (g: gaccessor p0 (p1 `nondep_then` p2) cl) : Tot (gaccessor p0 p1 (cl `clens_compose` clens_fst _ _)) = g `gaccessor_compose` gaccessor_fst _ () _ let gaccessor_snd' (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Ghost (nat) (requires (True)) (ensures (fun pos' -> gaccessor_post' (p1 `nondep_then` p2) p2 (clens_snd _ _) input pos')) = nondep_then_eq p1 p2 input; match parse p1 input with | None -> 0 // dummy | Some (_, consumed) -> consumed let gaccessor_snd_injective (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (sl sl' : bytes) : Lemma (requires (gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ injective_precond (p1 `nondep_then` p2) sl sl')) (ensures (gaccessor_snd' p1 p2 sl == gaccessor_snd' p1 p2 sl')) = nondep_then_eq p1 p2 sl; nondep_then_eq p1 p2 sl'; parse_injective p1 sl sl' let gaccessor_snd_no_lookahead (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (sl sl' : bytes) : Lemma (requires ((and_then_kind k1 k2).parser_kind_subkind == Some ParserStrong /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ gaccessor_pre (p1 `nondep_then` p2) p2 (clens_snd _ _) sl /\ no_lookahead_on_precond (p1 `nondep_then` p2) sl sl')) (ensures (gaccessor_snd' p1 p2 sl == gaccessor_snd' p1 p2 sl')) = nondep_then_eq p1 p2 sl; nondep_then_eq p1 p2 sl' ; parse_strong_prefix (p1 `nondep_then` p2) sl sl'; parse_injective p1 sl sl' ; parse_strong_prefix p1 sl sl' [@"opaque_to_smt"] let gaccessor_snd (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (gaccessor (p1 `nondep_then` p2) p2 (clens_snd _ _)) = Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_snd_injective p1 p2 x)); Classical.forall_intro_2 (fun x -> Classical.move_requires (gaccessor_snd_no_lookahead p1 p2 x)); gaccessor_prop_equiv (p1 `nondep_then` p2) p2 (clens_snd _ _) (gaccessor_snd' p1 p2); gaccessor_snd' p1 p2 let gaccessor_snd_eq (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (input: bytes) : Lemma (gaccessor_snd p1 p2 input == gaccessor_snd' p1 p2 input) = reveal_opaque (`%gaccessor_snd) (gaccessor_snd p1 p2 input ) let gaccessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (g: gaccessor p0 (p1 `nondep_then` p2) cl) : Tot (gaccessor p0 p2 (cl `clens_compose` clens_snd _ _)) = g `gaccessor_compose` gaccessor_snd _ _ (* let clens_fst_snd_disjoint (t1 t2: Type) : Lemma (clens_disjoint (clens_fst t1 t2) (clens_snd t1 t2)) = clens_disjoint_l_intro (clens_fst t1 t2) (clens_snd t1 t2) (fun x1 x2 -> ()); clens_disjoint_l_intro (clens_snd t1 t2) (clens_fst t1 t2) (fun x1 x2 -> ()) *) (* abstract let gaccessor_fst_snd_disjoint (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash (k1.parser_kind_subkind == Some ParserStrong)) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Lemma (gaccessors_disjoint (gaccessor_fst p1 sq p2) (gaccessor_snd p1 p2)) = // clens_fst_snd_disjoint t1 t2; gaccessors_disjoint_intro (gaccessor_fst p1 sq p2) (gaccessor_snd p1 p2) (* *) (fun x -> ()) *) inline_for_extraction let accessor_fst (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (sq: squash unit) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (accessor (gaccessor_fst p1 sq p2)) = reveal_opaque (`%gaccessor_fst) (gaccessor_fst p1 sq p2); fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = slice_access_eq h (gaccessor_fst p1 sq p2) input pos in pos inline_for_extraction let accessor_fst_then (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k' : parser_kind) (#t' : Type) (#p': parser k' t') (#cl: clens t1 t') (#g: gaccessor p1 p' cl) (a: accessor g) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash unit) : Tot (accessor (gaccessor_fst_then g p2 u)) = accessor_compose (accessor_fst p1 u p2) a u inline_for_extraction let accessor_then_fst (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) : Tot (accessor (gaccessor_then_fst g)) = accessor_compose a (accessor_fst p1 () p2) () inline_for_extraction let accessor_snd (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (j1: jumper p1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) : Tot (accessor (gaccessor_snd p1 p2)) = reveal_opaque (`%gaccessor_snd) (gaccessor_snd p1 p2); fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_nondep_then h p1 p2 input pos in let res = j1 input pos in [@inline_let] let _ = slice_access_eq h (gaccessor_snd p1 p2) input pos; valid_facts p1 h input pos in res inline_for_extraction let accessor_then_snd (#k0: parser_kind) (#t0: Type) (#p0: parser k0 t0) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#cl: clens t0 (t1 & t2)) (#g: gaccessor p0 (p1 `nondep_then` p2) cl) (a: accessor g) (j1: jumper p1) : Tot (accessor (gaccessor_then_snd g)) = accessor_compose a (accessor_snd j1 p2) () inline_for_extraction let make_total_constant_size_reader (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' : ((#rrel: _) -> (#rel: _) -> (s: B.mbuffer byte rrel rel) -> (pos: U32.t) -> HST.Stack t (requires (fun h -> B.live h s /\ U32.v pos + sz <= B.length s)) (ensures (fun h res h' -> B.modifies B.loc_none h h' /\ res == f (Seq.slice (B.as_seq h s) (U32.v pos) (U32.v pos + sz)) )))) : Tot (leaf_reader (make_total_constant_size_parser sz t f)) = fun #rrel #rel sl pos -> let h = HST.get () in [@inline_let] let _ = valid_facts (make_total_constant_size_parser sz t f) h sl pos in f' sl.base pos let valid_filter (#rrel #rel: _) (h: HS.mem) (#k: parser_kind) (#t: Type) (p: parser k t) (f: (t -> GTot bool)) (input: slice rrel rel) (pos: U32.t) : Lemma ( (valid (parse_filter p f) h input pos \/ (valid p h input pos /\ f (contents p h input pos))) ==> ( valid p h input pos /\ f (contents p h input pos) == true /\ valid_content_pos (parse_filter p f) h input pos (contents p h input pos) (get_valid_pos p h input pos) )) = valid_facts (parse_filter p f) h input pos; valid_facts p h input pos; if U32.v pos <= U32.v input.len then parse_filter_eq p f (bytes_of_slice_from h input pos) inline_for_extraction let validate_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (v32: validator p) (p32: leaf_reader p) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) : Tot (validator (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input (uint64_to_uint32 pos) in let res = v32 input pos in if is_error res then res else let va = p32 input (uint64_to_uint32 pos) in if not (f' va) then validator_error_generic else res inline_for_extraction let validate_filter_with_error_code (#k: parser_kind) (#t: Type0) (#p: parser k t) (v32: validator p) (p32: leaf_reader p) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) (c: error_code) : Tot (validator (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input (uint64_to_uint32 pos) in let res = v32 input pos in if is_error res then maybe_set_validator_error_pos_and_code res pos c else let va = p32 input (uint64_to_uint32 pos) in if not (f' va) then set_validator_error_pos_and_code validator_error_generic pos c else res inline_for_extraction let validate_filter_ret (#t: Type0) (r: t) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) : Tot (validator (parse_filter (parse_ret r) f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h (parse_ret r) f input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_ret r) h input (uint64_to_uint32 pos) in if not (f' r) then validator_error_generic else pos inline_for_extraction let validate_filter_ret_with_error_code (#t: Type0) (r: t) (f: (t -> GTot bool)) (f' : ((x: t) -> Tot (y: bool { y == f x } ))) (c: error_code) : Tot (validator (parse_filter (parse_ret r) f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h (parse_ret r) f input (uint64_to_uint32 pos) in [@inline_let] let _ = valid_facts (parse_ret r) h input (uint64_to_uint32 pos) in if not (f' r) then set_validator_error_pos_and_code validator_error_generic pos c else pos inline_for_extraction let jump_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (j: jumper p) (f: (t -> GTot bool)) : Tot (jumper (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in j input pos inline_for_extraction let read_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> GTot bool)) : Tot (leaf_reader (parse_filter p f)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in (p32 input pos <: (res: t { f res == true } )) // FIXME: WHY WHY WHY do we need this coercion? inline_for_extraction let write_filter (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: leaf_writer_strong s) (f: (t -> GTot bool)) : Tot (leaf_writer_strong (serialize_filter s f)) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialized_length_eq s x in [@inline_let] let _ = serialized_length_eq (serialize_filter s f) x in let res = s32 x input pos in let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in res inline_for_extraction let write_filter_weak (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: leaf_writer_weak s) (f: (t -> GTot bool)) : Tot (leaf_writer_weak (serialize_filter s f)) = fun x #rrel #rel input pos -> [@inline_let] let _ = serialized_length_eq s x in [@inline_let] let _ = serialized_length_eq (serialize_filter s f) x in let res = s32 x input pos in let h = HST.get () in [@inline_let] let _ = valid_filter h p f input pos in 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 (serialize_filter s f)) = fun x #rrel #rel input pos -> s32 x input pos inline_for_extraction let read_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' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = fun #rrel #rel input pos -> let h = HST.get () in [@inline_let] let _ = valid_synth h p1 f2 input pos in let res = p1' input pos in f2' res <: t2 // FIXME: WHY WHY WHY this coercion AND the separate let binding? inline_for_extraction let read_synth' (#k: parser_kind) (#t1: Type) (#t2: Type) (p1: parser k t1) (f2: t1 -> Tot t2) (p1' : leaf_reader p1) (u: unit { synth_injective f2 }) : Tot (leaf_reader (parse_synth p1 f2)) = read_synth p1 f2 (fun x -> f2 x) p1' u inline_for_extraction let read_inline_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' : leaf_reader p1) (u: unit { synth_injective f2 })
false
false
LowParse.Low.Combinators.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val read_inline_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': leaf_reader p1) (u: unit{synth_injective f2}) : Tot (leaf_reader (parse_synth p1 f2))
[]
LowParse.Low.Combinators.read_inline_synth
{ "file_name": "src/lowparse/LowParse.Low.Combinators.fsti", "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.Low.Base.leaf_reader p1 -> u472: u476: Prims.unit{LowParse.Spec.Combinators.synth_injective f2} -> LowParse.Low.Base.leaf_reader (LowParse.Spec.Combinators.parse_synth p1 f2)
{ "end_col": 22, "end_line": 1203, "start_col": 2, "start_line": 1199 }