effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
Prims.Tot
[ { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1)
let error_handler =
false
null
false
typename: string -> fieldname: string -> error_reason: string -> error_code: U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ (loc_not_unused_in h) `loc_includes` (app_loc ctxt eloc_none) /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt eloc_none) /\ (app_loc ctxt eloc_none) `loc_disjoint` (I.footprint sl) /\ U64.v pos <= Seq.length (I.get_read sl h)) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1)
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.string", "FStar.UInt64.t", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.ErrorCode.pos_t", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "EverParse3d.InputStream.Base.live", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.true_inv", "EverParse3d.InputStream.Base.footprint", "LowStar.Monotonic.Buffer.live", "FStar.UInt8.t", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.loc_not_unused_in", "FStar.Ghost.reveal", "LowStar.Monotonic.Buffer.loc", "EverParse3d.Actions.Base.app_loc", "EverParse3d.Actions.Base.eloc_none", "LowStar.Monotonic.Buffer.address_liveness_insensitive_locs", "LowStar.Monotonic.Buffer.loc_disjoint", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt64.v", "FStar.Seq.Base.length", "EverParse3d.InputStream.Base.get_read", "LowStar.Monotonic.Buffer.modifies", "FStar.Ghost.hide" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction
false
true
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val error_handler : Type0
[]
EverParse3d.Actions.Base.error_handler
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
Type0
{ "end_col": 37, "end_line": 159, "start_col": 4, "start_line": 138 }
Prims.Tot
val valid_length (#input_buffer_t: Type0) (#[tcresolve ()] inst: I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop
[ { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end
val valid_length (#input_buffer_t: Type0) (#[tcresolve ()] inst: I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop let valid_length (#input_buffer_t: Type0) (#[tcresolve ()] inst: I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop =
false
null
false
I.live sl h /\ (let s = I.get_remaining sl h in match LP.parse p s with | None -> False | Some (_, len') -> len == len')
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "EverParse3d.InputStream.Base.input_stream_inst", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "FStar.Monotonic.HyperStack.mem", "Prims.int", "Prims.l_and", "EverParse3d.InputStream.Base.live", "LowParse.Spec.Base.parse", "Prims.l_False", "LowParse.Spec.Base.consumed_length", "Prims.eq2", "Prims.logical", "FStar.Seq.Base.seq", "FStar.UInt8.t", "EverParse3d.InputStream.Base.get_remaining", "Prims.prop" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_length (#input_buffer_t: Type0) (#[tcresolve ()] inst: I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop
[]
EverParse3d.Actions.Base.valid_length
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Spec.Base.parser k t -> h: FStar.Monotonic.HyperStack.mem -> sl: input_buffer_t -> len: Prims.int -> Prims.prop
{ "end_col": 5, "end_line": 122, "start_col": 2, "start_line": 115 }
FStar.HyperStack.ST.Stack
val validate_list_body (#[FStar.Tactics.Typeclasses.tcresolve ()] _extra_t: I.extra_t #input_buffer_t) (#k: LP.parser_kind) (#t: _) (#p: LP.parser k t) (#inv #l #ar: _) (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res))
[ { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end
val validate_list_body (#[FStar.Tactics.Typeclasses.tcresolve ()] _extra_t: I.extra_t #input_buffer_t) (#k: LP.parser_kind) (#t: _) (#p: LP.parser k t) (#inv #l #ar: _) (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res)) let validate_list_body (#[FStar.Tactics.Typeclasses.tcresolve ()] _extra_t: I.extra_t #input_buffer_t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0: Ghost.erased HS.mem) (g1: Ghost.erased HS.mem) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res)) =
true
null
false
let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !*bres in if not (I.has sl sl_len position 1uL) then true else let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[]
[ "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "Prims.bool", "EverParse3d.Actions.Base.validate_with_action_t'", "FStar.Ghost.erased", "FStar.Monotonic.HyperStack.mem", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "LowStar.Buffer.pointer", "FStar.UInt64.t", "EverParse3d.ErrorCode.is_error", "Prims.unit", "LowStar.Monotonic.Buffer.upd", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.__uint_to_t", "EverParse3d.Actions.Base.validate_drop", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Ghost.reveal", "FStar.HyperStack.ST.get", "Prims.op_Negation", "EverParse3d.InputStream.Base.has", "FStar.UInt64.__uint_to_t", "LowStar.BufferOps.op_Bang_Star", "LowParse.Spec.List.parse_list_eq", "EverParse3d.InputStream.Base.get_remaining", "EverParse3d.Actions.Base.validate_list_inv", "Prims.l_and" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_list_body (#[FStar.Tactics.Typeclasses.tcresolve ()] _extra_t: I.extra_t #input_buffer_t) (#k: LP.parser_kind) (#t: _) (#p: LP.parser k t) (#inv #l #ar: _) (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res))
[]
EverParse3d.Actions.Base.validate_list_body
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v: EverParse3d.Actions.Base.validate_with_action_t' p inv l ar -> g0: FStar.Ghost.erased FStar.Monotonic.HyperStack.mem -> g1: FStar.Ghost.erased FStar.Monotonic.HyperStack.mem -> ctxt: EverParse3d.Actions.Base.app_ctxt -> error_handler_fn: EverParse3d.Actions.Base.error_handler -> sl: EverParse3d.Actions.Base.input_buffer_t -> sl_len: EverParse3d.InputStream.Base.tlen sl -> bres: LowStar.Buffer.pointer FStar.UInt64.t -> FStar.HyperStack.ST.Stack Prims.bool
{ "end_col": 5, "end_line": 858, "start_col": 1, "start_line": 846 }
Prims.Tot
val action (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:Type) (p:parser k t) (inv:slice_inv) (l:eloc) (on_success:bool) (a:Type) : Type0
[ { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1)
val action (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:Type) (p:parser k t) (inv:slice_inv) (l:eloc) (on_success:bool) (a:Type) : Type0 let action p inv l on_success a =
false
null
false
#[tcresolve ()] I.extra_t #input_buffer_t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ (loc_not_unused_in h) `loc_includes` (app_loc ctxt l) /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt l) /\ (app_loc ctxt l) `loc_disjoint` (I.footprint sl) /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h)) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1)
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.ErrorCode.pos_t", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "EverParse3d.InputStream.Base.live", "EverParse3d.InputStream.Base.footprint", "LowStar.Monotonic.Buffer.live", "FStar.UInt8.t", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.loc_not_unused_in", "FStar.Ghost.reveal", "LowStar.Monotonic.Buffer.loc", "EverParse3d.Actions.Base.app_loc", "LowStar.Monotonic.Buffer.address_liveness_insensitive_locs", "LowStar.Monotonic.Buffer.loc_disjoint", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt64.v", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt64.n", "FStar.Seq.Base.length", "EverParse3d.InputStream.Base.get_read", "LowStar.Monotonic.Buffer.modifies", "FStar.Ghost.hide" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a
false
true
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val action (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#t:Type) (p:parser k t) (inv:slice_inv) (l:eloc) (on_success:bool) (a:Type) : Type0
[]
EverParse3d.Actions.Base.action
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: EverParse3d.Prelude.parser k t -> inv: EverParse3d.Actions.Base.slice_inv -> l: EverParse3d.Actions.Base.eloc -> on_success: Prims.bool -> a: Type -> Type0
{ "end_col": 32, "end_line": 78, "start_col": 4, "start_line": 58 }
Prims.Tot
val leaf_reader (#nz:bool) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (p: parser k t) : Type u#0
[ { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end ))
val leaf_reader (#nz:bool) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (p: parser k t) : Type u#0 let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type =
false
null
false
(#[FStar.Tactics.Typeclasses.tcresolve ()] _extra_t: I.extra_t #input_buffer_t) -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h))) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ (match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) )))
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.bool", "EverParse3d.Kinds.parser_kind", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Prelude.parser", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.ErrorCode.pos_t", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "EverParse3d.Actions.Base.valid", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt64.n", "FStar.UInt64.v", "FStar.Seq.Base.length", "FStar.UInt8.t", "EverParse3d.InputStream.Base.get_read", "EverParse3d.InputStream.Base.live", "LowStar.Monotonic.Buffer.modifies", "EverParse3d.InputStream.Base.perm_footprint", "LowParse.Spec.Base.parse", "Prims.l_False", "LowParse.Spec.Base.consumed_length", "FStar.Seq.Base.seq", "EverParse3d.InputStream.Base.get_remaining", "FStar.Seq.Base.slice", "Prims.logical" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val leaf_reader (#nz:bool) (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (p: parser k t) : Type u#0
[]
EverParse3d.Actions.Base.leaf_reader
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: EverParse3d.Prelude.parser k t -> Type0
{ "end_col": 4, "end_line": 237, "start_col": 2, "start_line": 219 }
Prims.Tot
val validate_with_dep_action (name: string) (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) (#[@@@erasable] inva:slice_inv) (#[@@@erasable] la:eloc) (a: t -> action p inva la b bool) : validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false
[ { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end
val validate_with_dep_action (name: string) (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) (#[@@@erasable] inva:slice_inv) (#[@@@erasable] la:eloc) (a: t -> action p inva la b bool) : validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false let validate_with_dep_action (name: string) #nz (#k: parser_kind nz _) (#t: _) (#p: parser k t) #inv #l (v: validate_with_action_t p inv l true) (r: leaf_reader p) (#b: bool) #inva (#la: eloc) (a: (t -> action p inva la b bool)) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) =
false
null
false
fun ctxt error_handler_fn input input_length start_position -> [@@ inline_let ]let pos0 = start_position in let h = HST.get () in [@@ (rename_let ("positionAfter" ^ name)) ]let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else [@@ (rename_let ("" ^ name)) ]let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.string", "Prims.bool", "EverParse3d.Kinds.parser_kind", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Actions.Base.leaf_reader", "EverParse3d.Actions.Base.action", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "EverParse3d.ErrorCode.is_error", "FStar.UInt64.t", "EverParse3d.ErrorCode.set_validator_error_pos", "EverParse3d.ErrorCode.validator_error_action_failed", "Prims.unit", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "EverParse3d.Actions.Base.conj_inv", "EverParse3d.Actions.Base.eloc_union" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_with_dep_action (name: string) (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) (#[@@@erasable] inva:slice_inv) (#[@@@erasable] la:eloc) (a: t -> action p inva la b bool) : validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false
[]
EverParse3d.Actions.Base.validate_with_dep_action
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
name: Prims.string -> v: EverParse3d.Actions.Base.validate_with_action_t p inv l true -> r: EverParse3d.Actions.Base.leaf_reader p -> a: (_: t -> EverParse3d.Actions.Base.action p inva la b Prims.bool) -> EverParse3d.Actions.Base.validate_with_action_t p (EverParse3d.Actions.Base.conj_inv inv inva) (EverParse3d.Actions.Base.eloc_union l la) false
{ "end_col": 7, "end_line": 731, "start_col": 4, "start_line": 715 }
Prims.Tot
val validate_drop (#k: LP.parser_kind) (#t: Type) (#p: LP.parser k t) (#inv: slice_inv) (#l: eloc) (#allow_reading: _) (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false)
[ { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v
val validate_drop (#k: LP.parser_kind) (#t: Type) (#p: LP.parser k t) (#inv: slice_inv) (#l: eloc) (#allow_reading: _) (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) let validate_drop (#k: LP.parser_kind) (#t: Type) (#p: LP.parser k t) (#inv: slice_inv) (#l: eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) =
false
null
false
if allow_reading then validate_drop_true v else v
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "Prims.bool", "EverParse3d.Actions.Base.validate_with_action_t'", "EverParse3d.Actions.Base.validate_drop_true" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_drop (#k: LP.parser_kind) (#t: Type) (#p: LP.parser k t) (#inv: slice_inv) (#l: eloc) (#allow_reading: _) (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false)
[]
EverParse3d.Actions.Base.validate_drop
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v: EverParse3d.Actions.Base.validate_with_action_t' p inv l allow_reading -> EverParse3d.Actions.Base.validate_with_action_t' p inv l false
{ "end_col": 8, "end_line": 284, "start_col": 2, "start_line": 282 }
Prims.Tot
val validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#[@@@erasable] inv1':slice_inv) (#[@@@erasable] l1':eloc) (#b:_) (a:t1 -> action p1 inv1' l1' b bool) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#[@@@erasable] t2:refine _ f -> Type) (#[@@@erasable] p2:(x:refine _ f -> parser k2 (t2 x))) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#allow_reading2:bool) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 allow_reading2)) : validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false
[ { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2
val validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#[@@@erasable] inv1':slice_inv) (#[@@@erasable] l1':eloc) (#b:_) (a:t1 -> action p1 inv1' l1' b bool) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#[@@@erasable] t2:refine _ f -> Type) (#[@@@erasable] p2:(x:refine _ f -> parser k2 (t2 x))) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#allow_reading2:bool) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 allow_reading2)) : validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1: parser_kind nz1 _) #t1 (#p1: parser k1 t1) #inv1 #l1 (v1: validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: (t1 -> bool)) #inv1' #l1' #b (a: (t1 -> action p1 inv1' l1' b bool)) #nz2 #wk2 (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) =
false
null
false
if (p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0)) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.bool", "Prims.string", "EverParse3d.Kinds.parser_kind", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Actions.Base.leaf_reader", "EverParse3d.Actions.Base.action", "EverParse3d.Kinds.weak_kind", "EverParse3d.Prelude.refine", "LowParse.Spec.Base.bool_and", "Prims.op_Equality", "FStar.Pervasives.Native.option", "Prims.nat", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.parser_kind_metadata_some", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_metadata", "LowParse.Spec.Base.ParserKindMetadataTotal", "EverParse3d.Actions.Base.validate_dep_pair_with_refinement_and_action_total_zero_parser'", "EverParse3d.Actions.Base.validate_dep_pair_with_refinement_and_action'", "Prims.op_BarBar", "EverParse3d.Kinds.and_then_kind", "EverParse3d.Kinds.filter_kind", "Prims.dtuple2", "EverParse3d.Prelude.parse_dep_pair", "EverParse3d.Prelude.parse_filter", "EverParse3d.Actions.Base.conj_inv", "EverParse3d.Actions.Base.eloc_union" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2))
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#[@@@erasable] inv1':slice_inv) (#[@@@erasable] l1':eloc) (#b:_) (a:t1 -> action p1 inv1' l1' b bool) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#[@@@erasable] t2:refine _ f -> Type) (#[@@@erasable] p2:(x:refine _ f -> parser k2 (t2 x))) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#allow_reading2:bool) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 allow_reading2)) : validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false
[]
EverParse3d.Actions.Base.validate_dep_pair_with_refinement_and_action
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p1_is_constant_size_without_actions: Prims.bool -> name1: Prims.string -> v1: EverParse3d.Actions.Base.validate_with_action_t p1 inv1 l1 true -> r1: EverParse3d.Actions.Base.leaf_reader p1 -> f: (_: t1 -> Prims.bool) -> a: (_: t1 -> EverParse3d.Actions.Base.action p1 inv1' l1' b Prims.bool) -> v2: (x: EverParse3d.Prelude.refine t1 f -> EverParse3d.Actions.Base.validate_with_action_t (p2 x) inv2 l2 allow_reading2) -> EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_dep_pair (EverParse3d.Prelude.parse_filter p1 f) p2) (EverParse3d.Actions.Base.conj_inv inv1 (EverParse3d.Actions.Base.conj_inv inv1' inv2)) (EverParse3d.Actions.Base.eloc_union l1 (EverParse3d.Actions.Base.eloc_union l1' l2)) false
{ "end_col": 70, "end_line": 499, "start_col": 4, "start_line": 492 }
Prims.Tot
val validate_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) (v:validate_with_action_t p inv l allow_reading) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l allow_reading
[ { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k)
val validate_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) (v:validate_with_action_t p inv l allow_reading) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l allow_reading let validate_weaken_left (#nz: _) #wk (#k: parser_kind nz wk) (#t: _) (#p: parser k t) (#inv: _) (#l: _) #ar (v: validate_with_action_t p inv l ar) (#nz': _) #wk' (k': parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar =
false
null
false
validate_weaken v (glb k' k)
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Actions.Base.validate_weaken", "Prims.op_AmpAmp", "EverParse3d.Kinds.weak_kind_glb", "EverParse3d.Kinds.glb", "EverParse3d.Prelude.parse_weaken_left" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk')
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_weaken_left (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) (v:validate_with_action_t p inv l allow_reading) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l allow_reading
[]
EverParse3d.Actions.Base.validate_weaken_left
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v: EverParse3d.Actions.Base.validate_with_action_t p inv l allow_reading -> k': EverParse3d.Kinds.parser_kind nz' wk' -> EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_weaken_left p k') inv l allow_reading
{ "end_col": 32, "end_line": 749, "start_col": 4, "start_line": 749 }
Prims.Tot
val validate_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) (v:validate_with_action_t p inv l allow_reading) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l allow_reading
[ { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k')
val validate_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) (v:validate_with_action_t p inv l allow_reading) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l allow_reading let validate_weaken_right (#nz: _) #wk (#k: parser_kind nz wk) (#t: _) (#p: parser k t) (#inv: _) (#l: _) #ar (v: validate_with_action_t p inv l ar) (#nz': _) #wk' (k': parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar =
false
null
false
validate_weaken v (glb k k')
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Actions.Base.validate_weaken", "Prims.op_AmpAmp", "EverParse3d.Kinds.weak_kind_glb", "EverParse3d.Kinds.glb", "EverParse3d.Prelude.parse_weaken_right" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk')
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_weaken_right (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) (v:validate_with_action_t p inv l allow_reading) (#nz':_) (#wk': _) (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l allow_reading
[]
EverParse3d.Actions.Base.validate_weaken_right
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v: EverParse3d.Actions.Base.validate_with_action_t p inv l allow_reading -> k': EverParse3d.Kinds.parser_kind nz' wk' -> EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_weaken_right p k') inv l allow_reading
{ "end_col": 32, "end_line": 758, "start_col": 4, "start_line": 758 }
Prims.Tot
val validate_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) (v: validate_with_action_t p inv l allow_reading) : validate_with_action_t (parse_nlist n p) inv l false
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist
val validate_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) (v: validate_with_action_t p inv l allow_reading) : validate_with_action_t (parse_nlist n p) inv l false let validate_nlist (n: U32.t) #wk (#k: parser_kind true wk) #t (#p: parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) =
false
null
false
validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "FStar.UInt32.t", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "Prims.bool", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Actions.Base.validate_weaken", "EverParse3d.Kinds.WeakKindStrongPrefix", "LowParse.Spec.FLData.parse_fldata_kind", "FStar.UInt32.v", "LowParse.Spec.List.parse_list_kind", "Prims.list", "LowParse.Spec.FLData.parse_fldata", "LowParse.Spec.List.parse_list", "EverParse3d.Actions.Base.validate_fldata_consumes_all", "EverParse3d.Actions.Base.validate_list", "EverParse3d.Kinds.kind_nlist", "EverParse3d.Prelude.nlist", "EverParse3d.Prelude.parse_nlist" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_nlist (n:U32.t) (#wk: _) (#k:parser_kind true wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) (v: validate_with_action_t p inv l allow_reading) : validate_with_action_t (parse_nlist n p) inv l false
[]
EverParse3d.Actions.Base.validate_nlist
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
n: FStar.UInt32.t -> v: EverParse3d.Actions.Base.validate_with_action_t p inv l allow_reading -> EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_nlist n p) inv l false
{ "end_col": 14, "end_line": 1033, "start_col": 2, "start_line": 1030 }
Prims.Tot
val validate_all_zeros : validate_with_action_t parse_all_zeros true_inv eloc_none false
[ { "abbrev": true, "full_module": "LowParse.Low.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_all_zeros = validate_list (validate_filter "parse_zeros" validate____UINT8 read____UINT8 is_zero "check if zero" "")
val validate_all_zeros : validate_with_action_t parse_all_zeros true_inv eloc_none false let validate_all_zeros =
false
null
false
validate_list (validate_filter "parse_zeros" validate____UINT8 read____UINT8 is_zero "check if zero" "")
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "EverParse3d.Actions.Base.validate_list", "EverParse3d.Kinds.filter_kind", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Kinds.kind____UINT8", "EverParse3d.Prelude.refine", "EverParse3d.Prelude.___UINT8", "EverParse3d.Prelude.is_zero", "EverParse3d.Prelude.parse_filter", "EverParse3d.Prelude.parse____UINT8", "EverParse3d.Actions.Base.true_inv", "EverParse3d.Actions.Base.eloc_none", "EverParse3d.Actions.Base.validate_filter", "EverParse3d.Actions.Base.validate____UINT8", "EverParse3d.Actions.Base.read____UINT8" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL inline_for_extraction noextract let validate____UINT16 : validator parse____UINT16 = validate_with_comment "Checking that we have enough space for a UINT16, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16 2uL () _ _) inline_for_extraction noextract let read____UINT16 : leaf_reader parse____UINT16 = lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL inline_for_extraction noextract let validate____UINT32 : validator parse____UINT32 = validate_with_comment "Checking that we have enough space for a UINT32, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32 4uL () _ _) inline_for_extraction noextract let read____UINT32 : leaf_reader parse____UINT32 = lift_reader _ LowParse.Low.BoundedInt.read_u32_le 4ul 4uL inline_for_extraction noextract let validate____UINT64 : validator parse____UINT64 = validate_with_comment "Checking that we have enough space for a UINT64, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64 8uL () _ _) inline_for_extraction noextract let read____UINT64 : leaf_reader parse____UINT64 = lift_reader _ LowParse.Low.Int.read_u64_le 8ul 8uL inline_for_extraction noextract let validate_unit = fun _ _ input _ start_position -> start_position inline_for_extraction noextract let read_unit = fun input pos -> () inline_for_extraction noextract let validate_unit_refinement (f:unit -> bool) (cf:string) : validator (parse_unit `parse_filter` f) = fun _ _ input _ start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq parse_unit f (I.get_remaining input h); LowStar.Comment.comment cf; if f () then pos else LPE.set_validator_error_pos LPE.validator_error_constraint_failed pos (* Reimplement validate_list_up_to with readability (but no actions) *) module LUT = LowParse.Low.ListUpTo unfold let validate_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let res = B.deref h bres in let q = LUT.parse_list_up_to (cond_string_up_to terminator) p prf in B.live h0 bres /\ I.live sl h0 /\ I.live sl h /\ B.loc_disjoint (I.footprint sl) (B.loc_buffer bres `B.loc_union` app_loc ctxt loc_none) /\ B.loc_disjoint (B.loc_buffer bres) (app_loc ctxt loc_none) /\ B.live h0 ctxt /\ B.live h ctxt /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt loc_none) /\ B.modifies (B.loc_buffer bres `B.loc_union` I.perm_footprint sl `B.loc_union` app_loc ctxt loc_none) h0 h /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) /\ begin if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse q s)) else U64.v res == Seq.length (I.get_read sl h) /\ begin if stop then valid_consumed q h0 h sl else match LP.parse q s, LP.parse q s' with | None, None -> True | Some (_, consumed), Some (_, consumed') -> consumed' + Seq.length s - Seq.length s' == consumed | _ -> False end end end inline_for_extraction let validate_list_up_to_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (v: validator p) (r: leaf_reader p) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (h0: HS.mem) (bres: B.pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false )) (ensures (fun h stop h' -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false /\ validate_list_up_to_inv p terminator prf ctxt sl h0 bres h' stop )) = let h = HST.get () in LUT.parse_list_up_to_eq (cond_string_up_to terminator) p prf (I.get_remaining sl h); let position = !* bres in let result = v ctxt error_handler_fn sl sl_len position in B.upd bres 0ul result; if LPE.is_error result then begin true end else begin let value = r sl position in cond_string_up_to terminator value end inline_for_extraction noextract let validate_list_up_to (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (v: validator p) (r: leaf_reader p) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) : Tot (validate_with_action_t #true #WeakKindStrongPrefix (LUT.parse_list_up_to (cond_string_up_to terminator) p prf) true_inv eloc_none false) = fun ctxt error_handler_fn sl sl_len pos -> let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in fresh_frame_modifies h0 h1; let bres = B.alloca pos 1ul in let h2 = HST.get () in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_up_to_inv p terminator prf ctxt sl h2 bres) (fun _ -> validate_list_up_to_body terminator prf v r ctxt error_handler_fn sl sl_len h2 bres) ; let result = B.index bres 0ul in HST.pop_frame (); result let validate_string #k #t #p v r terminator = LP.parser_kind_prop_equiv k p; validate_weaken (validate_list_up_to v r terminator (fun _ _ _ -> ())) _ let validate_all_bytes = fun _ _ input input_length start_position -> I.empty input input_length start_position
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_all_zeros : validate_with_action_t parse_all_zeros true_inv eloc_none false
[]
EverParse3d.Actions.Base.validate_all_zeros
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
EverParse3d.Actions.Base.validate_with_action_t EverParse3d.Prelude.parse_all_zeros EverParse3d.Actions.Base.true_inv EverParse3d.Actions.Base.eloc_none false
{ "end_col": 106, "end_line": 1582, "start_col": 2, "start_line": 1582 }
Prims.Pure
val validate_nlist_total_constant_size_mod_ok (n: U32.t) (#wk: _) (#k: parser_kind true wk) (#t: Type) (p: parser k t) (inv l: _) : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires (let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0)) (ensures (fun _ -> True))
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l
val validate_nlist_total_constant_size_mod_ok (n: U32.t) (#wk: _) (#k: parser_kind true wk) (#t: Type) (p: parser k t) (inv l: _) : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires (let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0)) (ensures (fun _ -> True)) let validate_nlist_total_constant_size_mod_ok (n: U32.t) #wk (#k: parser_kind true wk) (#t: Type) (p: parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires (let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0)) (ensures (fun _ -> True)) =
false
null
false
[@@ inline_let ]let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[]
[ "FStar.UInt32.t", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_total_constant_size_no_read'", "LowParse.Spec.Base.total_constant_size_parser_kind", "FStar.UInt32.v", "EverParse3d.Prelude.nlist", "LowParse.Spec.Base.strengthen", "EverParse3d.Prelude.parse_nlist", "FStar.Int.Cast.uint32_to_uint64", "Prims.unit", "EverParse3d.Prelude.parse_nlist_total_fixed_size_kind_correct", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Kinds.kind_nlist", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.nat", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "LowParse.Spec.Base.parser_kind_metadata_some", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_metadata", "LowParse.Spec.Base.ParserKindMetadataTotal", "Prims.b2t", "Prims.op_LessThan", "Prims.int", "Prims.op_Modulus", "Prims.l_True" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 ))
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_nlist_total_constant_size_mod_ok (n: U32.t) (#wk: _) (#k: parser_kind true wk) (#t: Type) (p: parser k t) (inv l: _) : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires (let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0)) (ensures (fun _ -> True))
[]
EverParse3d.Actions.Base.validate_nlist_total_constant_size_mod_ok
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
n: FStar.UInt32.t -> p: EverParse3d.Prelude.parser k t -> inv: EverParse3d.Actions.Base.slice_inv -> l: EverParse3d.Actions.Base.eloc -> Prims.Pure (EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_nlist n p) inv l true)
{ "end_col": 155, "end_line": 1093, "start_col": 2, "start_line": 1089 }
Prims.Tot
val validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) (inv l: _) : Tot (validate_with_action_t' p inv l true)
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos
val validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) (inv l: _) : Tot (validate_with_action_t' p inv l true) let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) =
false
null
false
fun ctxt error_handler_fn input input_length start_position -> [@@ inline_let ]let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "FStar.UInt64.t", "Prims.unit", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "Prims.nat", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt64.n", "FStar.UInt64.v", "LowParse.Spec.Base.parser_kind_metadata_some", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_metadata", "LowParse.Spec.Base.ParserKindMetadataTotal", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "FStar.UInt64.add", "Prims.bool", "EverParse3d.ErrorCode.set_validator_error_pos", "EverParse3d.ErrorCode.validator_error_not_enough_data", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "EverParse3d.InputStream.Base.has", "LowParse.Spec.Base.parser_kind_prop_equiv", "EverParse3d.Actions.Base.validate_with_action_t'" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) (inv l: _) : Tot (validate_with_action_t' p inv l true)
[]
EverParse3d.Actions.Base.validate_total_constant_size_no_read'
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: LowParse.Spec.Base.parser k t -> sz: FStar.UInt64.t -> u515: u518: Prims.unit { Mkparser_kind'?.parser_kind_high k == FStar.Pervasives.Native.Some (Mkparser_kind'?.parser_kind_low k) /\ Mkparser_kind'?.parser_kind_low k == FStar.UInt64.v sz /\ Mkparser_kind'?.parser_kind_metadata k == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserKindMetadataTotal } -> inv: EverParse3d.Actions.Base.slice_inv -> l: EverParse3d.Actions.Base.eloc -> EverParse3d.Actions.Base.validate_with_action_t' p inv l true
{ "end_col": 74, "end_line": 1058, "start_col": 2, "start_line": 1049 }
Prims.Pure
val validate_nlist_total_constant_size (n_is_const: bool) (n: U32.t) (#wk: _) (#k: parser_kind true wk) (#t: Type) (p: parser k t) (inv l: _) : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires (let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296)) (ensures (fun _ -> True))
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l
val validate_nlist_total_constant_size (n_is_const: bool) (n: U32.t) (#wk: _) (#k: parser_kind true wk) (#t: Type) (p: parser k t) (inv l: _) : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires (let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296)) (ensures (fun _ -> True)) let validate_nlist_total_constant_size (n_is_const: bool) (n: U32.t) #wk (#k: parser_kind true wk) (#t: Type) (p: parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires (let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296)) (ensures (fun _ -> True)) =
false
null
false
if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[]
[ "Prims.bool", "FStar.UInt32.t", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "Prims.op_Equality", "Prims.int", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "Prims.op_Modulus", "FStar.UInt32.v", "EverParse3d.Actions.Base.validate_nlist_total_constant_size_mod_ok", "Prims.op_disEquality", "EverParse3d.Actions.Base.validate_nlist_constant_size_mod_ko", "EverParse3d.Actions.Base.validate_nlist_total_constant_size'", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Kinds.kind_nlist", "EverParse3d.Prelude.nlist", "EverParse3d.Prelude.parse_nlist", "Prims.l_and", "Prims.b2t", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.nat", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "LowParse.Spec.Base.parser_kind_metadata_some", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_metadata", "LowParse.Spec.Base.ParserKindMetadataTotal", "Prims.op_LessThan", "Prims.l_True" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True))
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_nlist_total_constant_size (n_is_const: bool) (n: U32.t) (#wk: _) (#k: parser_kind true wk) (#t: Type) (p: parser k t) (inv l: _) : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires (let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296)) (ensures (fun _ -> True))
[]
EverParse3d.Actions.Base.validate_nlist_total_constant_size
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
n_is_const: Prims.bool -> n: FStar.UInt32.t -> p: EverParse3d.Prelude.parser k t -> inv: EverParse3d.Actions.Base.slice_inv -> l: EverParse3d.Actions.Base.eloc -> Prims.Pure (EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_nlist n p) inv l true)
{ "end_col": 49, "end_line": 1169, "start_col": 2, "start_line": 1154 }
Prims.Pure
val validate_dep_pair_with_refinement_total_zero_parser' (name1: string) (#nz1: _) (#k1: parser_kind nz1 _) (#t1: _) (#p1: parser k1 t1) (inv1 l1: _) (r1: leaf_reader p1) (f: (t1 -> bool)) (#nz2 #wk2: _) (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) (#inv2 #l2 #ar2: _) (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires (let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal)) (ensures (fun _ -> True))
[ { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end
val validate_dep_pair_with_refinement_total_zero_parser' (name1: string) (#nz1: _) (#k1: parser_kind nz1 _) (#t1: _) (#p1: parser k1 t1) (inv1 l1: _) (r1: leaf_reader p1) (f: (t1 -> bool)) (#nz2 #wk2: _) (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) (#inv2 #l2 #ar2: _) (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires (let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal)) (ensures (fun _ -> True)) let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1: parser_kind nz1 _) #t1 (#p1: parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: (t1 -> bool)) #nz2 #wk2 (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires (let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal)) (ensures (fun _ -> True)) =
false
null
false
fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@@ inline_let ]let _ = LP.parser_kind_prop_equiv k1 p1 in LowStar.Comment.comment ("Validating field " ^ name1); [@@ (rename_let ("" ^ name1)) ]let field_value = r1 input startPosition in [@@ (rename_let (name1 ^ "ConstraintIsOk")) ]let ok = f field_value in [@@ (rename_let ("positionAfter" ^ name1)) ]let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h2; let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[]
[ "Prims.string", "Prims.bool", "EverParse3d.Kinds.parser_kind", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.leaf_reader", "EverParse3d.Kinds.weak_kind", "EverParse3d.Prelude.refine", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "EverParse3d.ErrorCode.is_error", "FStar.UInt64.t", "EverParse3d.Actions.Base.validate_drop", "Prims.unit", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "EverParse3d.ErrorCode.check_constraint_ok", "LowStar.Comment.comment", "Prims.op_Hat", "LowParse.Spec.Base.parser_kind_prop_equiv", "LowParse.Spec.Combinators.parse_filter_eq", "EverParse3d.InputStream.Base.get_remaining", "LowParse.Spec.Combinators.parse_dtuple2_eq'", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.Combinators.parse_filter", "Prims.op_BarBar", "EverParse3d.Kinds.and_then_kind", "Prims.dtuple2", "EverParse3d.Prelude.parse_dep_pair", "EverParse3d.Actions.Base.conj_inv", "EverParse3d.Actions.Base.eloc_union", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "Prims.nat", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.parser_kind_metadata_some", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_metadata", "LowParse.Spec.Base.ParserKindMetadataTotal", "Prims.l_True" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal ))
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_dep_pair_with_refinement_total_zero_parser' (name1: string) (#nz1: _) (#k1: parser_kind nz1 _) (#t1: _) (#p1: parser k1 t1) (inv1 l1: _) (r1: leaf_reader p1) (f: (t1 -> bool)) (#nz2 #wk2: _) (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) (#inv2 #l2 #ar2: _) (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires (let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal)) (ensures (fun _ -> True))
[]
EverParse3d.Actions.Base.validate_dep_pair_with_refinement_total_zero_parser'
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
name1: Prims.string -> inv1: EverParse3d.Actions.Base.slice_inv -> l1: EverParse3d.Actions.Base.eloc -> r1: EverParse3d.Actions.Base.leaf_reader p1 -> f: (_: t1 -> Prims.bool) -> v2: (x: EverParse3d.Prelude.refine t1 f -> EverParse3d.Actions.Base.validate_with_action_t (p2 x) inv2 l2 ar2) -> Prims.Pure (EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_dep_pair (LowParse.Spec.Combinators.parse_filter p1 f) p2) (EverParse3d.Actions.Base.conj_inv inv1 inv2) (EverParse3d.Actions.Base.eloc_union l1 l2) false)
{ "end_col": 11, "end_line": 626, "start_col": 4, "start_line": 602 }
Prims.Tot
val validate_with_error_handler (typename: string) (fieldname: string) (#nz: _) (#wk: _) (#k1:parser_kind nz wk) (#[@@@erasable] t1: Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar
[ { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 )
val validate_with_error_handler (typename: string) (fieldname: string) (#nz: _) (#wk: _) (#k1:parser_kind nz wk) (#[@@@erasable] t1: Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar let validate_with_error_handler (typename: string) (fieldname: string) #nz #wk (#k1: parser_kind nz wk) #t1 (#p1: parser k1 t1) (#inv1: _) (#l1: eloc) (#ar: _) (v1: validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar =
false
null
false
fun ctxt error_handler_fn input input_length start_position -> [@@ inline_let ]let pos0 = start_position in let h0 = HST.get () in [@@ (rename_let ("positionAfter" ^ typename)) ]let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else (error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1)
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.string", "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "EverParse3d.ErrorCode.is_success", "FStar.UInt64.t", "Prims.unit", "EverParse3d.ErrorCode.error_reason_of_result", "EverParse3d.ErrorCode.get_validator_error_kind", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_with_error_handler (typename: string) (fieldname: string) (#nz: _) (#wk: _) (#k1:parser_kind nz wk) (#[@@@erasable] t1: Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar
[]
EverParse3d.Actions.Base.validate_with_error_handler
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
typename: Prims.string -> fieldname: Prims.string -> v1: EverParse3d.Actions.Base.validate_with_action_t p1 inv1 l1 ar -> EverParse3d.Actions.Base.validate_with_action_t p1 inv1 l1 ar
{ "end_col": 5, "end_line": 315, "start_col": 4, "start_line": 303 }
Prims.Pure
val validate_nlist_total_constant_size' (n: U32.t) (#wk: _) (#k: parser_kind true wk) (#t: _) (p: parser k t) (inv l: _) : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires (let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296)) (ensures (fun _ -> True))
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position
val validate_nlist_total_constant_size' (n: U32.t) (#wk: _) (#k: parser_kind true wk) (#t: _) (p: parser k t) (inv l: _) : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires (let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296)) (ensures (fun _ -> True)) let validate_nlist_total_constant_size' (n: U32.t) #wk (#k: parser_kind true wk) #t (p: parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires (let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296)) (ensures (fun _ -> True)) =
false
null
false
fun ctxt error_handler_fn input start_position -> if n `U32.rem` (U32.uint_to_t k.LP.parser_kind_low) = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[]
[ "FStar.UInt32.t", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "Prims.op_Equality", "FStar.UInt32.rem", "FStar.UInt32.uint_to_t", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "FStar.UInt32.__uint_to_t", "EverParse3d.Actions.Base.validate_nlist_total_constant_size_mod_ok", "Prims.bool", "EverParse3d.Actions.Base.validate_nlist_constant_size_mod_ko", "EverParse3d.ErrorCode.pos_t", "FStar.UInt64.t", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "EverParse3d.InputStream.Base.live", "EverParse3d.InputStream.Base.footprint", "LowStar.Monotonic.Buffer.live", "FStar.UInt8.t", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.loc_not_unused_in", "FStar.Ghost.reveal", "LowStar.Monotonic.Buffer.loc", "EverParse3d.Actions.Base.app_loc", "LowStar.Monotonic.Buffer.address_liveness_insensitive_locs", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt64.n", "FStar.UInt64.v", "FStar.Seq.Base.length", "EverParse3d.InputStream.Base.get_read", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_union", "EverParse3d.InputStream.Base.perm_footprint", "Prims.l_imp", "Prims.l_not", "EverParse3d.ErrorCode.is_error", "EverParse3d.ErrorCode.get_validator_error_pos", "EverParse3d.ErrorCode.is_success", "EverParse3d.Actions.Base.valid_length", "EverParse3d.Kinds.kind_nlist", "EverParse3d.Prelude.nlist", "EverParse3d.Prelude.parse_nlist", "Prims.op_Subtraction", "FStar.Seq.Base.seq", "EverParse3d.InputStream.Base.get_remaining", "Prims.logical", "Prims.op_disEquality", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "EverParse3d.ErrorCode.get_validator_error_kind", "EverParse3d.ErrorCode.validator_error_action_failed", "FStar.Pervasives.Native.uu___is_None", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "EverParse3d.Actions.Base.valid_consumed", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Kinds.WeakKindStrongPrefix", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.nat", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "LowParse.Spec.Base.parser_kind_metadata_some", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_metadata", "LowParse.Spec.Base.ParserKindMetadataTotal", "Prims.l_True" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 ))
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_nlist_total_constant_size' (n: U32.t) (#wk: _) (#k: parser_kind true wk) (#t: _) (p: parser k t) (inv l: _) : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires (let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296)) (ensures (fun _ -> True))
[]
EverParse3d.Actions.Base.validate_nlist_total_constant_size'
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
n: FStar.UInt32.t -> p: EverParse3d.Prelude.parser k t -> inv: EverParse3d.Actions.Base.slice_inv -> l: EverParse3d.Actions.Base.eloc -> Prims.Pure (EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_nlist n p) inv l true)
{ "end_col": 95, "end_line": 1140, "start_col": 2, "start_line": 1137 }
Prims.Tot
val validate____UINT8 : validator parse____UINT8
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _)
val validate____UINT8 : validator parse____UINT8 let validate____UINT8:validator parse____UINT8 =
false
null
false
validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _)
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "EverParse3d.Actions.Base.validate_with_comment", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Kinds.kind____UINT8", "EverParse3d.Prelude.___UINT8", "EverParse3d.Prelude.parse____UINT8", "EverParse3d.Actions.Base.true_inv", "EverParse3d.Actions.Base.eloc_none", "EverParse3d.Actions.Base.validate_total_constant_size_no_read", "FStar.UInt64.__uint_to_t", "EverParse3d.Actions.Base.validator" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate____UINT8 : validator parse____UINT8
[]
EverParse3d.Actions.Base.validate____UINT8
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
EverParse3d.Actions.Base.validator EverParse3d.Prelude.parse____UINT8
{ "end_col": 70, "end_line": 1320, "start_col": 4, "start_line": 1318 }
Prims.Tot
val read____UINT16BE : leaf_reader parse____UINT16BE
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL
val read____UINT16BE : leaf_reader parse____UINT16BE let read____UINT16BE:leaf_reader parse____UINT16BE =
false
null
false
lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "EverParse3d.Actions.Base.lift_reader", "LowParse.Spec.Int.parse_u16_kind", "FStar.UInt16.t", "LowParse.Spec.Int.parse_u16", "LowParse.Low.Int.read_u16", "FStar.UInt32.__uint_to_t", "FStar.UInt64.__uint_to_t", "EverParse3d.Actions.Base.leaf_reader", "EverParse3d.Kinds.kind____UINT16BE", "EverParse3d.Prelude.___UINT16BE", "EverParse3d.Prelude.parse____UINT16BE" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val read____UINT16BE : leaf_reader parse____UINT16BE
[]
EverParse3d.Actions.Base.read____UINT16BE
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
EverParse3d.Actions.Base.leaf_reader EverParse3d.Prelude.parse____UINT16BE
{ "end_col": 49, "end_line": 1371, "start_col": 2, "start_line": 1371 }
Prims.Tot
val validate____UINT32BE : validator parse____UINT32BE
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _)
val validate____UINT32BE : validator parse____UINT32BE let validate____UINT32BE:validator parse____UINT32BE =
false
null
false
validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _)
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "EverParse3d.Actions.Base.validate_with_comment", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Kinds.kind____UINT32BE", "EverParse3d.Prelude.___UINT32BE", "EverParse3d.Prelude.parse____UINT32BE", "EverParse3d.Actions.Base.true_inv", "EverParse3d.Actions.Base.eloc_none", "EverParse3d.Actions.Base.validate_total_constant_size_no_read", "FStar.UInt64.__uint_to_t", "EverParse3d.Actions.Base.validator" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate____UINT32BE : validator parse____UINT32BE
[]
EverParse3d.Actions.Base.validate____UINT32BE
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
EverParse3d.Actions.Base.validator EverParse3d.Prelude.parse____UINT32BE
{ "end_col": 73, "end_line": 1378, "start_col": 4, "start_line": 1376 }
Prims.Tot
val validate_with_comment (c:string) (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) (v:validate_with_action_t p inv l allow_reading) : validate_with_action_t p inv l allow_reading
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position
val validate_with_comment (c:string) (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) (v:validate_with_action_t p inv l allow_reading) : validate_with_action_t p inv l allow_reading let validate_with_comment (c: string) #nz #wk (#k: parser_kind nz wk) #t (#p: parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar =
false
null
false
fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.string", "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "FStar.UInt64.t", "Prims.unit", "LowParse.Low.Base.comment" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_with_comment (c:string) (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) (v:validate_with_action_t p inv l allow_reading) : validate_with_action_t p inv l allow_reading
[]
EverParse3d.Actions.Base.validate_with_comment
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
c: Prims.string -> v: EverParse3d.Actions.Base.validate_with_action_t p inv l allow_reading -> EverParse3d.Actions.Base.validate_with_action_t p inv l allow_reading
{ "end_col": 61, "end_line": 1280, "start_col": 4, "start_line": 1278 }
Prims.Tot
val external_action (l: eloc) : Tot Type0
[ { "abbrev": true, "full_module": "LowParse.Low.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let external_action l = unit -> Stack unit (fun _ -> True) (fun h0 _ h1 -> B.modifies l h0 h1)
val external_action (l: eloc) : Tot Type0 let external_action l =
false
null
false
unit -> Stack unit (fun _ -> True) (fun h0 _ h1 -> B.modifies l h0 h1)
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "EverParse3d.Actions.Base.eloc", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_True", "LowStar.Monotonic.Buffer.modifies", "FStar.Ghost.reveal", "LowStar.Monotonic.Buffer.loc" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL inline_for_extraction noextract let validate____UINT16 : validator parse____UINT16 = validate_with_comment "Checking that we have enough space for a UINT16, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16 2uL () _ _) inline_for_extraction noextract let read____UINT16 : leaf_reader parse____UINT16 = lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL inline_for_extraction noextract let validate____UINT32 : validator parse____UINT32 = validate_with_comment "Checking that we have enough space for a UINT32, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32 4uL () _ _) inline_for_extraction noextract let read____UINT32 : leaf_reader parse____UINT32 = lift_reader _ LowParse.Low.BoundedInt.read_u32_le 4ul 4uL inline_for_extraction noextract let validate____UINT64 : validator parse____UINT64 = validate_with_comment "Checking that we have enough space for a UINT64, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64 8uL () _ _) inline_for_extraction noextract let read____UINT64 : leaf_reader parse____UINT64 = lift_reader _ LowParse.Low.Int.read_u64_le 8ul 8uL inline_for_extraction noextract let validate_unit = fun _ _ input _ start_position -> start_position inline_for_extraction noextract let read_unit = fun input pos -> () inline_for_extraction noextract let validate_unit_refinement (f:unit -> bool) (cf:string) : validator (parse_unit `parse_filter` f) = fun _ _ input _ start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq parse_unit f (I.get_remaining input h); LowStar.Comment.comment cf; if f () then pos else LPE.set_validator_error_pos LPE.validator_error_constraint_failed pos (* Reimplement validate_list_up_to with readability (but no actions) *) module LUT = LowParse.Low.ListUpTo unfold let validate_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let res = B.deref h bres in let q = LUT.parse_list_up_to (cond_string_up_to terminator) p prf in B.live h0 bres /\ I.live sl h0 /\ I.live sl h /\ B.loc_disjoint (I.footprint sl) (B.loc_buffer bres `B.loc_union` app_loc ctxt loc_none) /\ B.loc_disjoint (B.loc_buffer bres) (app_loc ctxt loc_none) /\ B.live h0 ctxt /\ B.live h ctxt /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt loc_none) /\ B.modifies (B.loc_buffer bres `B.loc_union` I.perm_footprint sl `B.loc_union` app_loc ctxt loc_none) h0 h /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) /\ begin if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse q s)) else U64.v res == Seq.length (I.get_read sl h) /\ begin if stop then valid_consumed q h0 h sl else match LP.parse q s, LP.parse q s' with | None, None -> True | Some (_, consumed), Some (_, consumed') -> consumed' + Seq.length s - Seq.length s' == consumed | _ -> False end end end inline_for_extraction let validate_list_up_to_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (v: validator p) (r: leaf_reader p) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (h0: HS.mem) (bres: B.pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false )) (ensures (fun h stop h' -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false /\ validate_list_up_to_inv p terminator prf ctxt sl h0 bres h' stop )) = let h = HST.get () in LUT.parse_list_up_to_eq (cond_string_up_to terminator) p prf (I.get_remaining sl h); let position = !* bres in let result = v ctxt error_handler_fn sl sl_len position in B.upd bres 0ul result; if LPE.is_error result then begin true end else begin let value = r sl position in cond_string_up_to terminator value end inline_for_extraction noextract let validate_list_up_to (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (v: validator p) (r: leaf_reader p) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) : Tot (validate_with_action_t #true #WeakKindStrongPrefix (LUT.parse_list_up_to (cond_string_up_to terminator) p prf) true_inv eloc_none false) = fun ctxt error_handler_fn sl sl_len pos -> let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in fresh_frame_modifies h0 h1; let bres = B.alloca pos 1ul in let h2 = HST.get () in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_up_to_inv p terminator prf ctxt sl h2 bres) (fun _ -> validate_list_up_to_body terminator prf v r ctxt error_handler_fn sl sl_len h2 bres) ; let result = B.index bres 0ul in HST.pop_frame (); result let validate_string #k #t #p v r terminator = LP.parser_kind_prop_equiv k p; validate_weaken (validate_list_up_to v r terminator (fun _ _ _ -> ())) _ let validate_all_bytes = fun _ _ input input_length start_position -> I.empty input input_length start_position let validate_all_zeros = validate_list (validate_filter "parse_zeros" validate____UINT8 read____UINT8 is_zero "check if zero" "") //////////////////////////////////////////////////////////////////////////////// noextract inline_for_extraction let action_return #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#a:Type) (x:a) : action p true_inv eloc_none false a = fun _ _ _ _ -> x noextract inline_for_extraction let action_bind (name: string) #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#invf:slice_inv) (#lf:eloc) #bf (#a:Type) (f: action p invf lf bf a) (#invg:slice_inv) (#lg:eloc) #bg (#b:Type) (g: (a -> action p invg lg bg b)) : Tot (action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) b) = fun ctxt input pos posf -> let h0 = HST.get () in [@(rename_let ("" ^ name))] let x = f ctxt input pos posf in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; g x ctxt input pos posf noextract inline_for_extraction let action_seq #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#invf:slice_inv) (#lf:eloc) #bf (#a:Type) (f: action p invf lf bf a) (#invg:slice_inv) (#lg:eloc) #bg (#b:Type) (g: action p invg lg bg b) : Tot (action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) b) = fun ctxt input pos posf -> let h0 = HST.get () in let _ = f ctxt input pos posf in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; g ctxt input pos posf noextract inline_for_extraction let action_ite #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#invf:slice_inv) (#lf:eloc) (guard:bool) #bf (#a:Type) (then_: squash guard -> action p invf lf bf a) (#invg:slice_inv) (#lg:eloc) #bg (else_: squash (not guard) -> action p invg lg bg a) : action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) a = fun ctxt input pos posf -> if guard then then_ () ctxt input pos posf else else_ () ctxt input pos posf noextract inline_for_extraction let action_abort #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) : action p true_inv eloc_none false bool = fun _ _ _ _ -> false noextract inline_for_extraction let action_field_pos_64 #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (u:unit) : action p true_inv eloc_none false U64.t = fun _ _ pos _ -> pos (* FIXME: this is now unsound in general (only valid for flat buffer) noextract inline_for_extraction let action_field_ptr #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (u:unit) : action p true_inv eloc_none true LPL.puint8 = fun input startPosition _ -> let open LowParse.Slice in LPL.offset input (LPL.uint64_to_uint32 startPosition) *) noextract inline_for_extraction let action_deref #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#a:_) (x:B.pointer a) : action p (ptr_inv x) loc_none false a = fun _ _ _ _ -> !*x noextract inline_for_extraction let action_assignment #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#a:_) (x:B.pointer a) (v:a) : action p (ptr_inv x) (ptr_loc x) false unit = fun _ _ _ _ -> x *= v (* FIXME: This is now unsound. noextract inline_for_extraction let action_read_value #nz (#k:parser_kind nz) (#t:Type) (#p:parser k t) (r:leaf_reader p) : action p true_inv eloc_none true t = fun input startPosition endPosition -> r input (LPL.uint64_to_uint32 startPosition) *) noextract inline_for_extraction let action_weaken #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#inv:slice_inv) (#l:eloc) (#b:_) (#a:_) (act:action p inv l b a) (#inv':slice_inv{inv' `inv_implies` inv}) (#l':eloc{l' `eloc_includes` l}) : action p inv' l' b a = act
false
true
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val external_action (l: eloc) : Tot Type0
[]
EverParse3d.Actions.Base.external_action
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
l: EverParse3d.Actions.Base.eloc -> Type0
{ "end_col": 72, "end_line": 1706, "start_col": 2, "start_line": 1706 }
Prims.Tot
val read____UINT64BE : leaf_reader parse____UINT64BE
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL
val read____UINT64BE : leaf_reader parse____UINT64BE let read____UINT64BE:leaf_reader parse____UINT64BE =
false
null
false
lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "EverParse3d.Actions.Base.lift_reader", "LowParse.Spec.Int.parse_u64_kind", "FStar.UInt64.t", "LowParse.Spec.Int.parse_u64", "LowParse.Low.Int.read_u64", "FStar.UInt32.__uint_to_t", "FStar.UInt64.__uint_to_t", "EverParse3d.Actions.Base.leaf_reader", "EverParse3d.Kinds.kind____UINT64BE", "EverParse3d.Prelude.___UINT64BE", "EverParse3d.Prelude.parse____UINT64BE" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val read____UINT64BE : leaf_reader parse____UINT64BE
[]
EverParse3d.Actions.Base.read____UINT64BE
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
EverParse3d.Actions.Base.leaf_reader EverParse3d.Prelude.parse____UINT64BE
{ "end_col": 49, "end_line": 1395, "start_col": 2, "start_line": 1395 }
Prims.Tot
val validate____UINT32 : validator parse____UINT32
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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____UINT32 : validator parse____UINT32 = validate_with_comment "Checking that we have enough space for a UINT32, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32 4uL () _ _)
val validate____UINT32 : validator parse____UINT32 let validate____UINT32:validator parse____UINT32 =
false
null
false
validate_with_comment "Checking that we have enough space for a UINT32, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32 4uL () _ _)
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "EverParse3d.Actions.Base.validate_with_comment", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Kinds.kind____UINT32", "EverParse3d.Prelude.___UINT32", "EverParse3d.Prelude.parse____UINT32", "EverParse3d.Actions.Base.true_inv", "EverParse3d.Actions.Base.eloc_none", "EverParse3d.Actions.Base.validate_total_constant_size_no_read", "FStar.UInt64.__uint_to_t", "EverParse3d.Actions.Base.validator" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL inline_for_extraction noextract let validate____UINT16 : validator parse____UINT16 = validate_with_comment "Checking that we have enough space for a UINT16, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16 2uL () _ _) inline_for_extraction noextract let read____UINT16 : leaf_reader parse____UINT16 = lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL inline_for_extraction noextract let validate____UINT32
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate____UINT32 : validator parse____UINT32
[]
EverParse3d.Actions.Base.validate____UINT32
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
EverParse3d.Actions.Base.validator EverParse3d.Prelude.parse____UINT32
{ "end_col": 71, "end_line": 1414, "start_col": 4, "start_line": 1412 }
Prims.Tot
val read____UINT16 : leaf_reader parse____UINT16
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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____UINT16 : leaf_reader parse____UINT16 = lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL
val read____UINT16 : leaf_reader parse____UINT16 let read____UINT16:leaf_reader parse____UINT16 =
false
null
false
lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "EverParse3d.Actions.Base.lift_reader", "LowParse.Spec.Int.parse_u16_kind", "FStar.UInt16.t", "LowParse.Spec.BoundedInt.parse_u16_le", "LowParse.Low.BoundedInt.read_u16_le", "FStar.UInt32.__uint_to_t", "FStar.UInt64.__uint_to_t", "EverParse3d.Actions.Base.leaf_reader", "EverParse3d.Kinds.kind____UINT16", "EverParse3d.Prelude.___UINT16", "EverParse3d.Prelude.parse____UINT16" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL inline_for_extraction noextract let validate____UINT16 : validator parse____UINT16 = validate_with_comment "Checking that we have enough space for a UINT16, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16 2uL () _ _) inline_for_extraction noextract let read____UINT16
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val read____UINT16 : leaf_reader parse____UINT16
[]
EverParse3d.Actions.Base.read____UINT16
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
EverParse3d.Actions.Base.leaf_reader EverParse3d.Prelude.parse____UINT16
{ "end_col": 59, "end_line": 1407, "start_col": 2, "start_line": 1407 }
Prims.Tot
val validate_weaken_inv_loc (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) ([@@@erasable] inv':slice_inv{inv' `inv_implies` inv}) ([@@@erasable] l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l allow_reading) : Tot (validate_with_action_t p inv' l' allow_reading)
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v
val validate_weaken_inv_loc (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) ([@@@erasable] inv':slice_inv{inv' `inv_implies` inv}) ([@@@erasable] l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l allow_reading) : Tot (validate_with_action_t p inv' l' allow_reading) let validate_weaken_inv_loc #nz #wk (#k: parser_kind nz wk) #t (#p: parser k t) #inv (#l: eloc) #ar (inv': slice_inv{inv' `inv_implies` inv}) (l': eloc{l' `eloc_includes` l}) (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) =
false
null
false
v
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.inv_implies", "EverParse3d.Actions.Base.eloc_includes", "EverParse3d.Actions.Base.validate_with_action_t" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_weaken_inv_loc (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#allow_reading:bool) ([@@@erasable] inv':slice_inv{inv' `inv_implies` inv}) ([@@@erasable] l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l allow_reading) : Tot (validate_with_action_t p inv' l' allow_reading)
[]
EverParse3d.Actions.Base.validate_weaken_inv_loc
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
inv': EverParse3d.Actions.Base.slice_inv{EverParse3d.Actions.Base.inv_implies inv' inv} -> l': EverParse3d.Actions.Base.eloc{EverParse3d.Actions.Base.eloc_includes l' l} -> v: EverParse3d.Actions.Base.validate_with_action_t p inv l allow_reading -> EverParse3d.Actions.Base.validate_with_action_t p inv' l' allow_reading
{ "end_col": 5, "end_line": 1288, "start_col": 4, "start_line": 1288 }
Prims.Tot
val validate_with_success_action' (name: string) (#nz #wk: _) (#k1: parser_kind nz wk) (#t1: _) (#p1: parser k1 t1) (#inv1: _) (#l1: eloc) (v1: validate_with_action_t p1 inv1 l1 false) (#inv2: _) (#l2: eloc) (#b: _) (a: action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false
[ { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1
val validate_with_success_action' (name: string) (#nz #wk: _) (#k1: parser_kind nz wk) (#t1: _) (#p1: parser k1 t1) (#inv1: _) (#l1: eloc) (v1: validate_with_action_t p1 inv1 l1 false) (#inv2: _) (#l2: eloc) (#b: _) (a: action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false let validate_with_success_action' (name: string) #nz #wk (#k1: parser_kind nz wk) #t1 (#p1: parser k1 t1) (#inv1: _) (#l1: eloc) (v1: validate_with_action_t p1 inv1 l1 false) (#inv2: _) (#l2: eloc) #b (a: action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false =
false
null
false
fun ctxt error_handler_fn input input_length start_position -> [@@ inline_let ]let pos0 = start_position in let h0 = HST.get () in [@@ (rename_let ("positionAfter" ^ name)) ]let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@@ (rename_let ("action_success_" ^ name)) ]let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.string", "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Actions.Base.action", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "EverParse3d.ErrorCode.is_success", "Prims.op_Negation", "EverParse3d.ErrorCode.set_validator_error_pos", "EverParse3d.ErrorCode.validator_error_action_failed", "FStar.UInt64.t", "Prims.unit", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "EverParse3d.Actions.Base.conj_inv", "EverParse3d.Actions.Base.eloc_union" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_with_success_action' (name: string) (#nz #wk: _) (#k1: parser_kind nz wk) (#t1: _) (#p1: parser k1 t1) (#inv1: _) (#l1: eloc) (v1: validate_with_action_t p1 inv1 l1 false) (#inv2: _) (#l2: eloc) (#b: _) (a: action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false
[]
EverParse3d.Actions.Base.validate_with_success_action'
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
name: Prims.string -> v1: EverParse3d.Actions.Base.validate_with_action_t p1 inv1 l1 false -> a: EverParse3d.Actions.Base.action p1 inv2 l2 b Prims.bool -> EverParse3d.Actions.Base.validate_with_action_t p1 (EverParse3d.Actions.Base.conj_inv inv1 inv2) (EverParse3d.Actions.Base.eloc_union l1 l2) false
{ "end_col": 13, "end_line": 264, "start_col": 4, "start_line": 247 }
Prims.Tot
val validate_unit : validator parse_unit
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_unit = fun _ _ input _ start_position -> start_position
val validate_unit : validator parse_unit let validate_unit =
false
null
false
fun _ _ input _ start_position -> start_position
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "FStar.UInt64.t" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL inline_for_extraction noextract let validate____UINT16 : validator parse____UINT16 = validate_with_comment "Checking that we have enough space for a UINT16, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16 2uL () _ _) inline_for_extraction noextract let read____UINT16 : leaf_reader parse____UINT16 = lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL inline_for_extraction noextract let validate____UINT32 : validator parse____UINT32 = validate_with_comment "Checking that we have enough space for a UINT32, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32 4uL () _ _) inline_for_extraction noextract let read____UINT32 : leaf_reader parse____UINT32 = lift_reader _ LowParse.Low.BoundedInt.read_u32_le 4ul 4uL inline_for_extraction noextract let validate____UINT64 : validator parse____UINT64 = validate_with_comment "Checking that we have enough space for a UINT64, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64 8uL () _ _) inline_for_extraction noextract let read____UINT64 : leaf_reader parse____UINT64 = lift_reader _ LowParse.Low.Int.read_u64_le 8ul 8uL inline_for_extraction noextract
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_unit : validator parse_unit
[]
EverParse3d.Actions.Base.validate_unit
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
EverParse3d.Actions.Base.validator EverParse3d.Prelude.parse_unit
{ "end_col": 50, "end_line": 1435, "start_col": 2, "start_line": 1435 }
Prims.Tot
val validate_filter (name: string) (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : validate_with_action_t (p `parse_filter` f) inv l false
[ { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end
val validate_filter (name: string) (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : validate_with_action_t (p `parse_filter` f) inv l false let validate_filter (name: string) #nz (#k: parser_kind nz _) (#t: _) (#p: parser k t) #inv #l (v: validate_with_action_t p inv l true) (r: leaf_reader p) (f: (t -> bool)) (cr: string) (cf: string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) =
false
null
false
fun ctxt error_handler_fn input input_length start_position -> [@@ inline_let ]let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@@ (rename_let ("positionAfter" ^ name)) ]let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else (LowStar.Comment.comment cr; [@@ (rename_let ("" ^ name)) ]let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^ cf)); [@@ (rename_let (name ^ "ConstraintIsOk")) ]let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res)
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.string", "Prims.bool", "EverParse3d.Kinds.parser_kind", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Actions.Base.leaf_reader", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "EverParse3d.ErrorCode.is_error", "FStar.UInt64.t", "EverParse3d.ErrorCode.check_constraint_ok", "Prims.unit", "LowStar.Comment.comment", "FStar.Pervasives.normalize_term", "Prims.op_Hat", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Spec.Combinators.parse_filter_eq", "EverParse3d.InputStream.Base.get_remaining", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.Combinators.parse_filter", "EverParse3d.Kinds.filter_kind", "EverParse3d.Prelude.refine", "EverParse3d.Prelude.parse_filter" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_filter (name: string) (#nz:_) (#k:parser_kind nz WeakKindStrongPrefix) (#t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : validate_with_action_t (p `parse_filter` f) inv l false
[]
EverParse3d.Actions.Base.validate_filter
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
name: Prims.string -> v: EverParse3d.Actions.Base.validate_with_action_t p inv l true -> r: EverParse3d.Actions.Base.leaf_reader p -> f: (_: t -> Prims.bool) -> cr: Prims.string -> cf: Prims.string -> EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_filter p f) inv l false
{ "end_col": 7, "end_line": 673, "start_col": 4, "start_line": 655 }
FStar.HyperStack.ST.Stack
val validate_list' (#[FStar.Tactics.Typeclasses.tcresolve ()] _extra_t: I.extra_t #input_buffer_t) (#k: LP.parser_kind) (#t: _) (#p: LP.parser k t) (#inv #l #ar: _) (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ (loc_not_unused_in h) `loc_includes` (app_loc ctxt l) /\ (app_loc ctxt l) `loc_disjoint` (I.footprint sl) /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt l) /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h))) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ (let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` (Seq.slice s (Seq.length s - Seq.length s') (Seq.length s))) /\ (match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then (I.get_remaining sl h') `Seq.equal` (Seq.slice s len (Seq.length s)) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed) /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies ((app_loc ctxt l) `B.loc_union` (I.perm_footprint sl)) h h'))
[ { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult
val validate_list' (#[FStar.Tactics.Typeclasses.tcresolve ()] _extra_t: I.extra_t #input_buffer_t) (#k: LP.parser_kind) (#t: _) (#p: LP.parser k t) (#inv #l #ar: _) (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ (loc_not_unused_in h) `loc_includes` (app_loc ctxt l) /\ (app_loc ctxt l) `loc_disjoint` (I.footprint sl) /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt l) /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h))) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ (let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` (Seq.slice s (Seq.length s - Seq.length s') (Seq.length s))) /\ (match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then (I.get_remaining sl h') `Seq.equal` (Seq.slice s len (Seq.length s)) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed) /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies ((app_loc ctxt l) `B.loc_union` (I.perm_footprint sl)) h h')) let validate_list' (#[FStar.Tactics.Typeclasses.tcresolve ()] _extra_t: I.extra_t #input_buffer_t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ (loc_not_unused_in h) `loc_includes` (app_loc ctxt l) /\ (app_loc ctxt l) `loc_disjoint` (I.footprint sl) /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt l) /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h))) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ (let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` (Seq.slice s (Seq.length s - Seq.length s') (Seq.length s))) /\ (match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then (I.get_remaining sl h') `Seq.equal` (Seq.slice s len (Seq.length s)) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed) /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies ((app_loc ctxt l) `B.loc_union` (I.perm_footprint sl)) h h')) =
true
null
false
let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies ((app_loc ctxt l) `B.loc_union` (I.perm_footprint sl)) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[]
[ "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "Prims.bool", "EverParse3d.Actions.Base.validate_with_action_t'", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "Prims.unit", "LowParse.Spec.Base.parser_kind_prop_equiv", "Prims.list", "LowParse.Spec.List.parse_list_kind", "LowParse.Spec.List.parse_list", "Prims._assert", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_union", "FStar.Ghost.reveal", "LowStar.Monotonic.Buffer.loc", "EverParse3d.Actions.Base.app_loc", "EverParse3d.InputStream.Base.perm_footprint", "FStar.UInt64.t", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.pop_frame", "LowStar.Monotonic.Buffer.index", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.__uint_to_t", "C.Loops.do_while", "EverParse3d.Actions.Base.validate_list_inv", "EverParse3d.Actions.Base.validate_list_body", "EverParse3d.InputStream.Base.live_not_unused_in", "FStar.Ghost.erased", "FStar.Ghost.hide", "LowStar.Monotonic.Buffer.mbuffer", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.UInt32.v", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Buffer.alloca", "LowStar.Monotonic.Buffer.fresh_frame_modifies", "FStar.HyperStack.ST.push_frame", "EverParse3d.InputStream.Base.footprint", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.loc_not_unused_in", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.Monotonic.Buffer.address_liveness_insensitive_locs", "LowStar.Monotonic.Buffer.live", "FStar.UInt8.t", "EverParse3d.InputStream.Base.live", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt64.n", "FStar.UInt64.v", "FStar.Seq.Base.length", "EverParse3d.InputStream.Base.get_read", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "Prims.op_Subtraction", "FStar.Seq.Base.seq", "EverParse3d.InputStream.Base.get_remaining", "LowParse.Spec.Base.parse", "EverParse3d.ErrorCode.is_success", "LowParse.Spec.Base.consumed_length", "Prims.op_LessThan", "EverParse3d.ErrorCode.get_validator_error_kind", "EverParse3d.ErrorCode.validator_error_action_failed", "Prims.logical", "Prims.l_imp", "EverParse3d.ErrorCode.get_validator_error_pos" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h'
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_list' (#[FStar.Tactics.Typeclasses.tcresolve ()] _extra_t: I.extra_t #input_buffer_t) (#k: LP.parser_kind) (#t: _) (#p: LP.parser k t) (#inv #l #ar: _) (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ (loc_not_unused_in h) `loc_includes` (app_loc ctxt l) /\ (app_loc ctxt l) `loc_disjoint` (I.footprint sl) /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt l) /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h))) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ (let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` (Seq.slice s (Seq.length s - Seq.length s') (Seq.length s))) /\ (match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then (I.get_remaining sl h') `Seq.equal` (Seq.slice s len (Seq.length s)) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed) /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies ((app_loc ctxt l) `B.loc_union` (I.perm_footprint sl)) h h'))
[]
EverParse3d.Actions.Base.validate_list'
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v: EverParse3d.Actions.Base.validate_with_action_t' p inv l ar -> ctxt: EverParse3d.Actions.Base.app_ctxt -> error_handler_fn: EverParse3d.Actions.Base.error_handler -> sl: EverParse3d.Actions.Base.input_buffer_t -> sl_len: EverParse3d.InputStream.Base.tlen sl -> pos: EverParse3d.ErrorCode.pos_t -> FStar.HyperStack.ST.Stack FStar.UInt64.t
{ "end_col": 13, "end_line": 920, "start_col": 1, "start_line": 904 }
Prims.Tot
val validate_pair (name1: string) (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#[@@@erasable] t1:Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (#allow_reading1:bool) (v1:validate_with_action_t p1 inv1 l1 allow_reading1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#[@@@erasable] t2:Type) (#[@@@erasable] p2:parser k2 t2) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#allow_reading2:bool) (v2:validate_with_action_t p2 inv2 l2 allow_reading2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false
[ { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1
val validate_pair (name1: string) (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#[@@@erasable] t1:Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (#allow_reading1:bool) (v1:validate_with_action_t p1 inv1 l1 allow_reading1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#[@@@erasable] t2:Type) (#[@@@erasable] p2:parser k2 t2) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#allow_reading2:bool) (v2:validate_with_action_t p2 inv2 l2 allow_reading2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false let validate_pair (name1: string) #nz1 (#k1: parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1: parser k1 t1) (#inv1: _) (#l1: eloc) (#ar1: _) (v1: validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2: parser_kind nz2 wk2) #t2 (#p2: parser k2 t2) (#inv2: _) (#l2: eloc) (#ar2: _) (v2: validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false =
false
null
false
fun ctxt error_handler_fn input input_length start_position -> [@@ inline_let ]let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@@ (rename_let ("positionAfter" ^ name1)) ]let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.string", "Prims.bool", "EverParse3d.Kinds.parser_kind", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Kinds.weak_kind", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "EverParse3d.ErrorCode.is_error", "FStar.UInt64.t", "EverParse3d.Actions.Base.validate_drop", "Prims.unit", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Spec.Combinators.nondep_then_eq", "EverParse3d.InputStream.Base.get_remaining", "Prims.op_BarBar", "EverParse3d.Kinds.and_then_kind", "FStar.Pervasives.Native.tuple2", "EverParse3d.Prelude.parse_pair", "EverParse3d.Actions.Base.conj_inv", "EverParse3d.Actions.Base.eloc_union" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_pair (name1: string) (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#[@@@erasable] t1:Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (#allow_reading1:bool) (v1:validate_with_action_t p1 inv1 l1 allow_reading1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#[@@@erasable] t2:Type) (#[@@@erasable] p2:parser k2 t2) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#allow_reading2:bool) (v2:validate_with_action_t p2 inv2 l2 allow_reading2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false
[]
EverParse3d.Actions.Base.validate_pair
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
name1: Prims.string -> v1: EverParse3d.Actions.Base.validate_with_action_t p1 inv1 l1 allow_reading1 -> v2: EverParse3d.Actions.Base.validate_with_action_t p2 inv2 l2 allow_reading2 -> EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_pair p1 p2) (EverParse3d.Actions.Base.conj_inv inv1 inv2) (EverParse3d.Actions.Base.eloc_union l1 l2) false
{ "end_col": 68, "end_line": 347, "start_col": 4, "start_line": 335 }
Prims.Tot
val validate_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#[@@@erasable] p: parser k t) (v: validator p) (r: leaf_reader p) (terminator: t) : Tot (validate_with_action_t (parse_string p terminator) true_inv eloc_none false)
[ { "abbrev": true, "full_module": "LowParse.Low.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_string #k #t #p v r terminator = LP.parser_kind_prop_equiv k p; validate_weaken (validate_list_up_to v r terminator (fun _ _ _ -> ())) _
val validate_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#[@@@erasable] p: parser k t) (v: validator p) (r: leaf_reader p) (terminator: t) : Tot (validate_with_action_t (parse_string p terminator) true_inv eloc_none false) let validate_string #k #t #p v r terminator =
false
null
false
LP.parser_kind_prop_equiv k p; validate_weaken (validate_list_up_to v r terminator (fun _ _ _ -> ())) _
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "EverParse3d.Kinds.parser_kind", "EverParse3d.Kinds.WeakKindStrongPrefix", "Prims.eqtype", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.validator", "EverParse3d.Actions.Base.leaf_reader", "EverParse3d.Actions.Base.validate_weaken", "LowParse.Spec.ListUpTo.parse_list_up_to_kind", "LowParse.Spec.ListUpTo.parse_list_up_to_t", "EverParse3d.Prelude.cond_string_up_to", "LowParse.Spec.ListUpTo.parse_list_up_to", "LowParse.Bytes.bytes", "LowParse.Spec.Base.consumed_length", "Prims.unit", "EverParse3d.Actions.Base.true_inv", "EverParse3d.Actions.Base.eloc_none", "EverParse3d.Actions.Base.validate_list_up_to", "EverParse3d.Kinds.parse_string_kind", "LowParse.Spec.Base.parser_kind_prop_equiv", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Prelude.cstring", "EverParse3d.Prelude.parse_string" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL inline_for_extraction noextract let validate____UINT16 : validator parse____UINT16 = validate_with_comment "Checking that we have enough space for a UINT16, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16 2uL () _ _) inline_for_extraction noextract let read____UINT16 : leaf_reader parse____UINT16 = lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL inline_for_extraction noextract let validate____UINT32 : validator parse____UINT32 = validate_with_comment "Checking that we have enough space for a UINT32, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32 4uL () _ _) inline_for_extraction noextract let read____UINT32 : leaf_reader parse____UINT32 = lift_reader _ LowParse.Low.BoundedInt.read_u32_le 4ul 4uL inline_for_extraction noextract let validate____UINT64 : validator parse____UINT64 = validate_with_comment "Checking that we have enough space for a UINT64, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64 8uL () _ _) inline_for_extraction noextract let read____UINT64 : leaf_reader parse____UINT64 = lift_reader _ LowParse.Low.Int.read_u64_le 8ul 8uL inline_for_extraction noextract let validate_unit = fun _ _ input _ start_position -> start_position inline_for_extraction noextract let read_unit = fun input pos -> () inline_for_extraction noextract let validate_unit_refinement (f:unit -> bool) (cf:string) : validator (parse_unit `parse_filter` f) = fun _ _ input _ start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq parse_unit f (I.get_remaining input h); LowStar.Comment.comment cf; if f () then pos else LPE.set_validator_error_pos LPE.validator_error_constraint_failed pos (* Reimplement validate_list_up_to with readability (but no actions) *) module LUT = LowParse.Low.ListUpTo unfold let validate_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let res = B.deref h bres in let q = LUT.parse_list_up_to (cond_string_up_to terminator) p prf in B.live h0 bres /\ I.live sl h0 /\ I.live sl h /\ B.loc_disjoint (I.footprint sl) (B.loc_buffer bres `B.loc_union` app_loc ctxt loc_none) /\ B.loc_disjoint (B.loc_buffer bres) (app_loc ctxt loc_none) /\ B.live h0 ctxt /\ B.live h ctxt /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt loc_none) /\ B.modifies (B.loc_buffer bres `B.loc_union` I.perm_footprint sl `B.loc_union` app_loc ctxt loc_none) h0 h /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) /\ begin if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse q s)) else U64.v res == Seq.length (I.get_read sl h) /\ begin if stop then valid_consumed q h0 h sl else match LP.parse q s, LP.parse q s' with | None, None -> True | Some (_, consumed), Some (_, consumed') -> consumed' + Seq.length s - Seq.length s' == consumed | _ -> False end end end inline_for_extraction let validate_list_up_to_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (v: validator p) (r: leaf_reader p) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (h0: HS.mem) (bres: B.pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false )) (ensures (fun h stop h' -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false /\ validate_list_up_to_inv p terminator prf ctxt sl h0 bres h' stop )) = let h = HST.get () in LUT.parse_list_up_to_eq (cond_string_up_to terminator) p prf (I.get_remaining sl h); let position = !* bres in let result = v ctxt error_handler_fn sl sl_len position in B.upd bres 0ul result; if LPE.is_error result then begin true end else begin let value = r sl position in cond_string_up_to terminator value end inline_for_extraction noextract let validate_list_up_to (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (v: validator p) (r: leaf_reader p) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) : Tot (validate_with_action_t #true #WeakKindStrongPrefix (LUT.parse_list_up_to (cond_string_up_to terminator) p prf) true_inv eloc_none false) = fun ctxt error_handler_fn sl sl_len pos -> let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in fresh_frame_modifies h0 h1; let bres = B.alloca pos 1ul in let h2 = HST.get () in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_up_to_inv p terminator prf ctxt sl h2 bres) (fun _ -> validate_list_up_to_body terminator prf v r ctxt error_handler_fn sl sl_len h2 bres) ; let result = B.index bres 0ul in HST.pop_frame (); result let validate_string #k #t #p v r terminator
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_string (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#[@@@erasable] p: parser k t) (v: validator p) (r: leaf_reader p) (terminator: t) : Tot (validate_with_action_t (parse_string p terminator) true_inv eloc_none false)
[]
EverParse3d.Actions.Base.validate_string
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v: EverParse3d.Actions.Base.validator p -> r: EverParse3d.Actions.Base.leaf_reader p -> terminator: t -> EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_string p terminator) EverParse3d.Actions.Base.true_inv EverParse3d.Actions.Base.eloc_none false
{ "end_col": 74, "end_line": 1576, "start_col": 2, "start_line": 1575 }
Prims.GTot
val validate_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0
[ { "abbrev": true, "full_module": "LowParse.Low.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let res = B.deref h bres in let q = LUT.parse_list_up_to (cond_string_up_to terminator) p prf in B.live h0 bres /\ I.live sl h0 /\ I.live sl h /\ B.loc_disjoint (I.footprint sl) (B.loc_buffer bres `B.loc_union` app_loc ctxt loc_none) /\ B.loc_disjoint (B.loc_buffer bres) (app_loc ctxt loc_none) /\ B.live h0 ctxt /\ B.live h ctxt /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt loc_none) /\ B.modifies (B.loc_buffer bres `B.loc_union` I.perm_footprint sl `B.loc_union` app_loc ctxt loc_none) h0 h /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) /\ begin if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse q s)) else U64.v res == Seq.length (I.get_read sl h) /\ begin if stop then valid_consumed q h0 h sl else match LP.parse q s, LP.parse q s' with | None, None -> True | Some (_, consumed), Some (_, consumed') -> consumed' + Seq.length s - Seq.length s' == consumed | _ -> False end end end
val validate_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 let validate_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 =
false
null
false
let res = B.deref h bres in let q = LUT.parse_list_up_to (cond_string_up_to terminator) p prf in B.live h0 bres /\ I.live sl h0 /\ I.live sl h /\ B.loc_disjoint (I.footprint sl) ((B.loc_buffer bres) `B.loc_union` (app_loc ctxt loc_none)) /\ B.loc_disjoint (B.loc_buffer bres) (app_loc ctxt loc_none) /\ B.live h0 ctxt /\ B.live h ctxt /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt loc_none) /\ B.modifies (((B.loc_buffer bres) `B.loc_union` (I.perm_footprint sl)) `B.loc_union` (app_loc ctxt loc_none)) h0 h /\ (let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` (Seq.slice s (Seq.length s - Seq.length s') (Seq.length s)) /\ (if LPE.is_error res then stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse q s)) else U64.v res == Seq.length (I.get_read sl h) /\ (if stop then valid_consumed q h0 h sl else match LP.parse q s, LP.parse q s' with | None, None -> True | Some (_, consumed), Some (_, consumed') -> consumed' + Seq.length s - Seq.length s' == consumed | _ -> False)))
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "sometrivial" ]
[ "EverParse3d.Kinds.parser_kind", "EverParse3d.Kinds.WeakKindStrongPrefix", "Prims.eqtype", "EverParse3d.Prelude.parser", "LowParse.Spec.ListUpTo.consumes_if_not_cond", "EverParse3d.Prelude.cond_string_up_to", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.input_buffer_t", "FStar.Monotonic.HyperStack.mem", "LowStar.Buffer.pointer", "FStar.UInt64.t", "Prims.bool", "Prims.l_and", "LowStar.Monotonic.Buffer.live", "LowStar.Buffer.trivial_preorder", "EverParse3d.InputStream.Base.live", "EverParse3d.InputStream.All.inst", "LowStar.Monotonic.Buffer.loc_disjoint", "EverParse3d.InputStream.Base.footprint", "LowStar.Monotonic.Buffer.loc_union", "LowStar.Monotonic.Buffer.loc_buffer", "FStar.Ghost.reveal", "LowStar.Monotonic.Buffer.loc", "EverParse3d.Actions.Base.app_loc", "FStar.Ghost.hide", "LowStar.Monotonic.Buffer.loc_none", "FStar.UInt8.t", "LowStar.Monotonic.Buffer.loc_includes", "LowStar.Monotonic.Buffer.address_liveness_insensitive_locs", "LowStar.Monotonic.Buffer.modifies", "EverParse3d.InputStream.Base.perm_footprint", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.length", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "Prims.op_Subtraction", "EverParse3d.ErrorCode.is_error", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt64.n", "FStar.UInt64.v", "EverParse3d.ErrorCode.get_validator_error_pos", "EverParse3d.InputStream.Base.get_read", "Prims.l_imp", "Prims.op_disEquality", "Prims.op_LessThan", "EverParse3d.ErrorCode.get_validator_error_kind", "EverParse3d.ErrorCode.validator_error_action_failed", "FStar.Pervasives.Native.uu___is_None", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.ListUpTo.parse_list_up_to_t", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "EverParse3d.Actions.Base.valid_consumed", "LowParse.Spec.ListUpTo.parse_list_up_to_kind", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "Prims.l_True", "Prims.op_Addition", "Prims.l_False", "Prims.logical", "FStar.Seq.Base.seq", "EverParse3d.InputStream.Base.get_remaining", "LowParse.Spec.Base.parser", "LowParse.Spec.ListUpTo.parse_list_up_to", "LowStar.Monotonic.Buffer.deref" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL inline_for_extraction noextract let validate____UINT16 : validator parse____UINT16 = validate_with_comment "Checking that we have enough space for a UINT16, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16 2uL () _ _) inline_for_extraction noextract let read____UINT16 : leaf_reader parse____UINT16 = lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL inline_for_extraction noextract let validate____UINT32 : validator parse____UINT32 = validate_with_comment "Checking that we have enough space for a UINT32, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32 4uL () _ _) inline_for_extraction noextract let read____UINT32 : leaf_reader parse____UINT32 = lift_reader _ LowParse.Low.BoundedInt.read_u32_le 4ul 4uL inline_for_extraction noextract let validate____UINT64 : validator parse____UINT64 = validate_with_comment "Checking that we have enough space for a UINT64, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64 8uL () _ _) inline_for_extraction noextract let read____UINT64 : leaf_reader parse____UINT64 = lift_reader _ LowParse.Low.Int.read_u64_le 8ul 8uL inline_for_extraction noextract let validate_unit = fun _ _ input _ start_position -> start_position inline_for_extraction noextract let read_unit = fun input pos -> () inline_for_extraction noextract let validate_unit_refinement (f:unit -> bool) (cf:string) : validator (parse_unit `parse_filter` f) = fun _ _ input _ start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq parse_unit f (I.get_remaining input h); LowStar.Comment.comment cf; if f () then pos else LPE.set_validator_error_pos LPE.validator_error_constraint_failed pos (* Reimplement validate_list_up_to with readability (but no actions) *) module LUT = LowParse.Low.ListUpTo unfold let validate_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0
[]
EverParse3d.Actions.Base.validate_list_up_to_inv
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
p: EverParse3d.Prelude.parser k t -> terminator: t -> prf: LowParse.Spec.ListUpTo.consumes_if_not_cond (EverParse3d.Prelude.cond_string_up_to terminator) p -> ctxt: EverParse3d.Actions.Base.app_ctxt -> sl: EverParse3d.Actions.Base.input_buffer_t -> h0: FStar.Monotonic.HyperStack.mem -> bres: LowStar.Buffer.pointer FStar.UInt64.t -> h: FStar.Monotonic.HyperStack.mem -> stop: Prims.bool -> Prims.GTot Type0
{ "end_col": 5, "end_line": 1504, "start_col": 1, "start_line": 1472 }
Prims.Tot
val validate_unit_refinement (f:unit -> bool) (cf:string) : validator (parse_unit `parse_filter` f)
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_unit_refinement (f:unit -> bool) (cf:string) : validator (parse_unit `parse_filter` f) = fun _ _ input _ start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq parse_unit f (I.get_remaining input h); LowStar.Comment.comment cf; if f () then pos else LPE.set_validator_error_pos LPE.validator_error_constraint_failed pos
val validate_unit_refinement (f:unit -> bool) (cf:string) : validator (parse_unit `parse_filter` f) let validate_unit_refinement (f: (unit -> bool)) (cf: string) : validator (parse_unit `parse_filter` f) =
false
null
false
fun _ _ input _ start_position -> [@@ inline_let ]let pos = start_position in let h = HST.get () in LPC.parse_filter_eq parse_unit f (I.get_remaining input h); LowStar.Comment.comment cf; if f () then pos else LPE.set_validator_error_pos LPE.validator_error_constraint_failed pos
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.unit", "Prims.bool", "Prims.string", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "EverParse3d.ErrorCode.set_validator_error_pos", "EverParse3d.ErrorCode.validator_error_constraint_failed", "FStar.UInt64.t", "LowStar.Comment.comment", "LowParse.Spec.Combinators.parse_filter_eq", "EverParse3d.Kinds.kind_unit", "EverParse3d.Prelude.parse_unit", "EverParse3d.InputStream.Base.get_remaining", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "EverParse3d.Actions.Base.validator", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Kinds.filter_kind", "EverParse3d.Prelude.refine", "EverParse3d.Prelude.parse_filter" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL inline_for_extraction noextract let validate____UINT16 : validator parse____UINT16 = validate_with_comment "Checking that we have enough space for a UINT16, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16 2uL () _ _) inline_for_extraction noextract let read____UINT16 : leaf_reader parse____UINT16 = lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL inline_for_extraction noextract let validate____UINT32 : validator parse____UINT32 = validate_with_comment "Checking that we have enough space for a UINT32, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32 4uL () _ _) inline_for_extraction noextract let read____UINT32 : leaf_reader parse____UINT32 = lift_reader _ LowParse.Low.BoundedInt.read_u32_le 4ul 4uL inline_for_extraction noextract let validate____UINT64 : validator parse____UINT64 = validate_with_comment "Checking that we have enough space for a UINT64, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64 8uL () _ _) inline_for_extraction noextract let read____UINT64 : leaf_reader parse____UINT64 = lift_reader _ LowParse.Low.Int.read_u64_le 8ul 8uL inline_for_extraction noextract let validate_unit = fun _ _ input _ start_position -> start_position inline_for_extraction noextract let read_unit = fun input pos -> () inline_for_extraction noextract let validate_unit_refinement (f:unit -> bool) (cf:string)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_unit_refinement (f:unit -> bool) (cf:string) : validator (parse_unit `parse_filter` f)
[]
EverParse3d.Actions.Base.validate_unit_refinement
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
f: (_: Prims.unit -> Prims.bool) -> cf: Prims.string -> EverParse3d.Actions.Base.validator (EverParse3d.Prelude.parse_filter EverParse3d.Prelude.parse_unit f)
{ "end_col": 78, "end_line": 1451, "start_col": 2, "start_line": 1444 }
Prims.Tot
val validate_all_bytes : validate_with_action_t parse_all_bytes true_inv eloc_none false
[ { "abbrev": true, "full_module": "LowParse.Low.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_all_bytes = fun _ _ input input_length start_position -> I.empty input input_length start_position
val validate_all_bytes : validate_with_action_t parse_all_bytes true_inv eloc_none false let validate_all_bytes =
false
null
false
fun _ _ input input_length start_position -> I.empty input input_length start_position
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "EverParse3d.InputStream.Base.empty", "FStar.UInt64.t" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL inline_for_extraction noextract let validate____UINT16 : validator parse____UINT16 = validate_with_comment "Checking that we have enough space for a UINT16, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16 2uL () _ _) inline_for_extraction noextract let read____UINT16 : leaf_reader parse____UINT16 = lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL inline_for_extraction noextract let validate____UINT32 : validator parse____UINT32 = validate_with_comment "Checking that we have enough space for a UINT32, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32 4uL () _ _) inline_for_extraction noextract let read____UINT32 : leaf_reader parse____UINT32 = lift_reader _ LowParse.Low.BoundedInt.read_u32_le 4ul 4uL inline_for_extraction noextract let validate____UINT64 : validator parse____UINT64 = validate_with_comment "Checking that we have enough space for a UINT64, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64 8uL () _ _) inline_for_extraction noextract let read____UINT64 : leaf_reader parse____UINT64 = lift_reader _ LowParse.Low.Int.read_u64_le 8ul 8uL inline_for_extraction noextract let validate_unit = fun _ _ input _ start_position -> start_position inline_for_extraction noextract let read_unit = fun input pos -> () inline_for_extraction noextract let validate_unit_refinement (f:unit -> bool) (cf:string) : validator (parse_unit `parse_filter` f) = fun _ _ input _ start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq parse_unit f (I.get_remaining input h); LowStar.Comment.comment cf; if f () then pos else LPE.set_validator_error_pos LPE.validator_error_constraint_failed pos (* Reimplement validate_list_up_to with readability (but no actions) *) module LUT = LowParse.Low.ListUpTo unfold let validate_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let res = B.deref h bres in let q = LUT.parse_list_up_to (cond_string_up_to terminator) p prf in B.live h0 bres /\ I.live sl h0 /\ I.live sl h /\ B.loc_disjoint (I.footprint sl) (B.loc_buffer bres `B.loc_union` app_loc ctxt loc_none) /\ B.loc_disjoint (B.loc_buffer bres) (app_loc ctxt loc_none) /\ B.live h0 ctxt /\ B.live h ctxt /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt loc_none) /\ B.modifies (B.loc_buffer bres `B.loc_union` I.perm_footprint sl `B.loc_union` app_loc ctxt loc_none) h0 h /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) /\ begin if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse q s)) else U64.v res == Seq.length (I.get_read sl h) /\ begin if stop then valid_consumed q h0 h sl else match LP.parse q s, LP.parse q s' with | None, None -> True | Some (_, consumed), Some (_, consumed') -> consumed' + Seq.length s - Seq.length s' == consumed | _ -> False end end end inline_for_extraction let validate_list_up_to_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (v: validator p) (r: leaf_reader p) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (h0: HS.mem) (bres: B.pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false )) (ensures (fun h stop h' -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false /\ validate_list_up_to_inv p terminator prf ctxt sl h0 bres h' stop )) = let h = HST.get () in LUT.parse_list_up_to_eq (cond_string_up_to terminator) p prf (I.get_remaining sl h); let position = !* bres in let result = v ctxt error_handler_fn sl sl_len position in B.upd bres 0ul result; if LPE.is_error result then begin true end else begin let value = r sl position in cond_string_up_to terminator value end inline_for_extraction noextract let validate_list_up_to (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (v: validator p) (r: leaf_reader p) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) : Tot (validate_with_action_t #true #WeakKindStrongPrefix (LUT.parse_list_up_to (cond_string_up_to terminator) p prf) true_inv eloc_none false) = fun ctxt error_handler_fn sl sl_len pos -> let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in fresh_frame_modifies h0 h1; let bres = B.alloca pos 1ul in let h2 = HST.get () in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_up_to_inv p terminator prf ctxt sl h2 bres) (fun _ -> validate_list_up_to_body terminator prf v r ctxt error_handler_fn sl sl_len h2 bres) ; let result = B.index bres 0ul in HST.pop_frame (); result let validate_string #k #t #p v r terminator = LP.parser_kind_prop_equiv k p; validate_weaken (validate_list_up_to v r terminator (fun _ _ _ -> ())) _
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_all_bytes : validate_with_action_t parse_all_bytes true_inv eloc_none false
[]
EverParse3d.Actions.Base.validate_all_bytes
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
EverParse3d.Actions.Base.validate_with_action_t EverParse3d.Prelude.parse_all_bytes EverParse3d.Actions.Base.true_inv EverParse3d.Actions.Base.eloc_none false
{ "end_col": 43, "end_line": 1579, "start_col": 25, "start_line": 1578 }
Prims.Tot
val action_return (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#a:Type) (x:a) : action p true_inv eloc_none false a
[ { "abbrev": true, "full_module": "LowParse.Low.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let action_return #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#a:Type) (x:a) : action p true_inv eloc_none false a = fun _ _ _ _ -> x
val action_return (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#a:Type) (x:a) : action p true_inv eloc_none false a let action_return #nz #wk (#k: parser_kind nz wk) (#t: Type) (#p: parser k t) (#a: Type) (x: a) : action p true_inv eloc_none false a =
false
null
false
fun _ _ _ _ -> x
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.ErrorCode.pos_t", "EverParse3d.Actions.Base.action", "EverParse3d.Actions.Base.true_inv", "EverParse3d.Actions.Base.eloc_none" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL inline_for_extraction noextract let validate____UINT16 : validator parse____UINT16 = validate_with_comment "Checking that we have enough space for a UINT16, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16 2uL () _ _) inline_for_extraction noextract let read____UINT16 : leaf_reader parse____UINT16 = lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL inline_for_extraction noextract let validate____UINT32 : validator parse____UINT32 = validate_with_comment "Checking that we have enough space for a UINT32, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32 4uL () _ _) inline_for_extraction noextract let read____UINT32 : leaf_reader parse____UINT32 = lift_reader _ LowParse.Low.BoundedInt.read_u32_le 4ul 4uL inline_for_extraction noextract let validate____UINT64 : validator parse____UINT64 = validate_with_comment "Checking that we have enough space for a UINT64, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64 8uL () _ _) inline_for_extraction noextract let read____UINT64 : leaf_reader parse____UINT64 = lift_reader _ LowParse.Low.Int.read_u64_le 8ul 8uL inline_for_extraction noextract let validate_unit = fun _ _ input _ start_position -> start_position inline_for_extraction noextract let read_unit = fun input pos -> () inline_for_extraction noextract let validate_unit_refinement (f:unit -> bool) (cf:string) : validator (parse_unit `parse_filter` f) = fun _ _ input _ start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq parse_unit f (I.get_remaining input h); LowStar.Comment.comment cf; if f () then pos else LPE.set_validator_error_pos LPE.validator_error_constraint_failed pos (* Reimplement validate_list_up_to with readability (but no actions) *) module LUT = LowParse.Low.ListUpTo unfold let validate_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let res = B.deref h bres in let q = LUT.parse_list_up_to (cond_string_up_to terminator) p prf in B.live h0 bres /\ I.live sl h0 /\ I.live sl h /\ B.loc_disjoint (I.footprint sl) (B.loc_buffer bres `B.loc_union` app_loc ctxt loc_none) /\ B.loc_disjoint (B.loc_buffer bres) (app_loc ctxt loc_none) /\ B.live h0 ctxt /\ B.live h ctxt /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt loc_none) /\ B.modifies (B.loc_buffer bres `B.loc_union` I.perm_footprint sl `B.loc_union` app_loc ctxt loc_none) h0 h /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) /\ begin if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse q s)) else U64.v res == Seq.length (I.get_read sl h) /\ begin if stop then valid_consumed q h0 h sl else match LP.parse q s, LP.parse q s' with | None, None -> True | Some (_, consumed), Some (_, consumed') -> consumed' + Seq.length s - Seq.length s' == consumed | _ -> False end end end inline_for_extraction let validate_list_up_to_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (v: validator p) (r: leaf_reader p) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (h0: HS.mem) (bres: B.pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false )) (ensures (fun h stop h' -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false /\ validate_list_up_to_inv p terminator prf ctxt sl h0 bres h' stop )) = let h = HST.get () in LUT.parse_list_up_to_eq (cond_string_up_to terminator) p prf (I.get_remaining sl h); let position = !* bres in let result = v ctxt error_handler_fn sl sl_len position in B.upd bres 0ul result; if LPE.is_error result then begin true end else begin let value = r sl position in cond_string_up_to terminator value end inline_for_extraction noextract let validate_list_up_to (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (v: validator p) (r: leaf_reader p) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) : Tot (validate_with_action_t #true #WeakKindStrongPrefix (LUT.parse_list_up_to (cond_string_up_to terminator) p prf) true_inv eloc_none false) = fun ctxt error_handler_fn sl sl_len pos -> let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in fresh_frame_modifies h0 h1; let bres = B.alloca pos 1ul in let h2 = HST.get () in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_up_to_inv p terminator prf ctxt sl h2 bres) (fun _ -> validate_list_up_to_body terminator prf v r ctxt error_handler_fn sl sl_len h2 bres) ; let result = B.index bres 0ul in HST.pop_frame (); result let validate_string #k #t #p v r terminator = LP.parser_kind_prop_equiv k p; validate_weaken (validate_list_up_to v r terminator (fun _ _ _ -> ())) _ let validate_all_bytes = fun _ _ input input_length start_position -> I.empty input input_length start_position let validate_all_zeros = validate_list (validate_filter "parse_zeros" validate____UINT8 read____UINT8 is_zero "check if zero" "") //////////////////////////////////////////////////////////////////////////////// noextract inline_for_extraction let action_return #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#a:Type) (x:a)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val action_return (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#a:Type) (x:a) : action p true_inv eloc_none false a
[]
EverParse3d.Actions.Base.action_return
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
x: a -> EverParse3d.Actions.Base.action p EverParse3d.Actions.Base.true_inv EverParse3d.Actions.Base.eloc_none false a
{ "end_col": 20, "end_line": 1593, "start_col": 4, "start_line": 1593 }
Prims.Tot
val validate_fldata_consumes_all (n: U32.t) (#k: LP.parser_kind) (#t: _) (#p: LP.parser k t) (#inv #l #ar: _) (v: validate_with_action_t' p inv l ar {k.LP.parser_kind_subkind == Some LP.ParserConsumesAll} ) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false)
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end
val validate_fldata_consumes_all (n: U32.t) (#k: LP.parser_kind) (#t: _) (#p: LP.parser k t) (#inv #l #ar: _) (v: validate_with_action_t' p inv l ar {k.LP.parser_kind_subkind == Some LP.ParserConsumesAll} ) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) let validate_fldata_consumes_all (n: U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar {k.LP.parser_kind_subkind == Some LP.ParserConsumesAll} ) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) =
false
null
false
fun ctxt error_handler_fn input input_length start_position -> [@@ inline_let ]let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert ((I.get_remaining truncatedInput h2) `Seq.equal` (Seq.slice (I.get_remaining input h) 0 (U32.v n))); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "FStar.UInt32.t", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "Prims.bool", "EverParse3d.Actions.Base.validate_with_action_t'", "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.ParserConsumesAll", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "Prims.op_Negation", "EverParse3d.ErrorCode.set_validator_error_pos", "EverParse3d.ErrorCode.validator_error_not_enough_data", "FStar.UInt64.t", "Prims.unit", "EverParse3d.InputStream.Base.is_prefix_of_prop", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "EverParse3d.Actions.Base.validate_drop", "Prims._assert", "FStar.Seq.Base.equal", "FStar.UInt8.t", "EverParse3d.InputStream.Base.get_remaining", "FStar.Seq.Base.slice", "FStar.UInt32.v", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "EverParse3d.InputStream.Base.__proj__Mkinput_stream_inst__item__tlen", "EverParse3d.InputStream.Base.truncate_len", "FStar.Int.Cast.uint32_to_uint64", "EverParse3d.InputStream.Base.truncate", "EverParse3d.InputStream.Base.has", "LowParse.Spec.FLData.parse_fldata_consumes_all_correct", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll })
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_fldata_consumes_all (n: U32.t) (#k: LP.parser_kind) (#t: _) (#p: LP.parser k t) (#inv #l #ar: _) (v: validate_with_action_t' p inv l ar {k.LP.parser_kind_subkind == Some LP.ParserConsumesAll} ) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false)
[]
EverParse3d.Actions.Base.validate_fldata_consumes_all
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
n: FStar.UInt32.t -> v: EverParse3d.Actions.Base.validate_with_action_t' p inv l ar { Mkparser_kind'?.parser_kind_subkind k == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserConsumesAll } -> EverParse3d.Actions.Base.validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (FStar.UInt32.v n)) inv l false
{ "end_col": 5, "end_line": 969, "start_col": 2, "start_line": 949 }
Prims.Tot
val validate_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#[@@@erasable] a:squash e -> Type) (#[@@@erasable] b:squash (not e) -> Type) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (#ar1:_) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#ar2:_) ([@@@erasable] p1:squash e -> parser k (a())) (v1:(squash e -> validate_with_action_t (p1()) inv1 l1 ar1)) ([@@@erasable] p2:squash (not e) -> parser k (b())) (v2:(squash (not e) -> validate_with_action_t (p2()) inv2 l2 ar2)) : validate_with_action_t (parse_ite e p1 p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false
[ { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position
val validate_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#[@@@erasable] a:squash e -> Type) (#[@@@erasable] b:squash (not e) -> Type) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (#ar1:_) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#ar2:_) ([@@@erasable] p1:squash e -> parser k (a())) (v1:(squash e -> validate_with_action_t (p1()) inv1 l1 ar1)) ([@@@erasable] p2:squash (not e) -> parser k (b())) (v2:(squash (not e) -> validate_with_action_t (p2()) inv2 l2 ar2)) : validate_with_action_t (parse_ite e p1 p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false let validate_ite e p1 v1 p2 v2 =
false
null
false
fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "Prims.squash", "Prims.b2t", "Prims.op_Negation", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "EverParse3d.Actions.Base.validate_drop", "FStar.UInt64.t" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_ite (#nz:_) (#wk: _) (#k:parser_kind nz wk) (e:bool) (#[@@@erasable] a:squash e -> Type) (#[@@@erasable] b:squash (not e) -> Type) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (#ar1:_) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#ar2:_) ([@@@erasable] p1:squash e -> parser k (a())) (v1:(squash e -> validate_with_action_t (p1()) inv1 l1 ar1)) ([@@@erasable] p2:squash (not e) -> parser k (b())) (v2:(squash (not e) -> validate_with_action_t (p2()) inv2 l2 ar2)) : validate_with_action_t (parse_ite e p1 p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false
[]
EverParse3d.Actions.Base.validate_ite
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
e: Prims.bool -> p1: (_: Prims.squash e -> EverParse3d.Prelude.parser k (a ())) -> v1: (_: Prims.squash e -> EverParse3d.Actions.Base.validate_with_action_t (p1 ()) inv1 l1 ar1) -> p2: (_: Prims.squash (Prims.op_Negation e) -> EverParse3d.Prelude.parser k (b ())) -> v2: (_: Prims.squash (Prims.op_Negation e) -> EverParse3d.Actions.Base.validate_with_action_t (p2 ()) inv2 l2 ar2) -> EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_ite e p1 p2) (EverParse3d.Actions.Base.conj_inv inv1 inv2) (EverParse3d.Actions.Base.eloc_union l1 l2) false
{ "end_col": 85, "end_line": 771, "start_col": 4, "start_line": 768 }
Prims.Tot
val action_abort (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) : action p true_inv eloc_none false bool
[ { "abbrev": true, "full_module": "LowParse.Low.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let action_abort #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) : action p true_inv eloc_none false bool = fun _ _ _ _ -> false
val action_abort (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) : action p true_inv eloc_none false bool let action_abort #nz #wk (#k: parser_kind nz wk) (#t: Type) (#p: parser k t) : action p true_inv eloc_none false bool =
false
null
false
fun _ _ _ _ -> false
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.ErrorCode.pos_t", "EverParse3d.Actions.Base.action", "EverParse3d.Actions.Base.true_inv", "EverParse3d.Actions.Base.eloc_none" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL inline_for_extraction noextract let validate____UINT16 : validator parse____UINT16 = validate_with_comment "Checking that we have enough space for a UINT16, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16 2uL () _ _) inline_for_extraction noextract let read____UINT16 : leaf_reader parse____UINT16 = lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL inline_for_extraction noextract let validate____UINT32 : validator parse____UINT32 = validate_with_comment "Checking that we have enough space for a UINT32, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32 4uL () _ _) inline_for_extraction noextract let read____UINT32 : leaf_reader parse____UINT32 = lift_reader _ LowParse.Low.BoundedInt.read_u32_le 4ul 4uL inline_for_extraction noextract let validate____UINT64 : validator parse____UINT64 = validate_with_comment "Checking that we have enough space for a UINT64, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64 8uL () _ _) inline_for_extraction noextract let read____UINT64 : leaf_reader parse____UINT64 = lift_reader _ LowParse.Low.Int.read_u64_le 8ul 8uL inline_for_extraction noextract let validate_unit = fun _ _ input _ start_position -> start_position inline_for_extraction noextract let read_unit = fun input pos -> () inline_for_extraction noextract let validate_unit_refinement (f:unit -> bool) (cf:string) : validator (parse_unit `parse_filter` f) = fun _ _ input _ start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq parse_unit f (I.get_remaining input h); LowStar.Comment.comment cf; if f () then pos else LPE.set_validator_error_pos LPE.validator_error_constraint_failed pos (* Reimplement validate_list_up_to with readability (but no actions) *) module LUT = LowParse.Low.ListUpTo unfold let validate_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let res = B.deref h bres in let q = LUT.parse_list_up_to (cond_string_up_to terminator) p prf in B.live h0 bres /\ I.live sl h0 /\ I.live sl h /\ B.loc_disjoint (I.footprint sl) (B.loc_buffer bres `B.loc_union` app_loc ctxt loc_none) /\ B.loc_disjoint (B.loc_buffer bres) (app_loc ctxt loc_none) /\ B.live h0 ctxt /\ B.live h ctxt /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt loc_none) /\ B.modifies (B.loc_buffer bres `B.loc_union` I.perm_footprint sl `B.loc_union` app_loc ctxt loc_none) h0 h /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) /\ begin if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse q s)) else U64.v res == Seq.length (I.get_read sl h) /\ begin if stop then valid_consumed q h0 h sl else match LP.parse q s, LP.parse q s' with | None, None -> True | Some (_, consumed), Some (_, consumed') -> consumed' + Seq.length s - Seq.length s' == consumed | _ -> False end end end inline_for_extraction let validate_list_up_to_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (v: validator p) (r: leaf_reader p) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (h0: HS.mem) (bres: B.pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false )) (ensures (fun h stop h' -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false /\ validate_list_up_to_inv p terminator prf ctxt sl h0 bres h' stop )) = let h = HST.get () in LUT.parse_list_up_to_eq (cond_string_up_to terminator) p prf (I.get_remaining sl h); let position = !* bres in let result = v ctxt error_handler_fn sl sl_len position in B.upd bres 0ul result; if LPE.is_error result then begin true end else begin let value = r sl position in cond_string_up_to terminator value end inline_for_extraction noextract let validate_list_up_to (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (v: validator p) (r: leaf_reader p) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) : Tot (validate_with_action_t #true #WeakKindStrongPrefix (LUT.parse_list_up_to (cond_string_up_to terminator) p prf) true_inv eloc_none false) = fun ctxt error_handler_fn sl sl_len pos -> let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in fresh_frame_modifies h0 h1; let bres = B.alloca pos 1ul in let h2 = HST.get () in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_up_to_inv p terminator prf ctxt sl h2 bres) (fun _ -> validate_list_up_to_body terminator prf v r ctxt error_handler_fn sl sl_len h2 bres) ; let result = B.index bres 0ul in HST.pop_frame (); result let validate_string #k #t #p v r terminator = LP.parser_kind_prop_equiv k p; validate_weaken (validate_list_up_to v r terminator (fun _ _ _ -> ())) _ let validate_all_bytes = fun _ _ input input_length start_position -> I.empty input input_length start_position let validate_all_zeros = validate_list (validate_filter "parse_zeros" validate____UINT8 read____UINT8 is_zero "check if zero" "") //////////////////////////////////////////////////////////////////////////////// noextract inline_for_extraction let action_return #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#a:Type) (x:a) : action p true_inv eloc_none false a = fun _ _ _ _ -> x noextract inline_for_extraction let action_bind (name: string) #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#invf:slice_inv) (#lf:eloc) #bf (#a:Type) (f: action p invf lf bf a) (#invg:slice_inv) (#lg:eloc) #bg (#b:Type) (g: (a -> action p invg lg bg b)) : Tot (action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) b) = fun ctxt input pos posf -> let h0 = HST.get () in [@(rename_let ("" ^ name))] let x = f ctxt input pos posf in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; g x ctxt input pos posf noextract inline_for_extraction let action_seq #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#invf:slice_inv) (#lf:eloc) #bf (#a:Type) (f: action p invf lf bf a) (#invg:slice_inv) (#lg:eloc) #bg (#b:Type) (g: action p invg lg bg b) : Tot (action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) b) = fun ctxt input pos posf -> let h0 = HST.get () in let _ = f ctxt input pos posf in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; g ctxt input pos posf noextract inline_for_extraction let action_ite #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#invf:slice_inv) (#lf:eloc) (guard:bool) #bf (#a:Type) (then_: squash guard -> action p invf lf bf a) (#invg:slice_inv) (#lg:eloc) #bg (else_: squash (not guard) -> action p invg lg bg a) : action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) a = fun ctxt input pos posf -> if guard then then_ () ctxt input pos posf else else_ () ctxt input pos posf noextract inline_for_extraction let action_abort #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val action_abort (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) : action p true_inv eloc_none false bool
[]
EverParse3d.Actions.Base.action_abort
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
EverParse3d.Actions.Base.action p EverParse3d.Actions.Base.true_inv EverParse3d.Actions.Base.eloc_none false Prims.bool
{ "end_col": 24, "end_line": 1649, "start_col": 4, "start_line": 1649 }
Prims.Tot
val validate_dep_pair_with_refinement' (name1: string) (#nz1: _) (#k1: parser_kind nz1 _) (#t1: _) (#p1: parser k1 t1) (#inv1 #l1: _) (v1: validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: (t1 -> bool)) (#nz2 #wk2: _) (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) (#inv2 #l2 #ar2: _) (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false)
[ { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end
val validate_dep_pair_with_refinement' (name1: string) (#nz1: _) (#k1: parser_kind nz1 _) (#t1: _) (#p1: parser k1 t1) (#inv1 #l1: _) (v1: validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: (t1 -> bool)) (#nz2 #wk2: _) (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) (#inv2 #l2 #ar2: _) (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1: parser_kind nz1 _) #t1 (#p1: parser k1 t1) #inv1 #l1 (v1: validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: (t1 -> bool)) #nz2 #wk2 (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) =
false
null
false
fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@@ (rename_let ("positionAfter" ^ name1)) ]let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then res else [@@ (rename_let ("" ^ name1)) ]let field_value = r1 input startPosition in [@@ (rename_let (name1 ^ "ConstraintIsOk")) ]let ok = f field_value in [@@ (rename_let ("positionAfter" ^ name1)) ]let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.string", "Prims.bool", "EverParse3d.Kinds.parser_kind", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Actions.Base.leaf_reader", "EverParse3d.Kinds.weak_kind", "EverParse3d.Prelude.refine", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "EverParse3d.ErrorCode.is_error", "FStar.UInt64.t", "EverParse3d.Actions.Base.validate_drop", "Prims.unit", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "EverParse3d.ErrorCode.check_constraint_ok", "LowParse.Spec.Combinators.parse_filter_eq", "EverParse3d.InputStream.Base.get_remaining", "LowParse.Spec.Combinators.parse_dtuple2_eq'", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.Combinators.parse_filter", "Prims.op_BarBar", "EverParse3d.Kinds.and_then_kind", "Prims.dtuple2", "EverParse3d.Prelude.parse_dep_pair", "EverParse3d.Actions.Base.conj_inv", "EverParse3d.Actions.Base.eloc_union" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_dep_pair_with_refinement' (name1: string) (#nz1: _) (#k1: parser_kind nz1 _) (#t1: _) (#p1: parser k1 t1) (#inv1 #l1: _) (v1: validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: (t1 -> bool)) (#nz2 #wk2: _) (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) (#inv2 #l2 #ar2: _) (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false)
[]
EverParse3d.Actions.Base.validate_dep_pair_with_refinement'
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
name1: Prims.string -> v1: EverParse3d.Actions.Base.validate_with_action_t p1 inv1 l1 true -> r1: EverParse3d.Actions.Base.leaf_reader p1 -> f: (_: t1 -> Prims.bool) -> v2: (x: EverParse3d.Prelude.refine t1 f -> EverParse3d.Actions.Base.validate_with_action_t (p2 x) inv2 l2 ar2) -> EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_dep_pair (LowParse.Spec.Combinators.parse_filter p1 f) p2) (EverParse3d.Actions.Base.conj_inv inv1 inv2) (EverParse3d.Actions.Base.eloc_union l1 l2) false
{ "end_col": 11, "end_line": 581, "start_col": 4, "start_line": 550 }
Prims.Tot
val mk_external_action (#nz:_) (#wk:_) (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#l:eloc) ($f: external_action l) : action p true_inv l false unit
[ { "abbrev": true, "full_module": "LowParse.Low.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_external_action #_ #_ #_ #_ #_ #_ f = fun _ _ _ _ -> f ()
val mk_external_action (#nz:_) (#wk:_) (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#l:eloc) ($f: external_action l) : action p true_inv l false unit let mk_external_action #_ #_ #_ #_ #_ #_ f =
false
null
false
fun _ _ _ _ -> f ()
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.external_action", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.ErrorCode.pos_t", "Prims.unit" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL inline_for_extraction noextract let validate____UINT16 : validator parse____UINT16 = validate_with_comment "Checking that we have enough space for a UINT16, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16 2uL () _ _) inline_for_extraction noextract let read____UINT16 : leaf_reader parse____UINT16 = lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL inline_for_extraction noextract let validate____UINT32 : validator parse____UINT32 = validate_with_comment "Checking that we have enough space for a UINT32, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32 4uL () _ _) inline_for_extraction noextract let read____UINT32 : leaf_reader parse____UINT32 = lift_reader _ LowParse.Low.BoundedInt.read_u32_le 4ul 4uL inline_for_extraction noextract let validate____UINT64 : validator parse____UINT64 = validate_with_comment "Checking that we have enough space for a UINT64, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64 8uL () _ _) inline_for_extraction noextract let read____UINT64 : leaf_reader parse____UINT64 = lift_reader _ LowParse.Low.Int.read_u64_le 8ul 8uL inline_for_extraction noextract let validate_unit = fun _ _ input _ start_position -> start_position inline_for_extraction noextract let read_unit = fun input pos -> () inline_for_extraction noextract let validate_unit_refinement (f:unit -> bool) (cf:string) : validator (parse_unit `parse_filter` f) = fun _ _ input _ start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq parse_unit f (I.get_remaining input h); LowStar.Comment.comment cf; if f () then pos else LPE.set_validator_error_pos LPE.validator_error_constraint_failed pos (* Reimplement validate_list_up_to with readability (but no actions) *) module LUT = LowParse.Low.ListUpTo unfold let validate_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let res = B.deref h bres in let q = LUT.parse_list_up_to (cond_string_up_to terminator) p prf in B.live h0 bres /\ I.live sl h0 /\ I.live sl h /\ B.loc_disjoint (I.footprint sl) (B.loc_buffer bres `B.loc_union` app_loc ctxt loc_none) /\ B.loc_disjoint (B.loc_buffer bres) (app_loc ctxt loc_none) /\ B.live h0 ctxt /\ B.live h ctxt /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt loc_none) /\ B.modifies (B.loc_buffer bres `B.loc_union` I.perm_footprint sl `B.loc_union` app_loc ctxt loc_none) h0 h /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) /\ begin if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse q s)) else U64.v res == Seq.length (I.get_read sl h) /\ begin if stop then valid_consumed q h0 h sl else match LP.parse q s, LP.parse q s' with | None, None -> True | Some (_, consumed), Some (_, consumed') -> consumed' + Seq.length s - Seq.length s' == consumed | _ -> False end end end inline_for_extraction let validate_list_up_to_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (v: validator p) (r: leaf_reader p) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (h0: HS.mem) (bres: B.pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false )) (ensures (fun h stop h' -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false /\ validate_list_up_to_inv p terminator prf ctxt sl h0 bres h' stop )) = let h = HST.get () in LUT.parse_list_up_to_eq (cond_string_up_to terminator) p prf (I.get_remaining sl h); let position = !* bres in let result = v ctxt error_handler_fn sl sl_len position in B.upd bres 0ul result; if LPE.is_error result then begin true end else begin let value = r sl position in cond_string_up_to terminator value end inline_for_extraction noextract let validate_list_up_to (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (v: validator p) (r: leaf_reader p) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) : Tot (validate_with_action_t #true #WeakKindStrongPrefix (LUT.parse_list_up_to (cond_string_up_to terminator) p prf) true_inv eloc_none false) = fun ctxt error_handler_fn sl sl_len pos -> let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in fresh_frame_modifies h0 h1; let bres = B.alloca pos 1ul in let h2 = HST.get () in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_up_to_inv p terminator prf ctxt sl h2 bres) (fun _ -> validate_list_up_to_body terminator prf v r ctxt error_handler_fn sl sl_len h2 bres) ; let result = B.index bres 0ul in HST.pop_frame (); result let validate_string #k #t #p v r terminator = LP.parser_kind_prop_equiv k p; validate_weaken (validate_list_up_to v r terminator (fun _ _ _ -> ())) _ let validate_all_bytes = fun _ _ input input_length start_position -> I.empty input input_length start_position let validate_all_zeros = validate_list (validate_filter "parse_zeros" validate____UINT8 read____UINT8 is_zero "check if zero" "") //////////////////////////////////////////////////////////////////////////////// noextract inline_for_extraction let action_return #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#a:Type) (x:a) : action p true_inv eloc_none false a = fun _ _ _ _ -> x noextract inline_for_extraction let action_bind (name: string) #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#invf:slice_inv) (#lf:eloc) #bf (#a:Type) (f: action p invf lf bf a) (#invg:slice_inv) (#lg:eloc) #bg (#b:Type) (g: (a -> action p invg lg bg b)) : Tot (action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) b) = fun ctxt input pos posf -> let h0 = HST.get () in [@(rename_let ("" ^ name))] let x = f ctxt input pos posf in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; g x ctxt input pos posf noextract inline_for_extraction let action_seq #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#invf:slice_inv) (#lf:eloc) #bf (#a:Type) (f: action p invf lf bf a) (#invg:slice_inv) (#lg:eloc) #bg (#b:Type) (g: action p invg lg bg b) : Tot (action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) b) = fun ctxt input pos posf -> let h0 = HST.get () in let _ = f ctxt input pos posf in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; g ctxt input pos posf noextract inline_for_extraction let action_ite #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#invf:slice_inv) (#lf:eloc) (guard:bool) #bf (#a:Type) (then_: squash guard -> action p invf lf bf a) (#invg:slice_inv) (#lg:eloc) #bg (else_: squash (not guard) -> action p invg lg bg a) : action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) a = fun ctxt input pos posf -> if guard then then_ () ctxt input pos posf else else_ () ctxt input pos posf noextract inline_for_extraction let action_abort #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) : action p true_inv eloc_none false bool = fun _ _ _ _ -> false noextract inline_for_extraction let action_field_pos_64 #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (u:unit) : action p true_inv eloc_none false U64.t = fun _ _ pos _ -> pos (* FIXME: this is now unsound in general (only valid for flat buffer) noextract inline_for_extraction let action_field_ptr #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (u:unit) : action p true_inv eloc_none true LPL.puint8 = fun input startPosition _ -> let open LowParse.Slice in LPL.offset input (LPL.uint64_to_uint32 startPosition) *) noextract inline_for_extraction let action_deref #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#a:_) (x:B.pointer a) : action p (ptr_inv x) loc_none false a = fun _ _ _ _ -> !*x noextract inline_for_extraction let action_assignment #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#a:_) (x:B.pointer a) (v:a) : action p (ptr_inv x) (ptr_loc x) false unit = fun _ _ _ _ -> x *= v (* FIXME: This is now unsound. noextract inline_for_extraction let action_read_value #nz (#k:parser_kind nz) (#t:Type) (#p:parser k t) (r:leaf_reader p) : action p true_inv eloc_none true t = fun input startPosition endPosition -> r input (LPL.uint64_to_uint32 startPosition) *) noextract inline_for_extraction let action_weaken #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#inv:slice_inv) (#l:eloc) (#b:_) (#a:_) (act:action p inv l b a) (#inv':slice_inv{inv' `inv_implies` inv}) (#l':eloc{l' `eloc_includes` l}) : action p inv' l' b a = act let external_action l = unit -> Stack unit (fun _ -> True) (fun h0 _ h1 -> B.modifies l h0 h1) noextract
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mk_external_action (#nz:_) (#wk:_) (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#l:eloc) ($f: external_action l) : action p true_inv l false unit
[]
EverParse3d.Actions.Base.mk_external_action
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
$f: EverParse3d.Actions.Base.external_action l -> EverParse3d.Actions.Base.action p EverParse3d.Actions.Base.true_inv l false Prims.unit
{ "end_col": 64, "end_line": 1710, "start_col": 45, "start_line": 1710 }
Prims.Tot
val action_field_pos_64 (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (u:unit) : action p true_inv eloc_none false U64.t
[ { "abbrev": true, "full_module": "LowParse.Low.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let action_field_pos_64 #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (u:unit) : action p true_inv eloc_none false U64.t = fun _ _ pos _ -> pos
val action_field_pos_64 (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (u:unit) : action p true_inv eloc_none false U64.t let action_field_pos_64 #nz #wk (#k: parser_kind nz wk) (#t: Type) (#p: parser k t) (u: unit) : action p true_inv eloc_none false U64.t =
false
null
false
fun _ _ pos _ -> pos
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "Prims.unit", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.ErrorCode.pos_t", "FStar.UInt64.t", "EverParse3d.Actions.Base.action", "EverParse3d.Actions.Base.true_inv", "EverParse3d.Actions.Base.eloc_none" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL inline_for_extraction noextract let validate____UINT16 : validator parse____UINT16 = validate_with_comment "Checking that we have enough space for a UINT16, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16 2uL () _ _) inline_for_extraction noextract let read____UINT16 : leaf_reader parse____UINT16 = lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL inline_for_extraction noextract let validate____UINT32 : validator parse____UINT32 = validate_with_comment "Checking that we have enough space for a UINT32, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32 4uL () _ _) inline_for_extraction noextract let read____UINT32 : leaf_reader parse____UINT32 = lift_reader _ LowParse.Low.BoundedInt.read_u32_le 4ul 4uL inline_for_extraction noextract let validate____UINT64 : validator parse____UINT64 = validate_with_comment "Checking that we have enough space for a UINT64, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64 8uL () _ _) inline_for_extraction noextract let read____UINT64 : leaf_reader parse____UINT64 = lift_reader _ LowParse.Low.Int.read_u64_le 8ul 8uL inline_for_extraction noextract let validate_unit = fun _ _ input _ start_position -> start_position inline_for_extraction noextract let read_unit = fun input pos -> () inline_for_extraction noextract let validate_unit_refinement (f:unit -> bool) (cf:string) : validator (parse_unit `parse_filter` f) = fun _ _ input _ start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq parse_unit f (I.get_remaining input h); LowStar.Comment.comment cf; if f () then pos else LPE.set_validator_error_pos LPE.validator_error_constraint_failed pos (* Reimplement validate_list_up_to with readability (but no actions) *) module LUT = LowParse.Low.ListUpTo unfold let validate_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let res = B.deref h bres in let q = LUT.parse_list_up_to (cond_string_up_to terminator) p prf in B.live h0 bres /\ I.live sl h0 /\ I.live sl h /\ B.loc_disjoint (I.footprint sl) (B.loc_buffer bres `B.loc_union` app_loc ctxt loc_none) /\ B.loc_disjoint (B.loc_buffer bres) (app_loc ctxt loc_none) /\ B.live h0 ctxt /\ B.live h ctxt /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt loc_none) /\ B.modifies (B.loc_buffer bres `B.loc_union` I.perm_footprint sl `B.loc_union` app_loc ctxt loc_none) h0 h /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) /\ begin if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse q s)) else U64.v res == Seq.length (I.get_read sl h) /\ begin if stop then valid_consumed q h0 h sl else match LP.parse q s, LP.parse q s' with | None, None -> True | Some (_, consumed), Some (_, consumed') -> consumed' + Seq.length s - Seq.length s' == consumed | _ -> False end end end inline_for_extraction let validate_list_up_to_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (v: validator p) (r: leaf_reader p) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (h0: HS.mem) (bres: B.pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false )) (ensures (fun h stop h' -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false /\ validate_list_up_to_inv p terminator prf ctxt sl h0 bres h' stop )) = let h = HST.get () in LUT.parse_list_up_to_eq (cond_string_up_to terminator) p prf (I.get_remaining sl h); let position = !* bres in let result = v ctxt error_handler_fn sl sl_len position in B.upd bres 0ul result; if LPE.is_error result then begin true end else begin let value = r sl position in cond_string_up_to terminator value end inline_for_extraction noextract let validate_list_up_to (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (v: validator p) (r: leaf_reader p) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) : Tot (validate_with_action_t #true #WeakKindStrongPrefix (LUT.parse_list_up_to (cond_string_up_to terminator) p prf) true_inv eloc_none false) = fun ctxt error_handler_fn sl sl_len pos -> let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in fresh_frame_modifies h0 h1; let bres = B.alloca pos 1ul in let h2 = HST.get () in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_up_to_inv p terminator prf ctxt sl h2 bres) (fun _ -> validate_list_up_to_body terminator prf v r ctxt error_handler_fn sl sl_len h2 bres) ; let result = B.index bres 0ul in HST.pop_frame (); result let validate_string #k #t #p v r terminator = LP.parser_kind_prop_equiv k p; validate_weaken (validate_list_up_to v r terminator (fun _ _ _ -> ())) _ let validate_all_bytes = fun _ _ input input_length start_position -> I.empty input input_length start_position let validate_all_zeros = validate_list (validate_filter "parse_zeros" validate____UINT8 read____UINT8 is_zero "check if zero" "") //////////////////////////////////////////////////////////////////////////////// noextract inline_for_extraction let action_return #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#a:Type) (x:a) : action p true_inv eloc_none false a = fun _ _ _ _ -> x noextract inline_for_extraction let action_bind (name: string) #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#invf:slice_inv) (#lf:eloc) #bf (#a:Type) (f: action p invf lf bf a) (#invg:slice_inv) (#lg:eloc) #bg (#b:Type) (g: (a -> action p invg lg bg b)) : Tot (action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) b) = fun ctxt input pos posf -> let h0 = HST.get () in [@(rename_let ("" ^ name))] let x = f ctxt input pos posf in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; g x ctxt input pos posf noextract inline_for_extraction let action_seq #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#invf:slice_inv) (#lf:eloc) #bf (#a:Type) (f: action p invf lf bf a) (#invg:slice_inv) (#lg:eloc) #bg (#b:Type) (g: action p invg lg bg b) : Tot (action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) b) = fun ctxt input pos posf -> let h0 = HST.get () in let _ = f ctxt input pos posf in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; g ctxt input pos posf noextract inline_for_extraction let action_ite #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#invf:slice_inv) (#lf:eloc) (guard:bool) #bf (#a:Type) (then_: squash guard -> action p invf lf bf a) (#invg:slice_inv) (#lg:eloc) #bg (else_: squash (not guard) -> action p invg lg bg a) : action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) a = fun ctxt input pos posf -> if guard then then_ () ctxt input pos posf else else_ () ctxt input pos posf noextract inline_for_extraction let action_abort #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) : action p true_inv eloc_none false bool = fun _ _ _ _ -> false noextract inline_for_extraction let action_field_pos_64 #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (u:unit)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val action_field_pos_64 (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (u:unit) : action p true_inv eloc_none false U64.t
[]
EverParse3d.Actions.Base.action_field_pos_64
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
u727: Prims.unit -> EverParse3d.Actions.Base.action p EverParse3d.Actions.Base.true_inv EverParse3d.Actions.Base.eloc_none false FStar.UInt64.t
{ "end_col": 25, "end_line": 1656, "start_col": 5, "start_line": 1656 }
Prims.Tot
val validate_fldata (n: U32.t) (#k: LP.parser_kind) (#t: _) (#p: LP.parser k t) (#inv #l #ar: _) (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false)
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end
val validate_fldata (n: U32.t) (#k: LP.parser_kind) (#t: _) (#p: LP.parser k t) (#inv #l #ar: _) (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) let validate_fldata (n: U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) =
false
null
false
fun ctxt error_handler_fn input input_length start_position -> [@@ inline_let ]let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert ((I.get_remaining truncatedInput h2) `Seq.equal` (Seq.slice (I.get_remaining input h) 0 (U32.v n))); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "FStar.UInt32.t", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "Prims.bool", "EverParse3d.Actions.Base.validate_with_action_t'", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "Prims.op_Negation", "EverParse3d.ErrorCode.set_validator_error_pos", "EverParse3d.ErrorCode.validator_error_not_enough_data", "FStar.UInt64.t", "EverParse3d.ErrorCode.is_error", "EverParse3d.ErrorCode.validator_error_unexpected_padding", "Prims.unit", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "EverParse3d.InputStream.Base.has", "FStar.UInt64.__uint_to_t", "EverParse3d.InputStream.Base.is_prefix_of_prop", "EverParse3d.Actions.Base.validate_drop", "Prims._assert", "FStar.Seq.Base.equal", "FStar.UInt8.t", "EverParse3d.InputStream.Base.get_remaining", "FStar.Seq.Base.slice", "FStar.UInt32.v", "EverParse3d.InputStream.Base.__proj__Mkinput_stream_inst__item__tlen", "EverParse3d.InputStream.Base.truncate_len", "FStar.Int.Cast.uint32_to_uint64", "EverParse3d.InputStream.Base.truncate", "LowParse.Spec.FLData.parse_fldata_kind", "LowParse.Spec.FLData.parse_fldata" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10", "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 16, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_fldata (n: U32.t) (#k: LP.parser_kind) (#t: _) (#p: LP.parser k t) (#inv #l #ar: _) (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false)
[]
EverParse3d.Actions.Base.validate_fldata
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
n: FStar.UInt32.t -> v: EverParse3d.Actions.Base.validate_with_action_t' p inv l ar -> EverParse3d.Actions.Base.validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (FStar.UInt32.v n)) inv l false
{ "end_col": 5, "end_line": 1015, "start_col": 2, "start_line": 986 }
Prims.Tot
val action_bind (name: string) (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] invf:slice_inv) (#[@@@erasable] lf:eloc) (#bf:_) (#a:Type) (f: action p invf lf bf a) (#[@@@erasable] invg:slice_inv) (#[@@@erasable] lg:eloc) (#bg:_) (#b:Type) (g: (a -> action p invg lg bg b)) : Tot (action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) b)
[ { "abbrev": true, "full_module": "LowParse.Low.ListUpTo", "short_module": "LUT" }, { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let action_bind (name: string) #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#invf:slice_inv) (#lf:eloc) #bf (#a:Type) (f: action p invf lf bf a) (#invg:slice_inv) (#lg:eloc) #bg (#b:Type) (g: (a -> action p invg lg bg b)) : Tot (action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) b) = fun ctxt input pos posf -> let h0 = HST.get () in [@(rename_let ("" ^ name))] let x = f ctxt input pos posf in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; g x ctxt input pos posf
val action_bind (name: string) (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] invf:slice_inv) (#[@@@erasable] lf:eloc) (#bf:_) (#a:Type) (f: action p invf lf bf a) (#[@@@erasable] invg:slice_inv) (#[@@@erasable] lg:eloc) (#bg:_) (#b:Type) (g: (a -> action p invg lg bg b)) : Tot (action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) b) let action_bind (name: string) #nz #wk (#k: parser_kind nz wk) (#t: Type) (#p: parser k t) (#invf: slice_inv) (#lf: eloc) #bf (#a: Type) (f: action p invf lf bf a) (#invg: slice_inv) (#lg: eloc) #bg (#b: Type) (g: (a -> action p invg lg bg b)) : Tot (action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) b) =
false
null
false
fun ctxt input pos posf -> let h0 = HST.get () in [@@ (rename_let ("" ^ name)) ]let x = f ctxt input pos posf in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; g x ctxt input pos posf
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.string", "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.action", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.ErrorCode.pos_t", "Prims.unit", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "EverParse3d.Actions.Base.conj_inv", "EverParse3d.Actions.Base.eloc_union", "Prims.op_BarBar" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end #pop-options inline_for_extraction noextract let validate_with_comment (c:string) #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) : validate_with_action_t p inv l ar = fun ctxt error_handler_fn input input_length start_position -> LowParse.Low.Base.comment c; v ctxt error_handler_fn input input_length start_position inline_for_extraction noextract let validate_weaken_inv_loc #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv (#l:eloc) #ar (inv':slice_inv{inv' `inv_implies` inv}) (l':eloc{l' `eloc_includes` l}) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t p inv' l' ar) = v //////////////////////////////////////////////////////////////////////////////// //Base types //////////////////////////////////////////////////////////////////////////////// inline_for_extraction noextract let read_filter #nz (#k: parser_kind nz WeakKindStrongPrefix) (#t: Type) (#p: parser k t) (p32: leaf_reader p) (f: (t -> bool)) : leaf_reader (parse_filter p f) = fun input pos -> let h = HST.get () in assert (parse_filter p f == LPC.parse_filter #k #t p f); assert_norm (P.refine t f == LPC.parse_filter_refine f); LPC.parse_filter_eq p f (I.get_remaining input h); p32 input pos inline_for_extraction noextract let read_impos : leaf_reader (parse_impos()) = fun sl pos -> false_elim () inline_for_extraction noextract let validate____UINT8 : validator parse____UINT8 = validate_with_comment "Checking that we have enough space for a UINT8, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8 1uL () _ _) inline_for_extraction noextract let lift_reader (#nz: _) (#k: parser_kind nz WeakKindStrongPrefix) (#t: _) (p: parser k t) (r: LPL.leaf_reader p) (sz32: U32.t) (sz: U64.t) : Pure (leaf_reader p) (requires ( U32.v sz32 == U64.v sz /\ U64.v sz > 0 /\ k.LP.parser_kind_subkind == Some LP.ParserStrong /\ k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low = U64.v sz )) (ensures (fun _ -> True)) = fun input pos -> LP.parser_kind_prop_equiv k p; I.read t k p r input pos sz inline_for_extraction noextract let read____UINT8 : leaf_reader parse____UINT8 = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT8BE : validator parse____UINT8BE = validate_with_comment "Checking that we have enough space for a UINT8BE, i.e., 1 byte" (validate_total_constant_size_no_read parse____UINT8BE 1uL () _ _) inline_for_extraction noextract let read____UINT8BE : leaf_reader parse____UINT8BE = lift_reader _ LowParse.Low.Int.read_u8 1ul 1uL inline_for_extraction noextract let validate____UINT16BE : validator parse____UINT16BE = validate_with_comment "Checking that we have enough space for a UINT16BE, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16BE 2uL () _ _) inline_for_extraction noextract let read____UINT16BE : leaf_reader parse____UINT16BE = lift_reader _ LowParse.Low.Int.read_u16 2ul 2uL inline_for_extraction noextract let validate____UINT32BE : validator parse____UINT32BE = validate_with_comment "Checking that we have enough space for a UINT32BE, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32BE 4uL () _ _) inline_for_extraction noextract let read____UINT32BE : leaf_reader parse____UINT32BE = lift_reader _ LowParse.Low.Int.read_u32 4ul 4uL inline_for_extraction noextract let validate____UINT64BE : validator parse____UINT64BE = validate_with_comment "Checking that we have enough space for a UINT64BE, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64BE 8uL () _ _) inline_for_extraction noextract let read____UINT64BE : leaf_reader parse____UINT64BE = lift_reader _ LowParse.Low.Int.read_u64 8ul 8uL inline_for_extraction noextract let validate____UINT16 : validator parse____UINT16 = validate_with_comment "Checking that we have enough space for a UINT16, i.e., 2 bytes" (validate_total_constant_size_no_read parse____UINT16 2uL () _ _) inline_for_extraction noextract let read____UINT16 : leaf_reader parse____UINT16 = lift_reader _ LowParse.Low.BoundedInt.read_u16_le 2ul 2uL inline_for_extraction noextract let validate____UINT32 : validator parse____UINT32 = validate_with_comment "Checking that we have enough space for a UINT32, i.e., 4 bytes" (validate_total_constant_size_no_read parse____UINT32 4uL () _ _) inline_for_extraction noextract let read____UINT32 : leaf_reader parse____UINT32 = lift_reader _ LowParse.Low.BoundedInt.read_u32_le 4ul 4uL inline_for_extraction noextract let validate____UINT64 : validator parse____UINT64 = validate_with_comment "Checking that we have enough space for a UINT64, i.e., 8 bytes" (validate_total_constant_size_no_read parse____UINT64 8uL () _ _) inline_for_extraction noextract let read____UINT64 : leaf_reader parse____UINT64 = lift_reader _ LowParse.Low.Int.read_u64_le 8ul 8uL inline_for_extraction noextract let validate_unit = fun _ _ input _ start_position -> start_position inline_for_extraction noextract let read_unit = fun input pos -> () inline_for_extraction noextract let validate_unit_refinement (f:unit -> bool) (cf:string) : validator (parse_unit `parse_filter` f) = fun _ _ input _ start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq parse_unit f (I.get_remaining input h); LowStar.Comment.comment cf; if f () then pos else LPE.set_validator_error_pos LPE.validator_error_constraint_failed pos (* Reimplement validate_list_up_to with readability (but no actions) *) module LUT = LowParse.Low.ListUpTo unfold let validate_list_up_to_inv (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (ctxt: app_ctxt) (sl: input_buffer_t) (h0: HS.mem) (bres: B.pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let res = B.deref h bres in let q = LUT.parse_list_up_to (cond_string_up_to terminator) p prf in B.live h0 bres /\ I.live sl h0 /\ I.live sl h /\ B.loc_disjoint (I.footprint sl) (B.loc_buffer bres `B.loc_union` app_loc ctxt loc_none) /\ B.loc_disjoint (B.loc_buffer bres) (app_loc ctxt loc_none) /\ B.live h0 ctxt /\ B.live h ctxt /\ address_liveness_insensitive_locs `loc_includes` (app_loc ctxt loc_none) /\ B.modifies (B.loc_buffer bres `B.loc_union` I.perm_footprint sl `B.loc_union` app_loc ctxt loc_none) h0 h /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) /\ begin if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse q s)) else U64.v res == Seq.length (I.get_read sl h) /\ begin if stop then valid_consumed q h0 h sl else match LP.parse q s, LP.parse q s' with | None, None -> True | Some (_, consumed), Some (_, consumed') -> consumed' + Seq.length s - Seq.length s' == consumed | _ -> False end end end inline_for_extraction let validate_list_up_to_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) (v: validator p) (r: leaf_reader p) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (h0: HS.mem) (bres: B.pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false )) (ensures (fun h stop h' -> validate_list_up_to_inv p terminator prf ctxt sl h0 bres h false /\ validate_list_up_to_inv p terminator prf ctxt sl h0 bres h' stop )) = let h = HST.get () in LUT.parse_list_up_to_eq (cond_string_up_to terminator) p prf (I.get_remaining sl h); let position = !* bres in let result = v ctxt error_handler_fn sl sl_len position in B.upd bres 0ul result; if LPE.is_error result then begin true end else begin let value = r sl position in cond_string_up_to terminator value end inline_for_extraction noextract let validate_list_up_to (#k: parser_kind true WeakKindStrongPrefix) (#t: eqtype) (#p: parser k t) (v: validator p) (r: leaf_reader p) (terminator: t) (prf: LUT.consumes_if_not_cond (cond_string_up_to terminator) p) : Tot (validate_with_action_t #true #WeakKindStrongPrefix (LUT.parse_list_up_to (cond_string_up_to terminator) p prf) true_inv eloc_none false) = fun ctxt error_handler_fn sl sl_len pos -> let h0 = HST.get () in HST.push_frame (); let h1 = HST.get () in fresh_frame_modifies h0 h1; let bres = B.alloca pos 1ul in let h2 = HST.get () in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_up_to_inv p terminator prf ctxt sl h2 bres) (fun _ -> validate_list_up_to_body terminator prf v r ctxt error_handler_fn sl sl_len h2 bres) ; let result = B.index bres 0ul in HST.pop_frame (); result let validate_string #k #t #p v r terminator = LP.parser_kind_prop_equiv k p; validate_weaken (validate_list_up_to v r terminator (fun _ _ _ -> ())) _ let validate_all_bytes = fun _ _ input input_length start_position -> I.empty input input_length start_position let validate_all_zeros = validate_list (validate_filter "parse_zeros" validate____UINT8 read____UINT8 is_zero "check if zero" "") //////////////////////////////////////////////////////////////////////////////// noextract inline_for_extraction let action_return #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#a:Type) (x:a) : action p true_inv eloc_none false a = fun _ _ _ _ -> x noextract inline_for_extraction let action_bind (name: string) #nz #wk (#k:parser_kind nz wk) (#t:Type) (#p:parser k t) (#invf:slice_inv) (#lf:eloc) #bf (#a:Type) (f: action p invf lf bf a) (#invg:slice_inv) (#lg:eloc) #bg (#b:Type) (g: (a -> action p invg lg bg b))
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val action_bind (name: string) (#nz:_) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] invf:slice_inv) (#[@@@erasable] lf:eloc) (#bf:_) (#a:Type) (f: action p invf lf bf a) (#[@@@erasable] invg:slice_inv) (#[@@@erasable] lg:eloc) (#bg:_) (#b:Type) (g: (a -> action p invg lg bg b)) : Tot (action p (conj_inv invf invg) (eloc_union lf lg) (bf || bg) b)
[]
EverParse3d.Actions.Base.action_bind
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
name: Prims.string -> f: EverParse3d.Actions.Base.action p invf lf bf a -> g: (_: a -> EverParse3d.Actions.Base.action p invg lg bg b) -> EverParse3d.Actions.Base.action p (EverParse3d.Actions.Base.conj_inv invf invg) (EverParse3d.Actions.Base.eloc_union lf lg) (bf || bg) b
{ "end_col": 27, "end_line": 1611, "start_col": 4, "start_line": 1605 }
Prims.Tot
val validate_dep_pair (name1: string) (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#[@@@erasable] t2:t1 -> Type) (#[@@@erasable] p2:(x:t1 -> parser k2 (t2 x))) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#allow_reading2:bool) (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 allow_reading2)) : validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false
[ { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1
val validate_dep_pair (name1: string) (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#[@@@erasable] t2:t1 -> Type) (#[@@@erasable] p2:(x:t1 -> parser k2 (t2 x))) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#allow_reading2:bool) (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 allow_reading2)) : validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false let validate_dep_pair (name1: string) #nz1 (#k1: parser_kind nz1 _) #t1 (#p1: parser k1 t1) #inv1 #l1 (v1: validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2: parser_kind nz2 wk2) (#t2: (t1 -> Type)) (#p2: (x: t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2: (x: t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false ) =
false
null
false
fun ctxt error_handler_fn input input_length start_position -> [@@ inline_let ]let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@@ (rename_let ("positionAfter" ^ name1)) ]let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error pos1 then pos1 else [@@ (rename_let ("" ^ name1)) ]let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.string", "Prims.bool", "EverParse3d.Kinds.parser_kind", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Actions.Base.leaf_reader", "EverParse3d.Kinds.weak_kind", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "EverParse3d.ErrorCode.is_error", "FStar.UInt64.t", "EverParse3d.Actions.Base.validate_drop", "Prims.unit", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Spec.Combinators.parse_dtuple2_eq", "EverParse3d.InputStream.Base.get_remaining", "Prims.op_BarBar", "EverParse3d.Kinds.and_then_kind", "Prims.dtuple2", "EverParse3d.Prelude.parse_dep_pair", "EverParse3d.Actions.Base.conj_inv", "EverParse3d.Actions.Base.eloc_union" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2))
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_dep_pair (name1: string) (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#[@@@erasable] t2:t1 -> Type) (#[@@@erasable] p2:(x:t1 -> parser k2 (t2 x))) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#allow_reading2:bool) (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 allow_reading2)) : validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false
[]
EverParse3d.Actions.Base.validate_dep_pair
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
name1: Prims.string -> v1: EverParse3d.Actions.Base.validate_with_action_t p1 inv1 l1 true -> r1: EverParse3d.Actions.Base.leaf_reader p1 -> v2: (x: t1 -> EverParse3d.Actions.Base.validate_with_action_t (p2 x) inv2 l2 allow_reading2) -> EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_dep_pair p1 p2) (EverParse3d.Actions.Base.conj_inv inv1 inv2) (EverParse3d.Actions.Base.eloc_union l1 l2) false
{ "end_col": 74, "end_line": 373, "start_col": 4, "start_line": 357 }
Prims.Tot
val validate_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false)
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end
val validate_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) let validate_t_at_most (n: U32.t) #nz #wk (#k: parser_kind nz wk) (#t: _) (#p: parser k t) (#inv: _) (#l: _) (#ar: _) (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) =
false
null
false
fun ctxt error_handler_fn input input_length start_position -> [@@ inline_let ]let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert ((I.get_remaining truncatedInput h2) `Seq.equal` (Seq.slice (I.get_remaining input h) 0 (U32.v n))) in [@@ inline_let ]let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` (Cast.uint32_to_uint64 n)
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "Prims.op_Negation", "EverParse3d.ErrorCode.set_validator_error_pos", "EverParse3d.ErrorCode.validator_error_not_enough_data", "FStar.UInt64.t", "EverParse3d.ErrorCode.is_error", "FStar.UInt64.add", "FStar.Int.Cast.uint32_to_uint64", "Prims.unit", "EverParse3d.InputStream.Base.is_prefix_of_prop", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "EverParse3d.InputStream.Base.empty", "EverParse3d.Actions.Base.validate_drop", "LowParse.Spec.Combinators.nondep_then_eq", "EverParse3d.Kinds.kind_all_bytes", "EverParse3d.Prelude.all_bytes", "EverParse3d.Prelude.parse_all_bytes", "EverParse3d.InputStream.Base.get_remaining", "Prims._assert", "FStar.Seq.Base.equal", "FStar.UInt8.t", "FStar.Seq.Base.slice", "FStar.UInt32.v", "EverParse3d.InputStream.Base.__proj__Mkinput_stream_inst__item__tlen", "EverParse3d.InputStream.Base.truncate_len", "EverParse3d.InputStream.Base.truncate", "EverParse3d.InputStream.Base.has", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Kinds.kind_t_at_most", "EverParse3d.Prelude.t_at_most", "EverParse3d.Prelude.parse_t_at_most" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10", "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 16, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_t_at_most (n:U32.t) (#nz: _) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false)
[]
EverParse3d.Actions.Base.validate_t_at_most
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
n: FStar.UInt32.t -> v: EverParse3d.Actions.Base.validate_with_action_t p inv l ar -> EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_t_at_most n p) inv l false
{ "end_col": 9, "end_line": 1228, "start_col": 4, "start_line": 1200 }
Prims.Tot
val validate_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false)
[ { "abbrev": true, "full_module": "LowParse.Low.FLData", "short_module": "LPLF" }, { "abbrev": true, "full_module": "LowParse.Spec.List", "short_module": "LPLL" }, { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result end
val validate_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) let validate_t_exact (n: U32.t) #nz #wk (#k: parser_kind nz wk) (#t: _) (#p: parser k t) (#inv: _) (#l: _) (#ar: _) (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false) =
false
null
false
fun ctxt error_handler_fn input input_length start_position -> [@@ inline_let ]let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert ((I.get_remaining truncatedInput h2) `Seq.equal` (Seq.slice (I.get_remaining input h) 0 (U32.v n))) in [@@ inline_let ]let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else let stillHasBytes = I.has truncatedInput truncatedInputLength result 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; I.is_prefix_of_prop truncatedInput input h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding result else result
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.bool", "EverParse3d.Kinds.weak_kind", "EverParse3d.Kinds.parser_kind", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "Prims.op_Negation", "EverParse3d.ErrorCode.set_validator_error_pos", "EverParse3d.ErrorCode.validator_error_not_enough_data", "FStar.UInt64.t", "EverParse3d.ErrorCode.is_error", "EverParse3d.ErrorCode.validator_error_unexpected_padding", "Prims.unit", "EverParse3d.InputStream.Base.is_prefix_of_prop", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "EverParse3d.InputStream.Base.has", "FStar.UInt64.__uint_to_t", "EverParse3d.Actions.Base.validate_drop", "LowParse.Spec.Combinators.nondep_then_eq", "EverParse3d.Kinds.kind_all_bytes", "EverParse3d.Prelude.all_bytes", "EverParse3d.Prelude.parse_all_bytes", "EverParse3d.InputStream.Base.get_remaining", "Prims._assert", "FStar.Seq.Base.equal", "FStar.UInt8.t", "FStar.Seq.Base.slice", "FStar.UInt32.v", "EverParse3d.InputStream.Base.__proj__Mkinput_stream_inst__item__tlen", "EverParse3d.InputStream.Base.truncate_len", "FStar.Int.Cast.uint32_to_uint64", "EverParse3d.InputStream.Base.truncate", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Kinds.kind_t_exact", "EverParse3d.Prelude.t_exact", "EverParse3d.Prelude.parse_t_exact" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end inline_for_extraction noextract let validate_dep_pair_with_refinement' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h1 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement_total_zero_parser' (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) (inv1: _) (l1: _) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in // assert (B.modifies B.loc_none h1 h2); // assert (inv1' input.LPL.base h2); modifies_address_liveness_insensitive_unused_in h0 h2; // assert (loc_not_unused_in h2 `loc_includes` l1'); // assert (valid_pos (p1 `(LPC.parse_filter #k1 #t1)` f) h0 input (uint64_to_uint32 pos) (uint64_to_uint32 res)); let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end inline_for_extraction noextract let validate_dep_pair_with_refinement (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_total_zero_parser' name1 inv1 l1 r1 f v2 else validate_dep_pair_with_refinement' name1 v1 r1 f v2 inline_for_extraction noextract let validate_filter (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); LPE.check_constraint_ok ok res end inline_for_extraction noextract let validate_filter_with_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (f:t -> bool) (cr:string) (cf:string) (#b:bool) #inva (#la:eloc) (a: t -> action #nz #WeakKindStrongPrefix #(filter_kind k) #_ (p `LPC.parse_filter` f) inva la b bool) : Tot (validate_with_action_t #nz #WeakKindStrongPrefix (p `LPC.parse_filter` f) (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in LPC.parse_filter_eq p f (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin LowStar.Comment.comment cr; [@(rename_let ("" ^ name))] let field_value = r input pos0 in LowStar.Comment.comment (normalize_term ("start: " ^cf)); [@(rename_let (name ^ "ConstraintIsOk"))] let ok = f field_value in LowStar.Comment.comment (normalize_term ("end: " ^ cf)); if ok then let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res else LPE.set_validator_error_pos LPE.validator_error_constraint_failed res end inline_for_extraction noextract let validate_with_dep_action (name: string) #nz (#k:parser_kind nz _) (#t:_) (#p:parser k t) #inv #l (v:validate_with_action_t p inv l true) (r:leaf_reader p) (#b:bool) #inva (#la:eloc) (a: t -> action p inva la b bool) : Tot (validate_with_action_t #nz p (conj_inv inv inva) (eloc_union l la) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h = HST.get () in [@(rename_let ("positionAfter" ^ name))] let res = v ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in if LPE.is_error res then res else begin [@(rename_let ("" ^ name))] let field_value = r input pos0 in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in if a field_value ctxt input pos0 res then res else LPE.set_validator_error_pos LPE.validator_error_action_failed res end inline_for_extraction noextract let validate_weaken #nz #wk (#k:parser_kind nz wk) #t (#p:parser k t) #inv #l #ar (v:validate_with_action_t p inv l ar) #nz' #wk' (k':parser_kind nz' wk'{k' `is_weaker_than` k}) : Tot (validate_with_action_t (parse_weaken p k') inv l ar) = fun ctxt error_handler_fn input input_length start_position -> v ctxt error_handler_fn input input_length start_position /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_left (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_left p k') inv l ar = validate_weaken v (glb k' k) /// Parser: weakening kinds inline_for_extraction noextract let validate_weaken_right (#nz:_) #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) #ar (v:validate_with_action_t p inv l ar) (#nz':_) #wk' (k':parser_kind nz' wk') : validate_with_action_t (parse_weaken_right p k') inv l ar = validate_weaken v (glb k k') inline_for_extraction noextract let validate_impos () : Tot (validate_with_action_t (parse_impos ()) true_inv eloc_none true) = fun _ _ _ _ start_position -> LPE.set_validator_error_pos LPE.validator_error_impossible start_position noextract inline_for_extraction let validate_ite e p1 v1 p2 v2 = fun ctxt error_handler_fn input input_len start_position -> if e then validate_drop (v1 ()) ctxt error_handler_fn input input_len start_position else validate_drop (v2 ()) ctxt error_handler_fn input input_len start_position module LPLL = LowParse.Spec.List unfold let validate_list_inv (#k: LPL.parser_kind) (#t: Type) (p: LPL.parser k t) (inv: slice_inv) (l: eloc) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (sl: input_buffer_t) (bres: pointer U64.t) (h: HS.mem) (stop: bool) : GTot Type0 = let h0 = Ghost.reveal g0 in let h1 = Ghost.reveal g1 in let res = Seq.index (as_seq h bres) 0 in inv (I.footprint sl) h0 /\ loc_not_unused_in h0 `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ app_loc ctxt l `loc_disjoint` loc_buffer bres /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.loc_buffer bres `B.loc_disjoint` I.footprint sl /\ I.live sl h0 /\ I.live sl h /\ live h0 ctxt /\ live h ctxt /\ live h1 bres /\ begin let s = I.get_remaining sl h0 in let s' = I.get_remaining sl h in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ modifies loc_none h0 h1 /\ ( if LPE.is_error res then // validation *or action* failed stop == true /\ U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h) /\ (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> ~ (valid (LPLL.parse_list p) h0 sl)) else U64.v res == Seq.length (I.get_read sl h) /\ (valid (LPLL.parse_list p) h0 sl <==> valid (LPLL.parse_list p) h sl) /\ (stop == true ==> (valid (LPLL.parse_list p) h sl /\ Seq.length (I.get_remaining sl h) == 0)) ) /\ modifies (app_loc ctxt l `loc_union` loc_buffer bres `loc_union` I.perm_footprint sl) h1 h inline_for_extraction noextract let validate_list_body (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (g0 g1: Ghost.erased HS.mem) (ctxt:app_ctxt) (error_handler_fn:error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (bres: pointer U64.t) : HST.Stack bool (requires (fun h -> validate_list_inv p inv l g0 g1 ctxt sl bres h false)) (ensures (fun h res h' -> validate_list_inv p inv l g0 g1 ctxt sl bres h false /\ validate_list_inv p inv l g0 g1 ctxt sl bres h' res )) = let h = HST.get () in LPLL.parse_list_eq p (I.get_remaining sl h); let position = !* bres in if not (I.has sl sl_len position 1uL) then true else begin let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in (Ghost.reveal g0) h1; let result = validate_drop v ctxt error_handler_fn sl sl_len position in upd bres 0ul result; LPE.is_error result end inline_for_extraction noextract let validate_list' (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) (ctxt: app_ctxt) (error_handler_fn: error_handler) (sl: input_buffer_t) (sl_len: I.tlen sl) (pos: LPE.pos_t) : HST.Stack U64.t (requires (fun h -> inv (I.footprint sl) h /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ B.live h ctxt /\ I.live sl h /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in inv (I.footprint sl) h' /\ B.live h' ctxt /\ I.live sl h' /\ begin let s' = I.get_remaining sl h' in Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end /\ begin match LP.parse (LPLL.parse_list p) s with | None -> LPE.is_success res == false | Some (_, len) -> if LPE.is_success res then I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) /\ U64.v res == Seq.length (I.get_read sl h') else LPE.get_validator_error_kind res == LPE.get_validator_error_kind LPE.validator_error_action_failed end /\ (LPE.is_success res == false ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h h' )) = let h0 = HST.get () in let g0 = Ghost.hide h0 in HST.push_frame (); let h02 = HST.get () in fresh_frame_modifies h0 h02; let result = alloca pos 1ul in let h1 = HST.get () in let g1 = Ghost.hide h1 in I.live_not_unused_in sl h0; C.Loops.do_while (validate_list_inv p inv l g0 g1 ctxt sl result) (fun _ -> validate_list_body v g0 g1 ctxt error_handler_fn sl sl_len result); let finalResult = index result 0ul in let h2 = HST.get () in HST.pop_frame (); let h' = HST.get () in assert (B.modifies (app_loc ctxt l `B.loc_union` I.perm_footprint sl) h0 h'); LP.parser_kind_prop_equiv LPLL.parse_list_kind (LPLL.parse_list p); finalResult inline_for_extraction noextract let validate_list (#k:LP.parser_kind) #t (#p:LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.List.parse_list p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> validate_list' v ctxt error_handler_fn input input_length start_position #push-options "--z3rlimit 32" #restart-solver module LPLF = LowParse.Low.FLData noextract inline_for_extraction let validate_fldata_consumes_all (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar { k.LP.parser_kind_subkind == Some LP.ParserConsumesAll }) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPLF.parse_fldata_consumes_all_correct p (U32.v n) (I.get_remaining input h); let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in I.is_prefix_of_prop truncatedInput input h3; res end #pop-options #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_fldata (n:U32.t) (#k: LP.parser_kind) #t (#p: LP.parser k t) #inv #l #ar (v: validate_with_action_t' p inv l ar) : Tot (validate_with_action_t' (LowParse.Spec.FLData.parse_fldata p (U32.v n)) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasEnoughBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasEnoughBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else begin let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; I.is_prefix_of_prop truncatedInput input h2; assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)); let res = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h h3; I.is_prefix_of_prop truncatedInput input h3; if LPE.is_error res then res else begin let stillHasBytes = I.has truncatedInput truncatedInputLength res 1uL in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; if stillHasBytes then LPE.set_validator_error_pos LPE.validator_error_unexpected_padding res else res end end #pop-options noextract inline_for_extraction let validate_nlist (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = validate_weaken #false #WeakKindStrongPrefix #(LowParse.Spec.FLData.parse_fldata_kind (U32.v n) LowParse.Spec.List.parse_list_kind) #(list t) (validate_fldata_consumes_all n (validate_list v)) kind_nlist inline_for_extraction noextract let validate_total_constant_size_no_read' (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t' p inv l true) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LP.parser_kind_prop_equiv k p; let hasBytes = I.has input input_length pos sz in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h h2; if hasBytes then pos `U64.add` sz else LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos inline_for_extraction noextract let validate_total_constant_size_no_read #nz #wk (#k: parser_kind nz wk) (#t: Type) (p: parser k t) (sz: U64.t) (u: unit { k.LP.parser_kind_high == Some k.LP.parser_kind_low /\ k.LP.parser_kind_low == U64.v sz /\ k.LP.parser_kind_metadata == Some LP.ParserKindMetadataTotal }) inv l : Tot (validate_with_action_t p inv l true) = validate_total_constant_size_no_read' p sz u inv l inline_for_extraction noextract let validate_nlist_total_constant_size_mod_ok (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 /\ U32.v n % k.LP.parser_kind_low == 0 )) (ensures (fun _ -> True)) = [@inline_let] let _ = parse_nlist_total_fixed_size_kind_correct n p in validate_total_constant_size_no_read' (LP.strengthen (LP.total_constant_size_parser_kind (U32.v n)) (parse_nlist n p)) (Cast.uint32_to_uint64 n) () inv l inline_for_extraction noextract let validate_nlist_constant_size_mod_ko (n:U32.t) (#wk: _) (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ U32.v n % k.LP.parser_kind_low <> 0 )) (ensures (fun _ -> True)) = (fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = FStar.HyperStack.ST.get () in [@inline_let] let f () : Lemma (requires (Some? (LP.parse (parse_nlist n p) (I.get_remaining input h)))) (ensures False) = let sq = I.get_remaining input h in let sq' = Seq.slice sq 0 (U32.v n) in LowParse.Spec.List.list_length_constant_size_parser_correct p sq' ; let Some (l, _) = LP.parse (parse_nlist n p) sq in assert (U32.v n == FStar.List.Tot.length l `Prims.op_Multiply` k.LP.parser_kind_low) ; FStar.Math.Lemmas.cancel_mul_mod (FStar.List.Tot.length l) k.LP.parser_kind_low ; assert (U32.v n % k.LP.parser_kind_low == 0) in [@inline_let] let _ = Classical.move_requires f () in LPE.set_validator_error_pos LPE.validator_error_list_size_not_multiple pos ) inline_for_extraction noextract let validate_nlist_total_constant_size' (n:U32.t) #wk (#k:parser_kind true wk) #t (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind == Some ParserStrong /\ k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input start_position -> // n is not an integer constant, so we need to eta-expand and swap fun and if if n `U32.rem` U32.uint_to_t k.LP.parser_kind_low = 0ul then validate_nlist_total_constant_size_mod_ok n p inv l ctxt error_handler_fn input start_position else validate_nlist_constant_size_mod_ko n p inv l ctxt error_handler_fn input start_position inline_for_extraction noextract let validate_nlist_total_constant_size (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) (#t: Type) (p:parser k t) inv l : Pure (validate_with_action_t (parse_nlist n p) inv l true) (requires ( let open LP in k.parser_kind_subkind = Some ParserStrong /\ k.parser_kind_high = Some k.parser_kind_low /\ k.parser_kind_metadata = Some ParserKindMetadataTotal /\ k.parser_kind_low < 4294967296 )) (ensures (fun _ -> True)) = if if k.LP.parser_kind_low = 1 then true else if n_is_const then U32.v n % k.LP.parser_kind_low = 0 else false then validate_nlist_total_constant_size_mod_ok n p inv l else if if n_is_const then U32.v n % k.LP.parser_kind_low <> 0 else false then validate_nlist_constant_size_mod_ko n p inv l else validate_nlist_total_constant_size' n p inv l noextract inline_for_extraction let validate_nlist_constant_size_without_actions (n_is_const: bool) (n:U32.t) #wk (#k:parser_kind true wk) #t (#p:parser k t) #inv #l #ar (v: validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_nlist n p) inv l false) = if let open LP in k.parser_kind_subkind = Some ParserStrong && k.parser_kind_high = Some k.parser_kind_low && k.parser_kind_metadata = Some ParserKindMetadataTotal && k.parser_kind_low < 4294967296 then validate_drop (validate_nlist_total_constant_size n_is_const n p inv l) else validate_nlist n v #push-options "--z3rlimit_factor 16 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_at_most (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_at_most n p) inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in let hasBytes = I.has input input_length pos (Cast.uint32_to_uint64 n) in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if not hasBytes then LPE.set_validator_error_pos LPE.validator_error_not_enough_data pos else let truncatedInput = I.truncate input pos (Cast.uint32_to_uint64 n) in let truncatedInputLength = I.truncate_len input pos (Cast.uint32_to_uint64 n) truncatedInput in let h2 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h2 in let _ = I.is_prefix_of_prop truncatedInput input h2 in let _ = assert (I.get_remaining truncatedInput h2 `Seq.equal` Seq.slice (I.get_remaining input h) 0 (U32.v n)) in [@inline_let] let _ = LPC.nondep_then_eq p parse_all_bytes (I.get_remaining truncatedInput h2) in let result = validate_drop v ctxt error_handler_fn truncatedInput truncatedInputLength pos in let h3 = HST.get () in let _ = I.is_prefix_of_prop truncatedInput input h3 in if LPE.is_error result then result else begin let _ = I.empty truncatedInput truncatedInputLength result in let h4 = HST.get () in modifies_address_liveness_insensitive_unused_in h h4; let _ = I.is_prefix_of_prop truncatedInput input h4 in pos `U64.add` Cast.uint32_to_uint64 n end #pop-options #push-options "--z3rlimit 128 --z3cliopt smt.arith.nl=false" #restart-solver noextract inline_for_extraction let validate_t_exact (n:U32.t) #nz #wk (#k:parser_kind nz wk) (#t:_) (#p:parser k t) (#inv:_) (#l:_) (#ar:_) (v:validate_with_action_t p inv l ar)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10", "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 128, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_t_exact (n:U32.t) (#nz:bool) (#wk: _) (#k:parser_kind nz wk) (#[@@@erasable] t:Type) (#[@@@erasable] p:parser k t) (#[@@@erasable] inv:slice_inv) (#[@@@erasable] l:eloc) (#ar:_) (v:validate_with_action_t p inv l ar) : Tot (validate_with_action_t (parse_t_exact n p) inv l false)
[]
EverParse3d.Actions.Base.validate_t_exact
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
n: FStar.UInt32.t -> v: EverParse3d.Actions.Base.validate_with_action_t p inv l ar -> EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_t_exact n p) inv l false
{ "end_col": 9, "end_line": 1269, "start_col": 4, "start_line": 1239 }
Prims.Pure
val validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1: parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1: parser k1 t1) (r1: leaf_reader p1) (inv1 l1: _) (f: (t1 -> bool)) (#inv1' #l1' #b: _) (a: (t1 -> action p1 inv1' l1' b bool)) (#nz2 #wk2: _) (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) (#inv2 #l2 #ar2: _) (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires (let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal)) (ensures (fun _ -> True))
[ { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end
val validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1: parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1: parser k1 t1) (r1: leaf_reader p1) (inv1 l1: _) (f: (t1 -> bool)) (#inv1' #l1' #b: _) (a: (t1 -> action p1 inv1' l1' b bool)) (#nz2 #wk2: _) (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) (#inv2 #l2 #ar2: _) (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires (let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal)) (ensures (fun _ -> True)) let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1: parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1: parser k1 t1) (r1: leaf_reader p1) (inv1 l1: _) (f: (t1 -> bool)) (#inv1' #l1' #b: _) (a: (t1 -> action p1 inv1' l1' b bool)) (#nz2 #wk2: _) (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) (#inv2 #l2 #ar2: _) (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires (let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal)) (ensures (fun _ -> True)) =
false
null
false
fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@@ inline_let ]let _ = LP.parser_kind_prop_equiv k1 p1 in LowStar.Comment.comment ("Validating field " ^ name1); [@@ (rename_let ("" ^ name1)) ]let field_value = r1 input startPosition in [@@ (rename_let (name1 ^ "ConstraintIsOk")) ]let ok = f field_value in [@@ (rename_let ("positionAfter" ^ name1)) ]let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition else let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[]
[ "Prims.string", "Prims.bool", "EverParse3d.Kinds.parser_kind", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.leaf_reader", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.action", "EverParse3d.Kinds.weak_kind", "EverParse3d.Prelude.refine", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "EverParse3d.ErrorCode.is_error", "FStar.UInt64.t", "EverParse3d.ErrorCode.set_validator_error_pos", "EverParse3d.ErrorCode.validator_error_action_failed", "EverParse3d.Actions.Base.validate_drop", "Prims.unit", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.op_Negation", "EverParse3d.ErrorCode.check_constraint_ok", "LowStar.Comment.comment", "Prims.op_Hat", "LowParse.Spec.Base.parser_kind_prop_equiv", "LowParse.Spec.Combinators.parse_filter_eq", "EverParse3d.InputStream.Base.get_remaining", "LowParse.Spec.Combinators.parse_dtuple2_eq'", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.Combinators.parse_filter", "Prims.op_BarBar", "EverParse3d.Kinds.and_then_kind", "Prims.dtuple2", "EverParse3d.Prelude.parse_dep_pair", "EverParse3d.Actions.Base.conj_inv", "EverParse3d.Actions.Base.eloc_union", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "Prims.nat", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.parser_kind_metadata_some", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_metadata", "LowParse.Spec.Base.ParserKindMetadataTotal", "Prims.l_True" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal ))
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1: parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1: parser k1 t1) (r1: leaf_reader p1) (inv1 l1: _) (f: (t1 -> bool)) (#inv1' #l1' #b: _) (a: (t1 -> action p1 inv1' l1' b bool)) (#nz2 #wk2: _) (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) (#inv2 #l2 #ar2: _) (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires (let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal)) (ensures (fun _ -> True))
[]
EverParse3d.Actions.Base.validate_dep_pair_with_refinement_and_action_total_zero_parser'
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
name1: Prims.string -> r1: EverParse3d.Actions.Base.leaf_reader p1 -> inv1: EverParse3d.Actions.Base.slice_inv -> l1: EverParse3d.Actions.Base.eloc -> f: (_: t1 -> Prims.bool) -> a: (_: t1 -> EverParse3d.Actions.Base.action p1 inv1' l1' b Prims.bool) -> v2: (x: EverParse3d.Prelude.refine t1 f -> EverParse3d.Actions.Base.validate_with_action_t (p2 x) inv2 l2 ar2) -> Prims.Pure (EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_dep_pair (LowParse.Spec.Combinators.parse_filter p1 f) p2) (EverParse3d.Actions.Base.conj_inv inv1 (EverParse3d.Actions.Base.conj_inv inv1' inv2)) (EverParse3d.Actions.Base.eloc_union l1 (EverParse3d.Actions.Base.eloc_union l1' l2)) false)
{ "end_col": 11, "end_line": 476, "start_col": 4, "start_line": 451 }
Prims.Tot
val validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1: parser_kind nz1 _) (#t1: _) (#p1: parser k1 t1) (#inv1 #l1: _) (v1: validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: (t1 -> bool)) (#inv1' #l1' #b: _) (a: (t1 -> action p1 inv1' l1' b bool)) (#nz2 #wk2: _) (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) (#inv2 #l2 #ar2: _) (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false)
[ { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end
val validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1: parser_kind nz1 _) (#t1: _) (#p1: parser k1 t1) (#inv1 #l1: _) (v1: validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: (t1 -> bool)) (#inv1' #l1' #b: _) (a: (t1 -> action p1 inv1' l1' b bool)) (#nz2 #wk2: _) (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) (#inv2 #l2 #ar2: _) (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1: parser_kind nz1 _) (#t1: _) (#p1: parser k1 t1) (#inv1 #l1: _) (v1: validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: (t1 -> bool)) (#inv1' #l1' #b: _) (a: (t1 -> action p1 inv1' l1' b bool)) (#nz2 #wk2: _) (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) (#inv2 #l2 #ar2: _) (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) =
false
null
false
fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@@ (rename_let ("positionAfter" ^ name1)) ]let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then res else (assert (I.get_remaining input h1 == I.get_remaining input h0); [@@ (rename_let ("" ^ name1)) ]let field_value = r1 input startPosition in [@@ (rename_let (name1 ^ "ConstraintIsOk")) ]let ok = f field_value in [@@ (rename_let ("positionAfter" ^ name1)) ]let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get () in if LPE.is_error res1 then res1 else (modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 else let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1))
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.string", "Prims.bool", "EverParse3d.Kinds.parser_kind", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Actions.Base.leaf_reader", "EverParse3d.Actions.Base.action", "EverParse3d.Kinds.weak_kind", "EverParse3d.Prelude.refine", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "EverParse3d.ErrorCode.is_error", "FStar.UInt64.t", "EverParse3d.ErrorCode.set_validator_error_pos", "EverParse3d.ErrorCode.validator_error_action_failed", "EverParse3d.Actions.Base.validate_drop", "Prims.unit", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.op_Negation", "EverParse3d.ErrorCode.check_constraint_ok", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.seq", "FStar.UInt8.t", "EverParse3d.InputStream.Base.get_remaining", "LowParse.Spec.Combinators.parse_filter_eq", "LowParse.Spec.Combinators.parse_dtuple2_eq'", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.Combinators.parse_filter", "Prims.op_BarBar", "EverParse3d.Kinds.and_then_kind", "Prims.dtuple2", "EverParse3d.Prelude.parse_dep_pair", "EverParse3d.Actions.Base.conj_inv", "EverParse3d.Actions.Base.eloc_union" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false)
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1: parser_kind nz1 _) (#t1: _) (#p1: parser k1 t1) (#inv1 #l1: _) (v1: validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: (t1 -> bool)) (#inv1' #l1' #b: _) (a: (t1 -> action p1 inv1' l1' b bool)) (#nz2 #wk2: _) (#k2: parser_kind nz2 wk2) (#t2: (refine _ f -> Type)) (#p2: (x: refine _ f -> parser k2 (t2 x))) (#inv2 #l2 #ar2: _) (v2: (x: refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false)
[]
EverParse3d.Actions.Base.validate_dep_pair_with_refinement_and_action'
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
name1: Prims.string -> v1: EverParse3d.Actions.Base.validate_with_action_t p1 inv1 l1 true -> r1: EverParse3d.Actions.Base.leaf_reader p1 -> f: (_: t1 -> Prims.bool) -> a: (_: t1 -> EverParse3d.Actions.Base.action p1 inv1' l1' b Prims.bool) -> v2: (x: EverParse3d.Prelude.refine t1 f -> EverParse3d.Actions.Base.validate_with_action_t (p2 x) inv2 l2 ar2) -> EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_dep_pair (LowParse.Spec.Combinators.parse_filter p1 f) p2) (EverParse3d.Actions.Base.conj_inv inv1 (EverParse3d.Actions.Base.conj_inv inv1' inv2)) (EverParse3d.Actions.Base.eloc_union l1 (EverParse3d.Actions.Base.eloc_union l1' l2)) false
{ "end_col": 9, "end_line": 429, "start_col": 2, "start_line": 395 }
Prims.Tot
val validate_dep_pair_with_action (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (#[@@@erasable] inv1':slice_inv) (#[@@@erasable] l1':eloc) (#b:_) (a:t1 -> action p1 inv1' l1' b bool) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#[@@@erasable] t2:t1 -> Type) (#[@@@erasable] p2:(x:t1 -> parser k2 (t2 x))) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#allow_reading2:_) (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 allow_reading2)) : validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false
[ { "abbrev": true, "full_module": "LowParse.Spec.Combinators", "short_module": "LPC" }, { "abbrev": true, "full_module": "LowParse.Low.Base", "short_module": "LPL" }, { "abbrev": true, "full_module": "LowParse.Spec.Base", "short_module": "LP" }, { "abbrev": true, "full_module": "EverParse3d.Prelude", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Tactics.Typeclasses", "short_module": null }, { "abbrev": true, "full_module": "EverParse3d.ErrorCode", "short_module": "LPE" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "EverParse3d.InputStream.Base", "short_module": "I" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Actions", "short_module": null }, { "abbrev": false, "full_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_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin let field_value = r1 input startPosition in let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res //action failed else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res end
val validate_dep_pair_with_action (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (#[@@@erasable] inv1':slice_inv) (#[@@@erasable] l1':eloc) (#b:_) (a:t1 -> action p1 inv1' l1' b bool) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#[@@@erasable] t2:t1 -> Type) (#[@@@erasable] p2:(x:t1 -> parser k2 (t2 x))) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#allow_reading2:_) (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 allow_reading2)) : validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false let validate_dep_pair_with_action #nz1 (#k1: parser_kind nz1 _) #t1 (#p1: parser k1 t1) #inv1 #l1 (v1: validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a: (t1 -> action p1 inv1' l1' b bool)) #nz2 #wk2 (#k2: parser_kind nz2 wk2) (#t2: (t1 -> Type)) (#p2: (x: t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2: (x: t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) =
false
null
false
fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ p1 #_ #t2 p2 (I.get_remaining input h0); let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then res else let field_value = r1 input startPosition in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; let action_result = a field_value ctxt input startPosition res in let h3 = HST.get () in modifies_address_liveness_insensitive_unused_in h2 h3; if not action_result then LPE.set_validator_error_pos LPE.validator_error_action_failed res else validate_drop (v2 field_value) ctxt error_handler_fn input input_length res
{ "checked_file": "EverParse3d.Actions.Base.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Comment.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Spec.List.fsti.checked", "LowParse.Spec.FLData.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Low.ListUpTo.fst.checked", "LowParse.Low.Int.fsti.checked", "LowParse.Low.FLData.fst.checked", "LowParse.Low.BoundedInt.fsti.checked", "LowParse.Low.Base.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Typeclasses.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lemmas.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked", "EverParse3d.Prelude.fst.checked", "EverParse3d.Kinds.fst.checked", "EverParse3d.InputStream.Base.fst.checked", "EverParse3d.InputStream.All.fsti.checked", "EverParse3d.ErrorCode.fst.checked", "C.Loops.fst.checked" ], "interface_file": true, "source_file": "EverParse3d.Actions.Base.fst" }
[ "total" ]
[ "Prims.bool", "EverParse3d.Kinds.parser_kind", "EverParse3d.Kinds.WeakKindStrongPrefix", "EverParse3d.Prelude.parser", "EverParse3d.Actions.Base.slice_inv", "EverParse3d.Actions.Base.eloc", "EverParse3d.Actions.Base.validate_with_action_t", "EverParse3d.Actions.Base.leaf_reader", "EverParse3d.Actions.Base.action", "EverParse3d.Kinds.weak_kind", "EverParse3d.InputStream.Base.extra_t", "EverParse3d.Actions.Base.input_buffer_t", "EverParse3d.InputStream.All.inst", "EverParse3d.Actions.Base.app_ctxt", "EverParse3d.Actions.Base.error_handler", "EverParse3d.InputStream.Base.tlen", "EverParse3d.ErrorCode.pos_t", "EverParse3d.ErrorCode.is_error", "FStar.UInt64.t", "Prims.op_Negation", "EverParse3d.ErrorCode.set_validator_error_pos", "EverParse3d.ErrorCode.validator_error_action_failed", "EverParse3d.Actions.Base.validate_drop", "Prims.unit", "LowStar.Monotonic.Buffer.modifies_address_liveness_insensitive_unused_in", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowParse.Spec.Combinators.parse_dtuple2_eq'", "EverParse3d.InputStream.Base.get_remaining", "Prims.op_BarBar", "EverParse3d.Kinds.and_then_kind", "Prims.dtuple2", "EverParse3d.Prelude.parse_dep_pair", "EverParse3d.Actions.Base.conj_inv", "EverParse3d.Actions.Base.eloc_union" ]
[]
module EverParse3d.Actions.Base friend EverParse3d.Kinds friend EverParse3d.Prelude open FStar.HyperStack.ST open LowStar.Buffer open LowStar.BufferOps module B = LowStar.Buffer module I = EverParse3d.InputStream.Base module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module LPE = EverParse3d.ErrorCode open FStar.Tactics.Typeclasses module B = LowStar.Buffer module U8 = FStar.UInt8 module P = EverParse3d.Prelude let hinv = HS.mem -> Tot Type0 let liveness_inv = i:hinv { forall l h0 h1. {:pattern (i h1); (modifies l h0 h1)} i h0 /\ modifies l h0 h1 /\ address_liveness_insensitive_locs `loc_includes` l ==> i h1 } let mem_inv = liveness_inv let slice_inv = loc -> mem_inv let inv_implies (inv0 inv1:slice_inv) = forall i h. inv0 i h ==> inv1 i h let true_inv : slice_inv = fun _ _ -> True let conj_inv (i0 i1:slice_inv) : slice_inv = fun sl h -> i0 sl h /\ i1 sl h let eloc = (l: FStar.Ghost.erased B.loc { B.address_liveness_insensitive_locs `B.loc_includes` l }) let eloc_union (l1 l2:eloc) : Tot eloc = B.loc_union l1 l2 let eloc_none : eloc = B.loc_none let eloc_includes (l1 l2:eloc) = B.loc_includes l1 l2 /\ True let inv_implies_refl inv = () let inv_implies_true inv0 = () let inv_implies_conj inv0 inv1 inv2 h01 h02 = () let eloc_includes_none l = () let eloc_includes_union l0 l1 l2 h01 h02 = () let eloc_includes_refl l = () let bpointer a = B.pointer a let ptr_loc #a (x:B.pointer a) : Tot eloc = B.loc_buffer x let ptr_inv #a (x:B.pointer a) : slice_inv = fun (sl:_) h -> B.live h x let app_ctxt = B.pointer U8.t let app_loc (x:app_ctxt) (l:eloc) : eloc = B.loc_buffer x `loc_union` l inline_for_extraction noextract let input_buffer_t = EverParse3d.InputStream.All.t let action p inv l on_success a = (# [tcresolve ()] I.extra_t #input_buffer_t) -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> posf: LPE.pos_t -> Stack a (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ app_loc ctxt l `loc_disjoint` I.footprint sl /\ U64.v pos <= U64.v posf /\ U64.v posf == Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt l) h0 h1 /\ B.live h1 ctxt /\ inv (I.footprint sl) h1) module LP = LowParse.Spec.Base module LPL = LowParse.Low.Base unfold let valid_consumed (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (h': HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ I.live sl h' /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len) -> I.get_remaining sl h' `Seq.equal` Seq.slice s len (Seq.length s) end end unfold let valid_length (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) (len: int) : Tot prop = I.live sl h /\ begin let s = I.get_remaining sl h in begin match LP.parse p s with | None -> False | Some (_, len') -> len == len' end end let valid (#input_buffer_t: Type0) (# [tcresolve ()] inst : I.input_stream_inst input_buffer_t) (#k: LP.parser_kind) (#t: Type) (p: LP.parser k t) (h: HS.mem) (sl: input_buffer_t) : Tot prop = I.live sl h /\ Some? (LP.parse p (I.get_remaining sl h)) inline_for_extraction let error_handler = typename:string -> fieldname:string -> error_reason:string -> error_code:U64.t -> ctxt: app_ctxt -> sl: input_buffer_t -> pos: LPE.pos_t -> Stack unit (requires fun h -> I.live sl h /\ true_inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt eloc_none /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt eloc_none /\ app_loc ctxt eloc_none `loc_disjoint` I.footprint sl /\ U64.v pos <= Seq.length (I.get_read sl h) ) (ensures fun h0 _ h1 -> let sl = Ghost.reveal sl in modifies (app_loc ctxt eloc_none) h0 h1 /\ B.live h1 ctxt /\ true_inv (I.footprint sl) h1) inline_for_extraction noextract let validate_with_action_t' (#k:LP.parser_kind) (#t:Type) (p:LP.parser k t) (inv:slice_inv) (l:eloc) (allow_reading:bool) = (# [tcresolve ()] I.extra_t #input_buffer_t) -> (ctxt: app_ctxt) -> (error_handler_fn : error_handler) -> (sl: input_buffer_t) -> (len: I.tlen sl) -> (pos: LPE.pos_t) -> Stack U64.t (requires fun h -> I.live sl h /\ inv (I.footprint sl) h /\ B.live h ctxt /\ loc_not_unused_in h `loc_includes` app_loc ctxt l /\ address_liveness_insensitive_locs `loc_includes` app_loc ctxt l /\ U64.v pos == Seq.length (I.get_read sl h) /\ app_loc ctxt l `loc_disjoint` I.footprint sl ) (ensures fun h res h' -> I.live sl h' /\ modifies (app_loc ctxt l `loc_union` I.perm_footprint sl) h h' /\ inv (I.footprint sl) h' /\ B.live h' ctxt /\ (((~ allow_reading) \/ LPE.is_error res) ==> U64.v (LPE.get_validator_error_pos res) == Seq.length (I.get_read sl h')) /\ begin let s = I.get_remaining sl h in if LPE.is_success res then begin if allow_reading then U64.v res >= U64.v pos /\ valid_length p h sl (U64.v res - U64.v pos) /\ I.get_remaining sl h' == s else valid_consumed p h h' sl end else let s' = I.get_remaining sl h' in (LPE.get_validator_error_kind res <> LPE.get_validator_error_kind LPE.validator_error_action_failed ==> None? (LP.parse p s)) /\ Seq.length s' <= Seq.length s /\ s' `Seq.equal` Seq.slice s (Seq.length s - Seq.length s') (Seq.length s) end ) let validate_with_action_t p inv l allow_reading = validate_with_action_t' p inv l allow_reading let validate_eta v = fun ctxt error_handler_fn sl pos -> v ctxt error_handler_fn sl pos let act_with_comment s res a = fun ctxt sl pos posf -> LPL.comment s; a ctxt sl pos posf let leaf_reader #nz #k (#t: Type) (p: parser k t) : Tot Type = (# [FStar.Tactics.Typeclasses.tcresolve ()] _extra_t : I.extra_t #input_buffer_t ) -> (sl: input_buffer_t) -> (pos: LPE.pos_t) -> Stack t (requires (fun h -> valid p h sl /\ U64.v pos == Seq.length (I.get_read sl h) )) (ensures (fun h res h' -> let s = I.get_remaining sl h in I.live sl h' /\ modifies (I.perm_footprint sl) h h' /\ begin match LP.parse p s with | None -> False | Some (y, len) -> res == y /\ I.get_remaining sl h' == Seq.slice s len (Seq.length s) end )) #push-options "--z3rlimit 32" inline_for_extraction noextract let validate_with_success_action' (name: string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (v1:validate_with_action_t p1 inv1 l1 false) (#inv2:_) (#l2:eloc) #b (a:action p1 inv2 l2 b bool) : validate_with_action_t p1 (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ name))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then [@(rename_let ("action_success_" ^ name))] let b = a ctxt input pos0 pos1 in let h2 = HST.get () in modifies_address_liveness_insensitive_unused_in h1 h2; if not b then LPE.set_validator_error_pos LPE.validator_error_action_failed pos1 else pos1 else pos1 inline_for_extraction noextract let validate_drop_true (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) (v: validate_with_action_t' p inv l true) : Tot (validate_with_action_t' p inv l false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let res = v ctxt error_handler_fn input input_length pos in I.skip_if_success input pos res; res inline_for_extraction noextract let validate_drop (#k:LP.parser_kind) (#t:Type) (#p:LP.parser k t) (#inv:slice_inv) (#l:eloc) #allow_reading (v: validate_with_action_t' p inv l allow_reading) : Tot (validate_with_action_t' p inv l false) = if allow_reading then validate_drop_true v else v let validate_with_success_action name v1 a = validate_with_success_action' name (validate_drop v1) a inline_for_extraction noextract let validate_with_error_handler (typename:string) (fieldname:string) #nz #wk (#k1:parser_kind nz wk) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar:_) (v1:validate_with_action_t p1 inv1 l1 ar) : validate_with_action_t p1 inv1 l1 ar = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos0 = start_position in let h0 = HST.get () in [@(rename_let ("positionAfter" ^ typename))] let pos1 = v1 ctxt error_handler_fn input input_length pos0 in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_success pos1 then pos1 else ( error_handler_fn typename fieldname (LPE.error_reason_of_result pos1) (LPE.get_validator_error_kind pos1) ctxt input pos0; pos1 ) inline_for_extraction noextract let validate_ret : validate_with_action_t (parse_ret ()) true_inv eloc_none true = fun ctxt error_handler_fn input input_length start_position -> start_position #push-options "--z3rlimit 32" module LPC = LowParse.Spec.Combinators inline_for_extraction noextract let validate_pair (name1: string) #nz1 (#k1:parser_kind nz1 WeakKindStrongPrefix) #t1 (#p1:parser k1 t1) (#inv1:_) (#l1:eloc) (#ar1:_) (v1:validate_with_action_t p1 inv1 l1 ar1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) #t2 (#p2:parser k2 t2) (#inv2:_) (#l2:eloc) (#ar2:_) (v2:validate_with_action_t p2 inv2 l2 ar2) : validate_with_action_t (p1 `parse_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.nondep_then_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = validate_drop v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get () in modifies_address_liveness_insensitive_unused_in h h1; if LPE.is_error pos1 then pos1 else validate_drop v2 ctxt error_handler_fn input input_length pos1 inline_for_extraction noextract let validate_dep_pair (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `parse_dep_pair` p2) (conj_inv inv1 inv2) (l1 `eloc_union` l2) false) = fun ctxt error_handler_fn input input_length start_position -> [@inline_let] let pos = start_position in let h = HST.get () in LPC.parse_dtuple2_eq p1 p2 (I.get_remaining input h); [@(rename_let ("positionAfter" ^ name1))] let pos1 = v1 ctxt error_handler_fn input input_length pos in let h1 = HST.get() in if LPE.is_error pos1 then begin pos1 end else [@(rename_let ("" ^ name1))] let x = r1 input pos in let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h h15 in validate_drop (v2 x) ctxt error_handler_fn input input_length pos1 #pop-options #push-options "--z3rlimit 64" #restart-solver inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action' (name1: string) (#nz1: _) (#k1:parser_kind nz1 _) (#t1: _) (#p1:parser k1 t1) (#inv1: _) (#l1: _) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f) -> parser k2 (t2 x)) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@(rename_let ("positionAfter" ^ name1))] let res = v1 ctxt error_handler_fn input input_length startPosition in let h1 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h1; if LPE.is_error res then begin res end else begin assert (I.get_remaining input h1 == I.get_remaining input h0); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok res in let h2 = HST.get() in if LPE.is_error res1 then res1 else begin modifies_address_liveness_insensitive_unused_in h1 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed res1 //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action_total_zero_parser' (name1: string) (#nz1: _) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1: _) (#p1:parser k1 t1) (r1: leaf_reader p1) (inv1: _) (l1: _) (f: t1 -> bool) (#inv1': _) (#l1': _) (#b: _) (a:t1 -> action p1 inv1' l1' b bool) (#nz2: _) (#wk2: _) (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) (#inv2: _) (#l2: _) (#ar2: _) (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Pure (validate_with_action_t ((p1 `LPC.parse_filter` f) `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) (requires ( let open LP in k1.parser_kind_high == Some 0 /\ k1.parser_kind_metadata == Some ParserKindMetadataTotal )) (ensures (fun _ -> True)) = fun ctxt error_handler_fn input input_length startPosition -> let h0 = HST.get () in LPC.parse_dtuple2_eq' #_ #_ (p1 `LPC.parse_filter` f) #_ #t2 p2 (I.get_remaining input h0); LPC.parse_filter_eq p1 f (I.get_remaining input h0); [@inline_let] let _ = LP.parser_kind_prop_equiv k1 p1 in begin LowStar.Comment.comment ("Validating field " ^ name1); [@(rename_let ("" ^ name1))] let field_value = r1 input startPosition in [@(rename_let (name1 ^ "ConstraintIsOk"))] let ok = f field_value in [@(rename_let ("positionAfter" ^ name1))] let res1 = LPE.check_constraint_ok ok startPosition in if LPE.is_error res1 then res1 else let h2 = HST.get() in modifies_address_liveness_insensitive_unused_in h0 h2; if not (a field_value ctxt input startPosition res1) then LPE.set_validator_error_pos LPE.validator_error_action_failed startPosition //action failed else begin let h15 = HST.get () in let _ = modifies_address_liveness_insensitive_unused_in h0 h15 in validate_drop (v2 field_value) ctxt error_handler_fn input input_length res1 end end inline_for_extraction noextract let validate_dep_pair_with_refinement_and_action (p1_is_constant_size_without_actions: bool) (name1: string) #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (f: t1 -> bool) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:refine _ f -> Type) (#p2:(x:refine _ f -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:refine _ f -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t ((p1 `parse_filter` f) `parse_dep_pair` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false) = if p1_is_constant_size_without_actions `LP.bool_and` (k1.LP.parser_kind_high = Some 0) `LP.bool_and` (k1.LP.parser_kind_metadata = Some LP.ParserKindMetadataTotal) then validate_dep_pair_with_refinement_and_action_total_zero_parser' name1 r1 inv1 l1 f a v2 else validate_dep_pair_with_refinement_and_action' name1 v1 r1 f a v2 inline_for_extraction noextract let validate_dep_pair_with_action #nz1 (#k1:parser_kind nz1 _) #t1 (#p1:parser k1 t1) #inv1 #l1 (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) #inv1' #l1' #b (a:t1 -> action p1 inv1' l1' b bool) #nz2 #wk2 (#k2:parser_kind nz2 wk2) (#t2:t1 -> Type) (#p2:(x:t1 -> parser k2 (t2 x))) #inv2 #l2 #ar2 (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 ar2)) : Tot (validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2))
false
false
EverParse3d.Actions.Base.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "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": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 64, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val validate_dep_pair_with_action (#nz1:_) (#k1:parser_kind nz1 WeakKindStrongPrefix) (#t1:Type) (#[@@@erasable] p1:parser k1 t1) (#[@@@erasable] inv1:slice_inv) (#[@@@erasable] l1:eloc) (v1:validate_with_action_t p1 inv1 l1 true) (r1: leaf_reader p1) (#[@@@erasable] inv1':slice_inv) (#[@@@erasable] l1':eloc) (#b:_) (a:t1 -> action p1 inv1' l1' b bool) (#nz2:_) (#wk2: _) (#k2:parser_kind nz2 wk2) (#[@@@erasable] t2:t1 -> Type) (#[@@@erasable] p2:(x:t1 -> parser k2 (t2 x))) (#[@@@erasable] inv2:slice_inv) (#[@@@erasable] l2:eloc) (#allow_reading2:_) (v2:(x:t1 -> validate_with_action_t (p2 x) inv2 l2 allow_reading2)) : validate_with_action_t (p1 `(parse_dep_pair #nz1)` p2) (conj_inv inv1 (conj_inv inv1' inv2)) (l1 `eloc_union` (l1' `eloc_union` l2)) false
[]
EverParse3d.Actions.Base.validate_dep_pair_with_action
{ "file_name": "src/3d/prelude/EverParse3d.Actions.Base.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
v1: EverParse3d.Actions.Base.validate_with_action_t p1 inv1 l1 true -> r1: EverParse3d.Actions.Base.leaf_reader p1 -> a: (_: t1 -> EverParse3d.Actions.Base.action p1 inv1' l1' b Prims.bool) -> v2: (x: t1 -> EverParse3d.Actions.Base.validate_with_action_t (p2 x) inv2 l2 allow_reading2) -> EverParse3d.Actions.Base.validate_with_action_t (EverParse3d.Prelude.parse_dep_pair p1 p2) (EverParse3d.Actions.Base.conj_inv inv1 (EverParse3d.Actions.Base.conj_inv inv1' inv2)) (EverParse3d.Actions.Base.eloc_union l1 (EverParse3d.Actions.Base.eloc_union l1' l2)) false
{ "end_col": 9, "end_line": 535, "start_col": 4, "start_line": 514 }
Prims.Tot
val proj_g_pow2_64:S.proj_point
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ)
val proj_g_pow2_64:S.proj_point let proj_g_pow2_64:S.proj_point =
false
null
false
[@@ inline_let ]let rX:S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@@ inline_let ]let rY:S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@@ inline_let ]let rZ:S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ)
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.Mktuple3", "Prims.nat", "Spec.P256.PointOps.felem" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract
false
true
Hacl.P256.PrecompTable.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 proj_g_pow2_64:S.proj_point
[]
Hacl.P256.PrecompTable.proj_g_pow2_64
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.P256.PointOps.proj_point
{ "end_col": 14, "end_line": 44, "start_col": 2, "start_line": 38 }
Prims.Tot
val proj_point_to_list: p:S.proj_point -> x:list uint64{FStar.List.Tot.length x = 12 /\ mk_to_p256_comm_monoid.BE.linv (Seq.seq_of_list x)}
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p
val proj_point_to_list: p:S.proj_point -> x:list uint64{FStar.List.Tot.length x = 12 /\ mk_to_p256_comm_monoid.BE.linv (Seq.seq_of_list x)} let proj_point_to_list p =
false
null
false
SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "Spec.P256.PointOps.proj_point", "Hacl.Spec.P256.PrecompTable.proj_point_to_list", "Prims.unit", "Hacl.Spec.P256.PrecompTable.proj_point_to_list_lemma", "Prims.list", "Lib.IntTypes.uint64", "Prims.l_and", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv", "Lib.IntTypes.U64", "FStar.UInt32.uint_to_t", "Hacl.Impl.P256.Group.mk_to_p256_comm_monoid", "FStar.Seq.Properties.seq_of_list" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
false
false
Hacl.P256.PrecompTable.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 proj_point_to_list: p:S.proj_point -> x:list uint64{FStar.List.Tot.length x = 12 /\ mk_to_p256_comm_monoid.BE.linv (Seq.seq_of_list x)}
[]
Hacl.P256.PrecompTable.proj_point_to_list
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Spec.P256.PointOps.proj_point -> x: Prims.list Lib.IntTypes.uint64 { FStar.List.Tot.Base.length x = 12 /\ Mkto_comm_monoid?.linv Hacl.Impl.P256.Group.mk_to_p256_comm_monoid (FStar.Seq.Properties.seq_of_list x) }
{ "end_col": 27, "end_line": 29, "start_col": 2, "start_line": 28 }
FStar.Pervasives.Lemma
val lemma_refl: x:S.proj_point -> Lemma (S.mk_p256_concrete_ops.SE.to.SE.refl x == mk_to_p256_comm_monoid.BE.refl (Seq.seq_of_list (proj_point_to_list x)))
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_refl x = SPTK.proj_point_to_list_lemma x
val lemma_refl: x:S.proj_point -> Lemma (S.mk_p256_concrete_ops.SE.to.SE.refl x == mk_to_p256_comm_monoid.BE.refl (Seq.seq_of_list (proj_point_to_list x))) let lemma_refl x =
false
null
true
SPTK.proj_point_to_list_lemma x
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Spec.P256.PointOps.proj_point", "Hacl.Spec.P256.PrecompTable.proj_point_to_list_lemma", "Prims.unit" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p
false
false
Hacl.P256.PrecompTable.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 lemma_refl: x:S.proj_point -> Lemma (S.mk_p256_concrete_ops.SE.to.SE.refl x == mk_to_p256_comm_monoid.BE.refl (Seq.seq_of_list (proj_point_to_list x)))
[]
Hacl.P256.PrecompTable.lemma_refl
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Spec.P256.PointOps.proj_point -> FStar.Pervasives.Lemma (ensures Mkto_comm_monoid?.refl (Mkconcrete_ops?.to Spec.P256.mk_p256_concrete_ops) x == Mkto_comm_monoid?.refl Hacl.Impl.P256.Group.mk_to_p256_comm_monoid (FStar.Seq.Properties.seq_of_list (Hacl.P256.PrecompTable.proj_point_to_list x)))
{ "end_col": 33, "end_line": 32, "start_col": 2, "start_line": 32 }
Prims.Tot
val proj_g_pow2_128:S.proj_point
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ)
val proj_g_pow2_128:S.proj_point let proj_g_pow2_128:S.proj_point =
false
null
false
[@@ inline_let ]let rX:S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@@ inline_let ]let rY:S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@@ inline_let ]let rZ:S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ)
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.Mktuple3", "Prims.nat", "Spec.P256.PointOps.felem" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract
false
true
Hacl.P256.PrecompTable.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 proj_g_pow2_128:S.proj_point
[]
Hacl.P256.PrecompTable.proj_g_pow2_128
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.P256.PointOps.proj_point
{ "end_col": 14, "end_line": 67, "start_col": 2, "start_line": 61 }
FStar.Pervasives.Lemma
val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () =
false
null
true
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX:S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY:S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ:S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Prims.unit", "Prims.nat", "FStar.Pervasives.assert_norm", "Prims.l_and", "Prims.eq2", "Spec.P256.PointOps.felem", "FStar.Pervasives.normalize_term_spec", "Spec.P256.PointOps.proj_point", "Hacl.Spec.PrecompBaseTable256.exp_pow2_rec", "Spec.P256.mk_p256_concrete_ops", "Spec.P256.PointOps.base_point", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.normalize_term", "Hacl.Spec.PrecompBaseTable256.exp_pow2_rec_is_exp_pow2" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64)
false
false
Hacl.P256.PrecompTable.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 lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64)
[]
Hacl.P256.PrecompTable.lemma_proj_g_pow2_64_eval
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Spec.Exponentiation.exp_pow2 Spec.P256.mk_p256_concrete_ops Spec.P256.PointOps.base_point 64 == Hacl.P256.PrecompTable.proj_g_pow2_64)
{ "end_col": 48, "end_line": 56, "start_col": 2, "start_line": 50 }
Prims.Tot
val proj_g_pow2_192:S.proj_point
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ)
val proj_g_pow2_192:S.proj_point let proj_g_pow2_192:S.proj_point =
false
null
false
[@@ inline_let ]let rX:S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@@ inline_let ]let rY:S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@@ inline_let ]let rZ:S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ)
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.Mktuple3", "Prims.nat", "Spec.P256.PointOps.felem" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract
false
true
Hacl.P256.PrecompTable.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 proj_g_pow2_192:S.proj_point
[]
Hacl.P256.PrecompTable.proj_g_pow2_192
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.P256.PointOps.proj_point
{ "end_col": 14, "end_line": 90, "start_col": 2, "start_line": 84 }
Prims.Tot
val proj_g_pow2_64_list:SPTK.point_list
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64)
val proj_g_pow2_64_list:SPTK.point_list let proj_g_pow2_64_list:SPTK.point_list =
false
null
false
normalize_term (SPTK.proj_point_to_list proj_g_pow2_64)
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Pervasives.normalize_term", "Hacl.Spec.P256.PrecompTable.point_list", "Hacl.Spec.P256.PrecompTable.proj_point_to_list", "Hacl.P256.PrecompTable.proj_g_pow2_64" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract
false
true
Hacl.P256.PrecompTable.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 proj_g_pow2_64_list:SPTK.point_list
[]
Hacl.P256.PrecompTable.proj_g_pow2_64_list
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Spec.P256.PrecompTable.point_list
{ "end_col": 57, "end_line": 117, "start_col": 2, "start_line": 117 }
FStar.Pervasives.Lemma
val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point
val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () =
false
null
true
lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Prims.unit", "Hacl.Spec.PrecompBaseTable256.a_pow2_192_lemma", "Spec.P256.PointOps.proj_point", "Spec.P256.mk_p256_concrete_ops", "Spec.P256.PointOps.base_point", "Hacl.P256.PrecompTable.lemma_proj_g_pow2_64_eval", "Hacl.P256.PrecompTable.lemma_proj_g_pow2_128_eval", "Hacl.P256.PrecompTable.lemma_proj_g_pow2_192_eval" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff)
false
false
Hacl.P256.PrecompTable.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 proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff)
[]
Hacl.P256.PrecompTable.proj_g_pow2_192_lemma
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Spec.P256.PointOps.to_aff_point Hacl.P256.PrecompTable.proj_g_pow2_192 == Hacl.P256.PrecompTable.pow_point (Prims.pow2 192) Hacl.P256.PrecompTable.g_aff)
{ "end_col": 61, "end_line": 165, "start_col": 2, "start_line": 162 }
Prims.Tot
val proj_g_pow2_192_list:SPTK.point_list
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192)
val proj_g_pow2_192_list:SPTK.point_list let proj_g_pow2_192_list:SPTK.point_list =
false
null
false
normalize_term (SPTK.proj_point_to_list proj_g_pow2_192)
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Pervasives.normalize_term", "Hacl.Spec.P256.PrecompTable.point_list", "Hacl.Spec.P256.PrecompTable.proj_point_to_list", "Hacl.P256.PrecompTable.proj_g_pow2_192" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract
false
true
Hacl.P256.PrecompTable.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 proj_g_pow2_192_list:SPTK.point_list
[]
Hacl.P256.PrecompTable.proj_g_pow2_192_list
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Spec.P256.PrecompTable.point_list
{ "end_col": 58, "end_line": 125, "start_col": 2, "start_line": 125 }
FStar.Pervasives.Lemma
val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point
val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () =
false
null
true
lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Prims.unit", "Hacl.Spec.PrecompBaseTable256.a_pow2_128_lemma", "Spec.P256.PointOps.proj_point", "Spec.P256.mk_p256_concrete_ops", "Spec.P256.PointOps.base_point", "Hacl.P256.PrecompTable.lemma_proj_g_pow2_64_eval", "Hacl.P256.PrecompTable.lemma_proj_g_pow2_128_eval" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff)
false
false
Hacl.P256.PrecompTable.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 proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff)
[]
Hacl.P256.PrecompTable.proj_g_pow2_128_lemma
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Spec.P256.PointOps.to_aff_point Hacl.P256.PrecompTable.proj_g_pow2_128 == Hacl.P256.PrecompTable.pow_point (Prims.pow2 128) Hacl.P256.PrecompTable.g_aff)
{ "end_col": 61, "end_line": 155, "start_col": 2, "start_line": 153 }
FStar.Pervasives.Lemma
val proj_g_pow2_192_lseq_lemma: unit -> Lemma (point_inv_seq proj_g_pow2_192_lseq /\ S.to_aff_point (from_mont_point (as_point_nat_seq proj_g_pow2_192_lseq)) == g_pow2_192)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192
val proj_g_pow2_192_lseq_lemma: unit -> Lemma (point_inv_seq proj_g_pow2_192_lseq /\ S.to_aff_point (from_mont_point (as_point_nat_seq proj_g_pow2_192_lseq)) == g_pow2_192) let proj_g_pow2_192_lseq_lemma () =
false
null
true
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Prims.unit", "Hacl.Spec.P256.PrecompTable.proj_point_to_list_lemma", "Hacl.P256.PrecompTable.proj_g_pow2_192", "Hacl.P256.PrecompTable.proj_g_pow2_192_lemma", "FStar.Pervasives.normalize_term_spec", "Hacl.Spec.P256.PrecompTable.point_list", "Hacl.Spec.P256.PrecompTable.proj_point_to_list" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128
false
false
Hacl.P256.PrecompTable.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 proj_g_pow2_192_lseq_lemma: unit -> Lemma (point_inv_seq proj_g_pow2_192_lseq /\ S.to_aff_point (from_mont_point (as_point_nat_seq proj_g_pow2_192_lseq)) == g_pow2_192)
[]
Hacl.P256.PrecompTable.proj_g_pow2_192_lseq_lemma
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Hacl.Impl.P256.Point.point_inv_seq Hacl.P256.PrecompTable.proj_g_pow2_192_lseq /\ Spec.P256.PointOps.to_aff_point (Hacl.Impl.P256.Point.from_mont_point (Hacl.Impl.P256.Point.as_point_nat_seq Hacl.P256.PrecompTable.proj_g_pow2_192_lseq)) == Hacl.P256.PrecompTable.g_pow2_192)
{ "end_col": 47, "end_line": 183, "start_col": 2, "start_line": 181 }
FStar.Pervasives.Lemma
val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () =
false
null
true
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX:S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY:S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ:S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Prims.unit", "Prims.nat", "FStar.Pervasives.assert_norm", "Prims.l_and", "Prims.eq2", "Spec.P256.PointOps.felem", "FStar.Pervasives.normalize_term_spec", "Spec.P256.PointOps.proj_point", "Hacl.Spec.PrecompBaseTable256.exp_pow2_rec", "Spec.P256.mk_p256_concrete_ops", "Hacl.P256.PrecompTable.proj_g_pow2_64", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.normalize_term", "Hacl.Spec.PrecompBaseTable256.exp_pow2_rec_is_exp_pow2" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128)
false
false
Hacl.P256.PrecompTable.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 lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128)
[]
Hacl.P256.PrecompTable.lemma_proj_g_pow2_128_eval
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Spec.Exponentiation.exp_pow2 Spec.P256.mk_p256_concrete_ops Hacl.P256.PrecompTable.proj_g_pow2_64 64 == Hacl.P256.PrecompTable.proj_g_pow2_128)
{ "end_col": 48, "end_line": 79, "start_col": 2, "start_line": 73 }
FStar.HyperStack.ST.StackInline
val mk_proj_g_pow2_128: unit -> StackInline (lbuffer uint64 12ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_128_lseq)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list
val mk_proj_g_pow2_128: unit -> StackInline (lbuffer uint64 12ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_128_lseq) let mk_proj_g_pow2_128 () =
true
null
false
createL proj_g_pow2_128_list
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[]
[ "Prims.unit", "Lib.Buffer.createL", "Lib.IntTypes.uint64", "Hacl.P256.PrecompTable.proj_g_pow2_128_list", "Lib.Buffer.lbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list
false
false
Hacl.P256.PrecompTable.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_proj_g_pow2_128: unit -> StackInline (lbuffer uint64 12ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_128_lseq)
[]
Hacl.P256.PrecompTable.mk_proj_g_pow2_128
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.HyperStack.ST.StackInline (Lib.Buffer.lbuffer Lib.IntTypes.uint64 12ul)
{ "end_col": 30, "end_line": 190, "start_col": 2, "start_line": 190 }
FStar.Pervasives.Lemma
val proj_g_pow2_64_lseq_lemma: unit -> Lemma (point_inv_seq proj_g_pow2_64_lseq /\ S.to_aff_point (from_mont_point (as_point_nat_seq proj_g_pow2_64_lseq)) == g_pow2_64)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64
val proj_g_pow2_64_lseq_lemma: unit -> Lemma (point_inv_seq proj_g_pow2_64_lseq /\ S.to_aff_point (from_mont_point (as_point_nat_seq proj_g_pow2_64_lseq)) == g_pow2_64) let proj_g_pow2_64_lseq_lemma () =
false
null
true
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Prims.unit", "Hacl.Spec.P256.PrecompTable.proj_point_to_list_lemma", "Hacl.P256.PrecompTable.proj_g_pow2_64", "Hacl.P256.PrecompTable.proj_g_pow2_64_lemma", "FStar.Pervasives.normalize_term_spec", "Hacl.Spec.P256.PrecompTable.point_list", "Hacl.Spec.P256.PrecompTable.proj_point_to_list" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point
false
false
Hacl.P256.PrecompTable.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 proj_g_pow2_64_lseq_lemma: unit -> Lemma (point_inv_seq proj_g_pow2_64_lseq /\ S.to_aff_point (from_mont_point (as_point_nat_seq proj_g_pow2_64_lseq)) == g_pow2_64)
[]
Hacl.P256.PrecompTable.proj_g_pow2_64_lseq_lemma
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Hacl.Impl.P256.Point.point_inv_seq Hacl.P256.PrecompTable.proj_g_pow2_64_lseq /\ Spec.P256.PointOps.to_aff_point (Hacl.Impl.P256.Point.from_mont_point (Hacl.Impl.P256.Point.as_point_nat_seq Hacl.P256.PrecompTable.proj_g_pow2_64_lseq)) == Hacl.P256.PrecompTable.g_pow2_64)
{ "end_col": 46, "end_line": 171, "start_col": 2, "start_line": 169 }
Prims.Tot
val proj_g_pow2_128_lseq : LSeq.lseq uint64 12
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list
val proj_g_pow2_128_lseq : LSeq.lseq uint64 12 let proj_g_pow2_128_lseq:LSeq.lseq uint64 12 =
false
null
false
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Seq.Properties.seq_of_list", "Lib.IntTypes.uint64", "Hacl.P256.PrecompTable.proj_g_pow2_128_list", "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Hacl.Spec.P256.PrecompTable.point_list", "Hacl.Spec.P256.PrecompTable.proj_point_to_list", "Hacl.P256.PrecompTable.proj_g_pow2_128", "Lib.Sequence.lseq" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list
false
false
Hacl.P256.PrecompTable.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 proj_g_pow2_128_lseq : LSeq.lseq uint64 12
[]
Hacl.P256.PrecompTable.proj_g_pow2_128_lseq
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Sequence.lseq Lib.IntTypes.uint64 12
{ "end_col": 38, "end_line": 134, "start_col": 2, "start_line": 133 }
FStar.Pervasives.Lemma
val proj_g_pow2_128_lseq_lemma: unit -> Lemma (point_inv_seq proj_g_pow2_128_lseq /\ S.to_aff_point (from_mont_point (as_point_nat_seq proj_g_pow2_128_lseq)) == g_pow2_128)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128
val proj_g_pow2_128_lseq_lemma: unit -> Lemma (point_inv_seq proj_g_pow2_128_lseq /\ S.to_aff_point (from_mont_point (as_point_nat_seq proj_g_pow2_128_lseq)) == g_pow2_128) let proj_g_pow2_128_lseq_lemma () =
false
null
true
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Prims.unit", "Hacl.Spec.P256.PrecompTable.proj_point_to_list_lemma", "Hacl.P256.PrecompTable.proj_g_pow2_128", "Hacl.P256.PrecompTable.proj_g_pow2_128_lemma", "FStar.Pervasives.normalize_term_spec", "Hacl.Spec.P256.PrecompTable.point_list", "Hacl.Spec.P256.PrecompTable.proj_point_to_list" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64
false
false
Hacl.P256.PrecompTable.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 proj_g_pow2_128_lseq_lemma: unit -> Lemma (point_inv_seq proj_g_pow2_128_lseq /\ S.to_aff_point (from_mont_point (as_point_nat_seq proj_g_pow2_128_lseq)) == g_pow2_128)
[]
Hacl.P256.PrecompTable.proj_g_pow2_128_lseq_lemma
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Hacl.Impl.P256.Point.point_inv_seq Hacl.P256.PrecompTable.proj_g_pow2_128_lseq /\ Spec.P256.PointOps.to_aff_point (Hacl.Impl.P256.Point.from_mont_point (Hacl.Impl.P256.Point.as_point_nat_seq Hacl.P256.PrecompTable.proj_g_pow2_128_lseq)) == Hacl.P256.PrecompTable.g_pow2_128)
{ "end_col": 47, "end_line": 177, "start_col": 2, "start_line": 175 }
Prims.Tot
val precomp_basepoint_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192}
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15)
val precomp_basepoint_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192} let precomp_basepoint_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192} =
false
null
false
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15)
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Pervasives.normalize_term", "Prims.list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.P256.PointOps.proj_point", "FStar.UInt32.uint_to_t", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Spec.P256.PointOps.base_point" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract
false
false
Hacl.P256.PrecompTable.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 precomp_basepoint_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192}
[]
Hacl.P256.PrecompTable.precomp_basepoint_table_list_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC) {FStar.List.Tot.Base.length x = 192}
{ "end_col": 89, "end_line": 201, "start_col": 2, "start_line": 201 }
FStar.Pervasives.Lemma
val precomp_basepoint_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_aff 16 precomp_basepoint_table_lseq_w4 i)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4
val precomp_basepoint_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_aff 16 precomp_basepoint_table_lseq_w4 i) let precomp_basepoint_table_lemma_w4 () =
false
null
true
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Prims.unit", "Hacl.Spec.PrecompBaseTable.precomp_base_table_lemma", "Spec.P256.PointOps.proj_point", "Lib.IntTypes.U64", "FStar.UInt32.uint_to_t", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Spec.P256.PointOps.base_point", "Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w4", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4
false
false
Hacl.P256.PrecompTable.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 precomp_basepoint_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_aff 16 precomp_basepoint_table_lseq_w4 i)
[]
Hacl.P256.PrecompTable.precomp_basepoint_table_lemma_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (i: Prims.nat{i < 16}). Hacl.P256.PrecompTable.precomp_table_acc_inv Hacl.P256.PrecompTable.g_aff 16 Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w4 i)
{ "end_col": 105, "end_line": 209, "start_col": 2, "start_line": 208 }
Prims.Tot
val proj_g_pow2_128_list:SPTK.point_list
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128)
val proj_g_pow2_128_list:SPTK.point_list let proj_g_pow2_128_list:SPTK.point_list =
false
null
false
normalize_term (SPTK.proj_point_to_list proj_g_pow2_128)
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Pervasives.normalize_term", "Hacl.Spec.P256.PrecompTable.point_list", "Hacl.Spec.P256.PrecompTable.proj_point_to_list", "Hacl.P256.PrecompTable.proj_g_pow2_128" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract
false
true
Hacl.P256.PrecompTable.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 proj_g_pow2_128_list:SPTK.point_list
[]
Hacl.P256.PrecompTable.proj_g_pow2_128_list
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Spec.P256.PrecompTable.point_list
{ "end_col": 58, "end_line": 121, "start_col": 2, "start_line": 121 }
Prims.Tot
val precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4
val precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 let precomp_basepoint_table_lseq_w4:LSeq.lseq uint64 192 =
false
null
false
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Seq.Properties.seq_of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.P256.PrecompTable.precomp_basepoint_table_list_w4", "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.uint_to_t", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.P256.PointOps.proj_point", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Spec.P256.PointOps.base_point", "Lib.Sequence.lseq", "Lib.IntTypes.uint64" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15)
false
false
Hacl.P256.PrecompTable.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 precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192
[]
Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Sequence.lseq Lib.IntTypes.uint64 192
{ "end_col": 49, "end_line": 205, "start_col": 2, "start_line": 204 }
Prims.Tot
val precomp_g_pow2_64_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192}
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15)
val precomp_g_pow2_64_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192} let precomp_g_pow2_64_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192} =
false
null
false
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15)
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Pervasives.normalize_term", "Prims.list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.P256.PointOps.proj_point", "FStar.UInt32.uint_to_t", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Hacl.P256.PrecompTable.proj_g_pow2_64" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract
false
false
Hacl.P256.PrecompTable.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 precomp_g_pow2_64_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192}
[]
Hacl.P256.PrecompTable.precomp_g_pow2_64_table_list_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC) {FStar.List.Tot.Base.length x = 192}
{ "end_col": 91, "end_line": 220, "start_col": 2, "start_line": 220 }
FStar.HyperStack.ST.StackInline
val mk_proj_g_pow2_64: unit -> StackInline (lbuffer uint64 12ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_64_lseq)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list
val mk_proj_g_pow2_64: unit -> StackInline (lbuffer uint64 12ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_64_lseq) let mk_proj_g_pow2_64 () =
true
null
false
createL proj_g_pow2_64_list
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[]
[ "Prims.unit", "Lib.Buffer.createL", "Lib.IntTypes.uint64", "Hacl.P256.PrecompTable.proj_g_pow2_64_list", "Lib.Buffer.lbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192
false
false
Hacl.P256.PrecompTable.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_proj_g_pow2_64: unit -> StackInline (lbuffer uint64 12ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_64_lseq)
[]
Hacl.P256.PrecompTable.mk_proj_g_pow2_64
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.HyperStack.ST.StackInline (Lib.Buffer.lbuffer Lib.IntTypes.uint64 12ul)
{ "end_col": 29, "end_line": 187, "start_col": 2, "start_line": 187 }
Prims.Tot
val proj_g_pow2_192_lseq : LSeq.lseq uint64 12
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list
val proj_g_pow2_192_lseq : LSeq.lseq uint64 12 let proj_g_pow2_192_lseq:LSeq.lseq uint64 12 =
false
null
false
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Seq.Properties.seq_of_list", "Lib.IntTypes.uint64", "Hacl.P256.PrecompTable.proj_g_pow2_192_list", "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Hacl.Spec.P256.PrecompTable.point_list", "Hacl.Spec.P256.PrecompTable.proj_point_to_list", "Hacl.P256.PrecompTable.proj_g_pow2_192", "Lib.Sequence.lseq" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list
false
false
Hacl.P256.PrecompTable.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 proj_g_pow2_192_lseq : LSeq.lseq uint64 12
[]
Hacl.P256.PrecompTable.proj_g_pow2_192_lseq
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Sequence.lseq Lib.IntTypes.uint64 12
{ "end_col": 38, "end_line": 138, "start_col": 2, "start_line": 137 }
FStar.Pervasives.Lemma
val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point
val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () =
false
null
true
lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Prims.unit", "Hacl.Spec.PrecompBaseTable256.a_pow2_64_lemma", "Spec.P256.PointOps.proj_point", "Spec.P256.mk_p256_concrete_ops", "Spec.P256.PointOps.base_point", "Hacl.P256.PrecompTable.lemma_proj_g_pow2_64_eval" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff)
false
false
Hacl.P256.PrecompTable.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 proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff)
[]
Hacl.P256.PrecompTable.proj_g_pow2_64_lemma
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Spec.P256.PointOps.to_aff_point Hacl.P256.PrecompTable.proj_g_pow2_64 == Hacl.P256.PrecompTable.pow_point (Prims.pow2 64) Hacl.P256.PrecompTable.g_aff)
{ "end_col": 60, "end_line": 146, "start_col": 2, "start_line": 145 }
Prims.Tot
val proj_g_pow2_64_lseq : LSeq.lseq uint64 12
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list
val proj_g_pow2_64_lseq : LSeq.lseq uint64 12 let proj_g_pow2_64_lseq:LSeq.lseq uint64 12 =
false
null
false
normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Seq.Properties.seq_of_list", "Lib.IntTypes.uint64", "Hacl.P256.PrecompTable.proj_g_pow2_64_list", "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Hacl.Spec.P256.PrecompTable.point_list", "Hacl.Spec.P256.PrecompTable.proj_point_to_list", "Hacl.P256.PrecompTable.proj_g_pow2_64", "Lib.Sequence.lseq" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192)
false
false
Hacl.P256.PrecompTable.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 proj_g_pow2_64_lseq : LSeq.lseq uint64 12
[]
Hacl.P256.PrecompTable.proj_g_pow2_64_lseq
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Sequence.lseq Lib.IntTypes.uint64 12
{ "end_col": 37, "end_line": 130, "start_col": 2, "start_line": 129 }
FStar.HyperStack.ST.StackInline
val mk_proj_g_pow2_192: unit -> StackInline (lbuffer uint64 12ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_192_lseq)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list
val mk_proj_g_pow2_192: unit -> StackInline (lbuffer uint64 12ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_192_lseq) let mk_proj_g_pow2_192 () =
true
null
false
createL proj_g_pow2_192_list
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[]
[ "Prims.unit", "Lib.Buffer.createL", "Lib.IntTypes.uint64", "Hacl.P256.PrecompTable.proj_g_pow2_192_list", "Lib.Buffer.lbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length", "FStar.UInt32.__uint_to_t" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list
false
false
Hacl.P256.PrecompTable.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_proj_g_pow2_192: unit -> StackInline (lbuffer uint64 12ul) (requires fun _ -> True) (ensures fun h0 b h1 -> live h1 b /\ stack_allocated b h0 h1 proj_g_pow2_192_lseq)
[]
Hacl.P256.PrecompTable.mk_proj_g_pow2_192
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.HyperStack.ST.StackInline (Lib.Buffer.lbuffer Lib.IntTypes.uint64 12ul)
{ "end_col": 30, "end_line": 193, "start_col": 2, "start_line": 193 }
FStar.Pervasives.Lemma
val precomp_g_pow2_64_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4 i)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma ()
val precomp_g_pow2_64_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4 i) let precomp_g_pow2_64_table_lemma_w4 () =
false
null
true
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma ()
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Prims.unit", "Hacl.P256.PrecompTable.proj_g_pow2_64_lemma", "Hacl.Spec.PrecompBaseTable.precomp_base_table_lemma", "Spec.P256.PointOps.proj_point", "Lib.IntTypes.U64", "FStar.UInt32.uint_to_t", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Hacl.P256.PrecompTable.proj_g_pow2_64", "Hacl.P256.PrecompTable.precomp_g_pow2_64_table_lseq_w4", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4
false
false
Hacl.P256.PrecompTable.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 precomp_g_pow2_64_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4 i)
[]
Hacl.P256.PrecompTable.precomp_g_pow2_64_table_lemma_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (i: Prims.nat{i < 16}). Hacl.P256.PrecompTable.precomp_table_acc_inv Hacl.P256.PrecompTable.g_pow2_64 16 Hacl.P256.PrecompTable.precomp_g_pow2_64_table_lseq_w4 i)
{ "end_col": 25, "end_line": 230, "start_col": 2, "start_line": 227 }
FStar.Pervasives.Lemma
val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () =
false
null
true
SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX:S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY:S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ:S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ)
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Prims.unit", "Prims.nat", "FStar.Pervasives.assert_norm", "Prims.l_and", "Prims.eq2", "Spec.P256.PointOps.felem", "FStar.Pervasives.normalize_term_spec", "Spec.P256.PointOps.proj_point", "Hacl.Spec.PrecompBaseTable256.exp_pow2_rec", "Spec.P256.mk_p256_concrete_ops", "Hacl.P256.PrecompTable.proj_g_pow2_128", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.normalize_term", "Hacl.Spec.PrecompBaseTable256.exp_pow2_rec_is_exp_pow2" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192)
false
false
Hacl.P256.PrecompTable.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 lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192)
[]
Hacl.P256.PrecompTable.lemma_proj_g_pow2_192_eval
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Spec.Exponentiation.exp_pow2 Spec.P256.mk_p256_concrete_ops Hacl.P256.PrecompTable.proj_g_pow2_128 64 == Hacl.P256.PrecompTable.proj_g_pow2_192)
{ "end_col": 48, "end_line": 102, "start_col": 2, "start_line": 96 }
Prims.Tot
val precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4
val precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 let precomp_g_pow2_64_table_lseq_w4:LSeq.lseq uint64 192 =
false
null
false
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Seq.Properties.seq_of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.P256.PrecompTable.precomp_g_pow2_64_table_list_w4", "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.uint_to_t", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.P256.PointOps.proj_point", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Hacl.P256.PrecompTable.proj_g_pow2_64", "Lib.Sequence.lseq", "Lib.IntTypes.uint64" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15)
false
false
Hacl.P256.PrecompTable.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 precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192
[]
Hacl.P256.PrecompTable.precomp_g_pow2_64_table_lseq_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Sequence.lseq Lib.IntTypes.uint64 192
{ "end_col": 49, "end_line": 224, "start_col": 2, "start_line": 223 }
Prims.Tot
val precomp_g_pow2_128_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192}
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15)
val precomp_g_pow2_128_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192} let precomp_g_pow2_128_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192} =
false
null
false
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15)
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Pervasives.normalize_term", "Prims.list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.P256.PointOps.proj_point", "FStar.UInt32.uint_to_t", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Hacl.P256.PrecompTable.proj_g_pow2_128" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract
false
false
Hacl.P256.PrecompTable.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 precomp_g_pow2_128_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192}
[]
Hacl.P256.PrecompTable.precomp_g_pow2_128_table_list_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC) {FStar.List.Tot.Base.length x = 192}
{ "end_col": 92, "end_line": 241, "start_col": 2, "start_line": 241 }
Prims.Tot
val precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4
val precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 let precomp_g_pow2_128_table_lseq_w4:LSeq.lseq uint64 192 =
false
null
false
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Seq.Properties.seq_of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.P256.PrecompTable.precomp_g_pow2_128_table_list_w4", "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.uint_to_t", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.P256.PointOps.proj_point", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Hacl.P256.PrecompTable.proj_g_pow2_128", "Lib.Sequence.lseq", "Lib.IntTypes.uint64" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15)
false
false
Hacl.P256.PrecompTable.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 precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192
[]
Hacl.P256.PrecompTable.precomp_g_pow2_128_table_lseq_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Sequence.lseq Lib.IntTypes.uint64 192
{ "end_col": 50, "end_line": 245, "start_col": 2, "start_line": 244 }
Prims.Tot
val precomp_g_pow2_192_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192}
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15)
val precomp_g_pow2_192_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192} let precomp_g_pow2_192_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192} =
false
null
false
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15)
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Pervasives.normalize_term", "Prims.list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.P256.PointOps.proj_point", "FStar.UInt32.uint_to_t", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Hacl.P256.PrecompTable.proj_g_pow2_192" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4 let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma () let precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_128_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)] inline_for_extraction noextract
false
false
Hacl.P256.PrecompTable.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 precomp_g_pow2_192_table_list_w4:x: list uint64 {FStar.List.Tot.length x = 192}
[]
Hacl.P256.PrecompTable.precomp_g_pow2_192_table_list_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC) {FStar.List.Tot.Base.length x = 192}
{ "end_col": 92, "end_line": 262, "start_col": 2, "start_line": 262 }
FStar.Pervasives.Lemma
val precomp_g_pow2_192_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_192 16 precomp_g_pow2_192_table_lseq_w4 i)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_g_pow2_192_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_192 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_192_lemma ()
val precomp_g_pow2_192_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_192 16 precomp_g_pow2_192_table_lseq_w4 i) let precomp_g_pow2_192_table_lemma_w4 () =
false
null
true
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_192 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_192_lemma ()
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Prims.unit", "Hacl.P256.PrecompTable.proj_g_pow2_192_lemma", "Hacl.Spec.PrecompBaseTable.precomp_base_table_lemma", "Spec.P256.PointOps.proj_point", "Lib.IntTypes.U64", "FStar.UInt32.uint_to_t", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Hacl.P256.PrecompTable.proj_g_pow2_192", "Hacl.P256.PrecompTable.precomp_g_pow2_64_table_lseq_w4", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4 let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma () let precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_128_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)] inline_for_extraction noextract let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15) let precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); Seq.seq_of_list precomp_g_pow2_192_table_list_w4
false
false
Hacl.P256.PrecompTable.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 precomp_g_pow2_192_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_192 16 precomp_g_pow2_192_table_lseq_w4 i)
[]
Hacl.P256.PrecompTable.precomp_g_pow2_192_table_lemma_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (i: Prims.nat{i < 16}). Hacl.P256.PrecompTable.precomp_table_acc_inv Hacl.P256.PrecompTable.g_pow2_192 16 Hacl.P256.PrecompTable.precomp_g_pow2_192_table_lseq_w4 i)
{ "end_col": 26, "end_line": 272, "start_col": 2, "start_line": 269 }
Prims.Tot
val precomp_basepoint_table_list_w5:x: list uint64 {FStar.List.Tot.length x = 384}
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_basepoint_table_list_w5: x:list uint64{FStar.List.Tot.length x = 384} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31)
val precomp_basepoint_table_list_w5:x: list uint64 {FStar.List.Tot.length x = 384} let precomp_basepoint_table_list_w5:x: list uint64 {FStar.List.Tot.length x = 384} =
false
null
false
normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31)
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Pervasives.normalize_term", "Prims.list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.P256.PointOps.proj_point", "FStar.UInt32.uint_to_t", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Spec.P256.PointOps.base_point" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4 let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma () let precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_128_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)] inline_for_extraction noextract let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15) let precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); Seq.seq_of_list precomp_g_pow2_192_table_list_w4 let precomp_g_pow2_192_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_192 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_192_lemma () let precomp_g_pow2_192_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_192_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_192_table_list_w4 /// window size = 5; precomputed table = [[0]G, [1]G, ..., [31]G] inline_for_extraction noextract
false
false
Hacl.P256.PrecompTable.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 precomp_basepoint_table_list_w5:x: list uint64 {FStar.List.Tot.length x = 384}
[]
Hacl.P256.PrecompTable.precomp_basepoint_table_list_w5
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC) {FStar.List.Tot.Base.length x = 384}
{ "end_col": 89, "end_line": 283, "start_col": 2, "start_line": 283 }
FStar.Pervasives.Lemma
val precomp_g_pow2_128_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_128 16 precomp_g_pow2_128_table_lseq_w4 i)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma ()
val precomp_g_pow2_128_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_128 16 precomp_g_pow2_128_table_lseq_w4 i) let precomp_g_pow2_128_table_lemma_w4 () =
false
null
true
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma ()
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Prims.unit", "Hacl.P256.PrecompTable.proj_g_pow2_128_lemma", "Hacl.Spec.PrecompBaseTable.precomp_base_table_lemma", "Spec.P256.PointOps.proj_point", "Lib.IntTypes.U64", "FStar.UInt32.uint_to_t", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Hacl.P256.PrecompTable.proj_g_pow2_128", "Hacl.P256.PrecompTable.precomp_g_pow2_64_table_lseq_w4", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4
false
false
Hacl.P256.PrecompTable.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 precomp_g_pow2_128_table_lemma_w4: unit -> Lemma (forall (i:nat{i < 16}). precomp_table_acc_inv g_pow2_128 16 precomp_g_pow2_128_table_lseq_w4 i)
[]
Hacl.P256.PrecompTable.precomp_g_pow2_128_table_lemma_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (i: Prims.nat{i < 16}). Hacl.P256.PrecompTable.precomp_table_acc_inv Hacl.P256.PrecompTable.g_pow2_128 16 Hacl.P256.PrecompTable.precomp_g_pow2_128_table_lseq_w4 i)
{ "end_col": 26, "end_line": 251, "start_col": 2, "start_line": 248 }
Prims.Tot
val precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); Seq.seq_of_list precomp_g_pow2_192_table_list_w4
val precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 let precomp_g_pow2_192_table_lseq_w4:LSeq.lseq uint64 192 =
false
null
false
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); Seq.seq_of_list precomp_g_pow2_192_table_list_w4
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Seq.Properties.seq_of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.P256.PrecompTable.precomp_g_pow2_192_table_list_w4", "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.uint_to_t", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.P256.PointOps.proj_point", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Hacl.P256.PrecompTable.proj_g_pow2_192", "Lib.Sequence.lseq", "Lib.IntTypes.uint64" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4 let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma () let precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_128_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)] inline_for_extraction noextract let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15)
false
false
Hacl.P256.PrecompTable.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 precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192
[]
Hacl.P256.PrecompTable.precomp_g_pow2_192_table_lseq_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Sequence.lseq Lib.IntTypes.uint64 192
{ "end_col": 50, "end_line": 266, "start_col": 2, "start_line": 265 }
FStar.Pervasives.Lemma
val precomp_basepoint_table_lemma_w5: unit -> Lemma (forall (i:nat{i < 32}). precomp_table_acc_inv g_aff 32 precomp_basepoint_table_lseq_w5 i)
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_basepoint_table_lemma_w5 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 32 precomp_basepoint_table_lseq_w5
val precomp_basepoint_table_lemma_w5: unit -> Lemma (forall (i:nat{i < 32}). precomp_table_acc_inv g_aff 32 precomp_basepoint_table_lseq_w5 i) let precomp_basepoint_table_lemma_w5 () =
false
null
true
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 32 precomp_basepoint_table_lseq_w5
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "lemma" ]
[ "Prims.unit", "Hacl.Spec.PrecompBaseTable.precomp_base_table_lemma", "Spec.P256.PointOps.proj_point", "Lib.IntTypes.U64", "FStar.UInt32.uint_to_t", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Spec.P256.PointOps.base_point", "Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w5", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4 let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma () let precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_128_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)] inline_for_extraction noextract let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15) let precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); Seq.seq_of_list precomp_g_pow2_192_table_list_w4 let precomp_g_pow2_192_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_192 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_192_lemma () let precomp_g_pow2_192_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_192_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_192_table_list_w4 /// window size = 5; precomputed table = [[0]G, [1]G, ..., [31]G] inline_for_extraction noextract let precomp_basepoint_table_list_w5: x:list uint64{FStar.List.Tot.length x = 384} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31) let precomp_basepoint_table_lseq_w5 : LSeq.lseq uint64 384 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31); Seq.seq_of_list precomp_basepoint_table_list_w5
false
false
Hacl.P256.PrecompTable.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 precomp_basepoint_table_lemma_w5: unit -> Lemma (forall (i:nat{i < 32}). precomp_table_acc_inv g_aff 32 precomp_basepoint_table_lseq_w5 i)
[]
Hacl.P256.PrecompTable.precomp_basepoint_table_lemma_w5
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures forall (i: Prims.nat{i < 32}). Hacl.P256.PrecompTable.precomp_table_acc_inv Hacl.P256.PrecompTable.g_aff 32 Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w5 i)
{ "end_col": 105, "end_line": 291, "start_col": 2, "start_line": 290 }
Prims.Tot
val precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x}
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4
val precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} let precomp_basepoint_table_w4:x: glbuffer uint64 192ul {witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} =
false
null
false
createL_global precomp_basepoint_table_list_w4
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "Lib.Buffer.createL_global", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.P256.PrecompTable.precomp_basepoint_table_list_w4", "Lib.Buffer.glbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Prims.l_and", "Lib.Buffer.witnessed", "Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w4", "Lib.Buffer.recallable", "Lib.Buffer.CONST" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4:
false
false
Hacl.P256.PrecompTable.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 precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x}
[]
Hacl.P256.PrecompTable.precomp_basepoint_table_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Lib.Buffer.glbuffer Lib.IntTypes.uint64 192ul { Lib.Buffer.witnessed x Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w4 /\ Lib.Buffer.recallable x }
{ "end_col": 48, "end_line": 213, "start_col": 2, "start_line": 213 }
Prims.Tot
val precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x}
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4
val precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} let precomp_g_pow2_64_table_w4:x: glbuffer uint64 192ul {witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} =
false
null
false
createL_global precomp_g_pow2_64_table_list_w4
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "Lib.Buffer.createL_global", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.P256.PrecompTable.precomp_g_pow2_64_table_list_w4", "Lib.Buffer.glbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Prims.l_and", "Lib.Buffer.witnessed", "Hacl.P256.PrecompTable.precomp_g_pow2_64_table_lseq_w4", "Lib.Buffer.recallable", "Lib.Buffer.CONST" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4:
false
false
Hacl.P256.PrecompTable.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 precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x}
[]
Hacl.P256.PrecompTable.precomp_g_pow2_64_table_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Lib.Buffer.glbuffer Lib.IntTypes.uint64 192ul { Lib.Buffer.witnessed x Hacl.P256.PrecompTable.precomp_g_pow2_64_table_lseq_w4 /\ Lib.Buffer.recallable x }
{ "end_col": 48, "end_line": 234, "start_col": 2, "start_line": 234 }
Prims.Tot
val precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x}
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_128_table_list_w4
val precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} let precomp_g_pow2_128_table_w4:x: glbuffer uint64 192ul {witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} =
false
null
false
createL_global precomp_g_pow2_128_table_list_w4
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "Lib.Buffer.createL_global", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.P256.PrecompTable.precomp_g_pow2_128_table_list_w4", "Lib.Buffer.glbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Prims.l_and", "Lib.Buffer.witnessed", "Hacl.P256.PrecompTable.precomp_g_pow2_128_table_lseq_w4", "Lib.Buffer.recallable", "Lib.Buffer.CONST" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4 let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma () let precomp_g_pow2_128_table_w4:
false
false
Hacl.P256.PrecompTable.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 precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x}
[]
Hacl.P256.PrecompTable.precomp_g_pow2_128_table_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Lib.Buffer.glbuffer Lib.IntTypes.uint64 192ul { Lib.Buffer.witnessed x Hacl.P256.PrecompTable.precomp_g_pow2_128_table_lseq_w4 /\ Lib.Buffer.recallable x }
{ "end_col": 49, "end_line": 255, "start_col": 2, "start_line": 255 }
Prims.Tot
val precomp_g_pow2_192_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_192_table_lseq_w4 /\ recallable x}
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_g_pow2_192_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_192_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_192_table_list_w4
val precomp_g_pow2_192_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_192_table_lseq_w4 /\ recallable x} let precomp_g_pow2_192_table_w4:x: glbuffer uint64 192ul {witnessed x precomp_g_pow2_192_table_lseq_w4 /\ recallable x} =
false
null
false
createL_global precomp_g_pow2_192_table_list_w4
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "Lib.Buffer.createL_global", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.P256.PrecompTable.precomp_g_pow2_192_table_list_w4", "Lib.Buffer.glbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Prims.l_and", "Lib.Buffer.witnessed", "Hacl.P256.PrecompTable.precomp_g_pow2_192_table_lseq_w4", "Lib.Buffer.recallable", "Lib.Buffer.CONST" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4 let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma () let precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_128_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)] inline_for_extraction noextract let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15) let precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); Seq.seq_of_list precomp_g_pow2_192_table_list_w4 let precomp_g_pow2_192_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_192 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_192_lemma () let precomp_g_pow2_192_table_w4:
false
false
Hacl.P256.PrecompTable.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 precomp_g_pow2_192_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_192_table_lseq_w4 /\ recallable x}
[]
Hacl.P256.PrecompTable.precomp_g_pow2_192_table_w4
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Lib.Buffer.glbuffer Lib.IntTypes.uint64 192ul { Lib.Buffer.witnessed x Hacl.P256.PrecompTable.precomp_g_pow2_192_table_lseq_w4 /\ Lib.Buffer.recallable x }
{ "end_col": 49, "end_line": 276, "start_col": 2, "start_line": 276 }
Prims.Tot
val precomp_basepoint_table_lseq_w5 : LSeq.lseq uint64 384
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_basepoint_table_lseq_w5 : LSeq.lseq uint64 384 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31); Seq.seq_of_list precomp_basepoint_table_list_w5
val precomp_basepoint_table_lseq_w5 : LSeq.lseq uint64 384 let precomp_basepoint_table_lseq_w5:LSeq.lseq uint64 384 =
false
null
false
normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31); Seq.seq_of_list precomp_basepoint_table_list_w5
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "FStar.Seq.Properties.seq_of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.P256.PrecompTable.precomp_basepoint_table_list_w5", "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Prims.list", "Lib.IntTypes.uint_t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "FStar.Mul.op_Star", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.uint_to_t", "Hacl.Spec.PrecompBaseTable.precomp_base_table_list", "Spec.P256.PointOps.proj_point", "Hacl.P256.PrecompTable.mk_p256_precomp_base_table", "Spec.P256.PointOps.base_point", "Lib.Sequence.lseq", "Lib.IntTypes.uint64" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4 let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma () let precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_128_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)] inline_for_extraction noextract let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15) let precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); Seq.seq_of_list precomp_g_pow2_192_table_list_w4 let precomp_g_pow2_192_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_192 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_192_lemma () let precomp_g_pow2_192_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_192_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_192_table_list_w4 /// window size = 5; precomputed table = [[0]G, [1]G, ..., [31]G] inline_for_extraction noextract let precomp_basepoint_table_list_w5: x:list uint64{FStar.List.Tot.length x = 384} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31)
false
false
Hacl.P256.PrecompTable.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 precomp_basepoint_table_lseq_w5 : LSeq.lseq uint64 384
[]
Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w5
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Sequence.lseq Lib.IntTypes.uint64 384
{ "end_col": 49, "end_line": 287, "start_col": 2, "start_line": 286 }
Prims.Tot
val precomp_basepoint_table_w5: x:glbuffer uint64 384ul{witnessed x precomp_basepoint_table_lseq_w5 /\ recallable x}
[ { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.P256.PrecompTable", "short_module": "SPTK" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable", "short_module": "SPT" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation.Definition", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_basepoint_table_w5: x:glbuffer uint64 384ul{witnessed x precomp_basepoint_table_lseq_w5 /\ recallable x} = createL_global precomp_basepoint_table_list_w5
val precomp_basepoint_table_w5: x:glbuffer uint64 384ul{witnessed x precomp_basepoint_table_lseq_w5 /\ recallable x} let precomp_basepoint_table_w5:x: glbuffer uint64 384ul {witnessed x precomp_basepoint_table_lseq_w5 /\ recallable x} =
false
null
false
createL_global precomp_basepoint_table_list_w5
{ "checked_file": "Hacl.P256.PrecompTable.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.PrecompBaseTable.fsti.checked", "Hacl.Spec.P256.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.P256.PrecompTable.fst" }
[ "total" ]
[ "Lib.Buffer.createL_global", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.P256.PrecompTable.precomp_basepoint_table_list_w5", "Lib.Buffer.glbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Prims.l_and", "Lib.Buffer.witnessed", "Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w5", "Lib.Buffer.recallable", "Lib.Buffer.CONST" ]
[]
module Hacl.P256.PrecompTable open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module SPT = Hacl.Spec.PrecompBaseTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module SPTK = Hacl.Spec.P256.PrecompTable module S = Spec.P256 module SL = Spec.P256.Lemmas open Hacl.Impl.P256.Point include Hacl.Impl.P256.Group #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let proj_point_to_list p = SPTK.proj_point_to_list_lemma p; SPTK.proj_point_to_list p let lemma_refl x = SPTK.proj_point_to_list_lemma x //----------------- inline_for_extraction noextract let proj_g_pow2_64 : S.proj_point = [@inline_let] let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in [@inline_let] let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in [@inline_let] let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in (rX, rY, rZ) val lemma_proj_g_pow2_64_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops S.base_point 64 == proj_g_pow2_64) let lemma_proj_g_pow2_64_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops S.base_point 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64); let rX : S.felem = 0x000931f4ae428a4ad81ee0aa89cf5247ce85d4dd696c61b4bb9d4761e57b7fbe in let rY : S.felem = 0x7e88e5e6a142d5c2269f21a158e82ab2c79fcecb26e397b96fd5b9fbcd0a69a5 in let rZ : S.felem = 0x02626dc2dd5e06cd19de5e6afb6c5dbdd3e41dc1472e7b8ef11eb0662e41c44b in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_128 : S.proj_point = [@inline_let] let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in [@inline_let] let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in [@inline_let] let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in (rX, rY, rZ) val lemma_proj_g_pow2_128_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64 == proj_g_pow2_128) let lemma_proj_g_pow2_128_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_64 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64); let rX : S.felem = 0x04c3aaf6c6c00704e96eda89461d63fd2c97ee1e6786fc785e6afac7aa92f9b1 in let rY : S.felem = 0x14f1edaeb8e9c8d4797d164a3946c7ff50a7c8cd59139a4dbce354e6e4df09c3 in let rZ : S.felem = 0x80119ced9a5ce83c4e31f8de1a38f89d5f9ff9f637dca86d116a4217f83e55d2 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) inline_for_extraction noextract let proj_g_pow2_192 : S.proj_point = [@inline_let] let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in [@inline_let] let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in [@inline_let] let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in (rX, rY, rZ) val lemma_proj_g_pow2_192_eval : unit -> Lemma (SE.exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64 == proj_g_pow2_192) let lemma_proj_g_pow2_192_eval () = SPT256.exp_pow2_rec_is_exp_pow2 S.mk_p256_concrete_ops proj_g_pow2_128 64; let qX, qY, qZ = normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) in normalize_term_spec (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64); let rX : S.felem = 0xc762a9c8ae1b2f7434ff8da70fe105e0d4f188594989f193de0dbdbf5f60cb9a in let rY : S.felem = 0x1eddaf51836859e1369f1ae8d9ab02e4123b6f151d9b796e297a38fa5613d9bc in let rZ : S.felem = 0xcb433ab3f67815707e398dc7910cc4ec6ea115360060fc73c35b53dce02e2c72 in assert_norm (qX == rX /\ qY == rY /\ qZ == rZ) // let proj_g_pow2_64 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops S.base_point 64) // let proj_g_pow2_128 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_64 64) // let proj_g_pow2_192 : S.proj_point = // normalize_term (SPT256.exp_pow2_rec S.mk_p256_concrete_ops proj_g_pow2_128 64) inline_for_extraction noextract let proj_g_pow2_64_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_64) inline_for_extraction noextract let proj_g_pow2_128_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_128) inline_for_extraction noextract let proj_g_pow2_192_list : SPTK.point_list = normalize_term (SPTK.proj_point_to_list proj_g_pow2_192) let proj_g_pow2_64_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); Seq.seq_of_list proj_g_pow2_64_list let proj_g_pow2_128_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); Seq.seq_of_list proj_g_pow2_128_list let proj_g_pow2_192_lseq : LSeq.lseq uint64 12 = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); Seq.seq_of_list proj_g_pow2_192_list val proj_g_pow2_64_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_64 == pow_point (pow2 64) g_aff) let proj_g_pow2_64_lemma () = lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_64_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_128_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_128 == pow_point (pow2 128) g_aff) let proj_g_pow2_128_lemma () = lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_128_lemma S.mk_p256_concrete_ops S.base_point val proj_g_pow2_192_lemma: unit -> Lemma (S.to_aff_point proj_g_pow2_192 == pow_point (pow2 192) g_aff) let proj_g_pow2_192_lemma () = lemma_proj_g_pow2_192_eval (); lemma_proj_g_pow2_128_eval (); lemma_proj_g_pow2_64_eval (); SPT256.a_pow2_192_lemma S.mk_p256_concrete_ops S.base_point let proj_g_pow2_64_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_64); proj_g_pow2_64_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_64 let proj_g_pow2_128_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_128); proj_g_pow2_128_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_128 let proj_g_pow2_192_lseq_lemma () = normalize_term_spec (SPTK.proj_point_to_list proj_g_pow2_192); proj_g_pow2_192_lemma (); SPTK.proj_point_to_list_lemma proj_g_pow2_192 let mk_proj_g_pow2_64 () = createL proj_g_pow2_64_list let mk_proj_g_pow2_128 () = createL proj_g_pow2_128_list let mk_proj_g_pow2_192 () = createL proj_g_pow2_192_list //---------------- /// window size = 4; precomputed table = [[0]G, [1]G, ..., [15]G] inline_for_extraction noextract let precomp_basepoint_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15) let precomp_basepoint_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); Seq.seq_of_list precomp_basepoint_table_list_w4 let precomp_basepoint_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 16 precomp_basepoint_table_lseq_w4 let precomp_basepoint_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_basepoint_table_lseq_w4 /\ recallable x} = createL_global precomp_basepoint_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 64]G), [1]([pow2 64]G), ..., [15]([pow2 64]G)] inline_for_extraction noextract let precomp_g_pow2_64_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15) let precomp_g_pow2_64_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); Seq.seq_of_list precomp_g_pow2_64_table_list_w4 let precomp_g_pow2_64_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_64 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_64 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_64_lemma () let precomp_g_pow2_64_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_64_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_64_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 128]G), [1]([pow2 128]G),...,[15]([pow2 128]G)] inline_for_extraction noextract let precomp_g_pow2_128_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15) let precomp_g_pow2_128_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); Seq.seq_of_list precomp_g_pow2_128_table_list_w4 let precomp_g_pow2_128_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_128 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_128 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_128_lemma () let precomp_g_pow2_128_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_128_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_128_table_list_w4 /// window size = 4; precomputed table = [[0]([pow2 192]G), [1]([pow2 192]G),...,[15]([pow2 192]G)] inline_for_extraction noextract let precomp_g_pow2_192_table_list_w4: x:list uint64{FStar.List.Tot.length x = 192} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15) let precomp_g_pow2_192_table_lseq_w4 : LSeq.lseq uint64 192 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); Seq.seq_of_list precomp_g_pow2_192_table_list_w4 let precomp_g_pow2_192_table_lemma_w4 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table proj_g_pow2_192 15); SPT.precomp_base_table_lemma mk_p256_precomp_base_table proj_g_pow2_192 16 precomp_g_pow2_64_table_lseq_w4; proj_g_pow2_192_lemma () let precomp_g_pow2_192_table_w4: x:glbuffer uint64 192ul{witnessed x precomp_g_pow2_192_table_lseq_w4 /\ recallable x} = createL_global precomp_g_pow2_192_table_list_w4 /// window size = 5; precomputed table = [[0]G, [1]G, ..., [31]G] inline_for_extraction noextract let precomp_basepoint_table_list_w5: x:list uint64{FStar.List.Tot.length x = 384} = normalize_term (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31) let precomp_basepoint_table_lseq_w5 : LSeq.lseq uint64 384 = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31); Seq.seq_of_list precomp_basepoint_table_list_w5 let precomp_basepoint_table_lemma_w5 () = normalize_term_spec (SPT.precomp_base_table_list mk_p256_precomp_base_table S.base_point 31); SPT.precomp_base_table_lemma mk_p256_precomp_base_table S.base_point 32 precomp_basepoint_table_lseq_w5 let precomp_basepoint_table_w5:
false
false
Hacl.P256.PrecompTable.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 precomp_basepoint_table_w5: x:glbuffer uint64 384ul{witnessed x precomp_basepoint_table_lseq_w5 /\ recallable x}
[]
Hacl.P256.PrecompTable.precomp_basepoint_table_w5
{ "file_name": "code/ecdsap256/Hacl.P256.PrecompTable.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Lib.Buffer.glbuffer Lib.IntTypes.uint64 384ul { Lib.Buffer.witnessed x Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w5 /\ Lib.Buffer.recallable x }
{ "end_col": 48, "end_line": 295, "start_col": 2, "start_line": 295 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ctr = size_nat
let ctr =
false
null
false
size_nat
{ "checked_file": "Spec.Agile.Cipher.fsti.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.Cipher.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_nat" ]
[]
module Spec.Agile.Cipher open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1" /// This module is concerned with defining an agile stream cipher, i.e. a /// function that given: a key; an iv (nonce); a counter, produces a fresh /// block. We leave details of key expansion to the ``.fst``, or possibly even /// to the low-level implementation. val force_flush_interleaving: unit /// Definitions /// ----------- type cipher_alg = | AES128 | AES256 | CHACHA20 /// The AES spec itself is agile; this is the same nested agility technique used /// for SHA2 vs. MD. let aes_alg_of_alg (a: cipher_alg { a = AES128 \/ a = AES256 }) = match a with | AES128 -> Spec.AES.AES128 | AES256 -> Spec.AES.AES256 /// Trying to enforce conventions: lengths for nats (spec); len for machine /// integers (runtime). let key_length (a: cipher_alg): size_nat = match a with | AES128 | AES256 -> Spec.AES.key_size (aes_alg_of_alg a) | CHACHA20 -> Spec.Chacha20.size_key let key (a: cipher_alg) = match a with | AES128 | AES256 -> Spec.AES.aes_key (aes_alg_of_alg a) | CHACHA20 -> Spec.Chacha20.key let block_length (a:cipher_alg) = match a with | AES128 | AES256 -> 16 | CHACHA20 -> 64 let block a = lbytes (block_length a) /// Smaller bound than for AES-GCM; no IV reduction. let nonce_bound (a: cipher_alg) (n_len: nat): Type0 = match a with | AES128 | AES256 -> n_len <= block_length a | CHACHA20 -> n_len == 12 let nonce a = b:bytes { nonce_bound a (length b) }
false
true
Spec.Agile.Cipher.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ctr : Type0
[]
Spec.Agile.Cipher.ctr
{ "file_name": "specs/Spec.Agile.Cipher.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 18, "end_line": 59, "start_col": 10, "start_line": 59 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let nonce a = b:bytes { nonce_bound a (length b) }
let nonce a =
false
null
false
b: bytes{nonce_bound a (length b)}
{ "checked_file": "Spec.Agile.Cipher.fsti.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.Cipher.fsti" }
[ "total" ]
[ "Spec.Agile.Cipher.cipher_alg", "Lib.ByteSequence.bytes", "Spec.Agile.Cipher.nonce_bound", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC" ]
[]
module Spec.Agile.Cipher open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1" /// This module is concerned with defining an agile stream cipher, i.e. a /// function that given: a key; an iv (nonce); a counter, produces a fresh /// block. We leave details of key expansion to the ``.fst``, or possibly even /// to the low-level implementation. val force_flush_interleaving: unit /// Definitions /// ----------- type cipher_alg = | AES128 | AES256 | CHACHA20 /// The AES spec itself is agile; this is the same nested agility technique used /// for SHA2 vs. MD. let aes_alg_of_alg (a: cipher_alg { a = AES128 \/ a = AES256 }) = match a with | AES128 -> Spec.AES.AES128 | AES256 -> Spec.AES.AES256 /// Trying to enforce conventions: lengths for nats (spec); len for machine /// integers (runtime). let key_length (a: cipher_alg): size_nat = match a with | AES128 | AES256 -> Spec.AES.key_size (aes_alg_of_alg a) | CHACHA20 -> Spec.Chacha20.size_key let key (a: cipher_alg) = match a with | AES128 | AES256 -> Spec.AES.aes_key (aes_alg_of_alg a) | CHACHA20 -> Spec.Chacha20.key let block_length (a:cipher_alg) = match a with | AES128 | AES256 -> 16 | CHACHA20 -> 64 let block a = lbytes (block_length a) /// Smaller bound than for AES-GCM; no IV reduction. let nonce_bound (a: cipher_alg) (n_len: nat): Type0 = match a with | AES128 | AES256 -> n_len <= block_length a | CHACHA20 -> n_len == 12
false
true
Spec.Agile.Cipher.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nonce : a: Spec.Agile.Cipher.cipher_alg -> Type0
[]
Spec.Agile.Cipher.nonce
{ "file_name": "specs/Spec.Agile.Cipher.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.Cipher.cipher_alg -> Type0
{ "end_col": 50, "end_line": 57, "start_col": 14, "start_line": 57 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let block_length (a:cipher_alg) = match a with | AES128 | AES256 -> 16 | CHACHA20 -> 64
let block_length (a: cipher_alg) =
false
null
false
match a with | AES128 | AES256 -> 16 | CHACHA20 -> 64
{ "checked_file": "Spec.Agile.Cipher.fsti.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.Cipher.fsti" }
[ "total" ]
[ "Spec.Agile.Cipher.cipher_alg", "Prims.int" ]
[]
module Spec.Agile.Cipher open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1" /// This module is concerned with defining an agile stream cipher, i.e. a /// function that given: a key; an iv (nonce); a counter, produces a fresh /// block. We leave details of key expansion to the ``.fst``, or possibly even /// to the low-level implementation. val force_flush_interleaving: unit /// Definitions /// ----------- type cipher_alg = | AES128 | AES256 | CHACHA20 /// The AES spec itself is agile; this is the same nested agility technique used /// for SHA2 vs. MD. let aes_alg_of_alg (a: cipher_alg { a = AES128 \/ a = AES256 }) = match a with | AES128 -> Spec.AES.AES128 | AES256 -> Spec.AES.AES256 /// Trying to enforce conventions: lengths for nats (spec); len for machine /// integers (runtime). let key_length (a: cipher_alg): size_nat = match a with | AES128 | AES256 -> Spec.AES.key_size (aes_alg_of_alg a) | CHACHA20 -> Spec.Chacha20.size_key let key (a: cipher_alg) = match a with | AES128 | AES256 -> Spec.AES.aes_key (aes_alg_of_alg a) | CHACHA20 -> Spec.Chacha20.key
false
true
Spec.Agile.Cipher.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val block_length : a: Spec.Agile.Cipher.cipher_alg -> Prims.int
[]
Spec.Agile.Cipher.block_length
{ "file_name": "specs/Spec.Agile.Cipher.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.Cipher.cipher_alg -> Prims.int
{ "end_col": 18, "end_line": 47, "start_col": 2, "start_line": 45 }
Prims.Tot
val nonce_bound (a: cipher_alg) (n_len: nat) : Type0
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let nonce_bound (a: cipher_alg) (n_len: nat): Type0 = match a with | AES128 | AES256 -> n_len <= block_length a | CHACHA20 -> n_len == 12
val nonce_bound (a: cipher_alg) (n_len: nat) : Type0 let nonce_bound (a: cipher_alg) (n_len: nat) : Type0 =
false
null
false
match a with | AES128 | AES256 -> n_len <= block_length a | CHACHA20 -> n_len == 12
{ "checked_file": "Spec.Agile.Cipher.fsti.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.Cipher.fsti" }
[ "total" ]
[ "Spec.Agile.Cipher.cipher_alg", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Spec.Agile.Cipher.block_length", "Prims.eq2", "Prims.int" ]
[]
module Spec.Agile.Cipher open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1" /// This module is concerned with defining an agile stream cipher, i.e. a /// function that given: a key; an iv (nonce); a counter, produces a fresh /// block. We leave details of key expansion to the ``.fst``, or possibly even /// to the low-level implementation. val force_flush_interleaving: unit /// Definitions /// ----------- type cipher_alg = | AES128 | AES256 | CHACHA20 /// The AES spec itself is agile; this is the same nested agility technique used /// for SHA2 vs. MD. let aes_alg_of_alg (a: cipher_alg { a = AES128 \/ a = AES256 }) = match a with | AES128 -> Spec.AES.AES128 | AES256 -> Spec.AES.AES256 /// Trying to enforce conventions: lengths for nats (spec); len for machine /// integers (runtime). let key_length (a: cipher_alg): size_nat = match a with | AES128 | AES256 -> Spec.AES.key_size (aes_alg_of_alg a) | CHACHA20 -> Spec.Chacha20.size_key let key (a: cipher_alg) = match a with | AES128 | AES256 -> Spec.AES.aes_key (aes_alg_of_alg a) | CHACHA20 -> Spec.Chacha20.key let block_length (a:cipher_alg) = match a with | AES128 | AES256 -> 16 | CHACHA20 -> 64 let block a = lbytes (block_length a) /// Smaller bound than for AES-GCM; no IV reduction.
false
true
Spec.Agile.Cipher.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val nonce_bound (a: cipher_alg) (n_len: nat) : Type0
[]
Spec.Agile.Cipher.nonce_bound
{ "file_name": "specs/Spec.Agile.Cipher.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.Cipher.cipher_alg -> n_len: Prims.nat -> Type0
{ "end_col": 27, "end_line": 55, "start_col": 2, "start_line": 53 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let aes_alg_of_alg (a: cipher_alg { a = AES128 \/ a = AES256 }) = match a with | AES128 -> Spec.AES.AES128 | AES256 -> Spec.AES.AES256
let aes_alg_of_alg (a: cipher_alg{a = AES128 \/ a = AES256}) =
false
null
false
match a with | AES128 -> Spec.AES.AES128 | AES256 -> Spec.AES.AES256
{ "checked_file": "Spec.Agile.Cipher.fsti.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.Cipher.fsti" }
[ "total" ]
[ "Spec.Agile.Cipher.cipher_alg", "Prims.l_or", "Prims.b2t", "Prims.op_Equality", "Spec.Agile.Cipher.AES128", "Spec.Agile.Cipher.AES256", "Spec.AES.AES128", "Spec.AES.AES256", "Spec.AES.variant" ]
[]
module Spec.Agile.Cipher open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1" /// This module is concerned with defining an agile stream cipher, i.e. a /// function that given: a key; an iv (nonce); a counter, produces a fresh /// block. We leave details of key expansion to the ``.fst``, or possibly even /// to the low-level implementation. val force_flush_interleaving: unit /// Definitions /// ----------- type cipher_alg = | AES128 | AES256 | CHACHA20 /// The AES spec itself is agile; this is the same nested agility technique used /// for SHA2 vs. MD.
false
false
Spec.Agile.Cipher.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val aes_alg_of_alg : a: Spec.Agile.Cipher.cipher_alg{a = Spec.Agile.Cipher.AES128 \/ a = Spec.Agile.Cipher.AES256} -> Spec.AES.variant
[]
Spec.Agile.Cipher.aes_alg_of_alg
{ "file_name": "specs/Spec.Agile.Cipher.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.Cipher.cipher_alg{a = Spec.Agile.Cipher.AES128 \/ a = Spec.Agile.Cipher.AES256} -> Spec.AES.variant
{ "end_col": 29, "end_line": 30, "start_col": 2, "start_line": 28 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let key (a: cipher_alg) = match a with | AES128 | AES256 -> Spec.AES.aes_key (aes_alg_of_alg a) | CHACHA20 -> Spec.Chacha20.key
let key (a: cipher_alg) =
false
null
false
match a with | AES128 | AES256 -> Spec.AES.aes_key (aes_alg_of_alg a) | CHACHA20 -> Spec.Chacha20.key
{ "checked_file": "Spec.Agile.Cipher.fsti.checked", "dependencies": [ "Spec.Chacha20.fst.checked", "Spec.AES.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Agile.Cipher.fsti" }
[ "total" ]
[ "Spec.Agile.Cipher.cipher_alg", "Spec.AES.aes_key", "Spec.Agile.Cipher.aes_alg_of_alg", "Spec.Chacha20.key" ]
[]
module Spec.Agile.Cipher open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence #reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1" /// This module is concerned with defining an agile stream cipher, i.e. a /// function that given: a key; an iv (nonce); a counter, produces a fresh /// block. We leave details of key expansion to the ``.fst``, or possibly even /// to the low-level implementation. val force_flush_interleaving: unit /// Definitions /// ----------- type cipher_alg = | AES128 | AES256 | CHACHA20 /// The AES spec itself is agile; this is the same nested agility technique used /// for SHA2 vs. MD. let aes_alg_of_alg (a: cipher_alg { a = AES128 \/ a = AES256 }) = match a with | AES128 -> Spec.AES.AES128 | AES256 -> Spec.AES.AES256 /// Trying to enforce conventions: lengths for nats (spec); len for machine /// integers (runtime). let key_length (a: cipher_alg): size_nat = match a with | AES128 | AES256 -> Spec.AES.key_size (aes_alg_of_alg a) | CHACHA20 -> Spec.Chacha20.size_key
false
true
Spec.Agile.Cipher.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val key : a: Spec.Agile.Cipher.cipher_alg -> Type0
[]
Spec.Agile.Cipher.key
{ "file_name": "specs/Spec.Agile.Cipher.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Agile.Cipher.cipher_alg -> Type0
{ "end_col": 33, "end_line": 42, "start_col": 2, "start_line": 40 }