file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
FStar.SizeT.fst
FStar.SizeT.of_u32
val of_u32 (x: U32.t) : Pure t (requires fits_u32) (ensures (fun y -> v y == U32.v x))
val of_u32 (x: U32.t) : Pure t (requires fits_u32) (ensures (fun y -> v y == U32.v x))
let of_u32 (x: U32.t) = uint_to_t (U32.v x)
{ "file_name": "ulib/FStar.SizeT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 23, "end_line": 57, "start_col": 0, "start_line": 56 }
module FStar.SizeT open FStar.Ghost module I64 = FStar.Int64 (* This is only intended as a model, but will be extracted natively by Krml with the correct C semantics *) (* We assume the existence of some lower bound on the size, where the bound is at least 2^16 *) assume val bound : x:erased nat { x >= pow2 16 } let t = x:U64.t { U64.v x < bound } let fits x = FStar.UInt.fits x U64.n == true /\ x < bound let fits_at_least_16 _ = () let v x = U64.v x irreducible let uint_to_t x = U64.uint_to_t x let size_v_inj (x: t) = () let size_uint_to_t_inj (x: nat) = () /// These two predicates are only used for modeling purposes, and their definitions must /// remain abstract to ensure they can only be introduced through a static assert. /// We simply define them as True here let fits_u32 = (reveal bound >= pow2 32) == true let fits_u64 = (reveal bound == pow2 64) let fits_u64_implies_fits_32 () : Lemma (requires fits_u64) (ensures fits_u32) = () let fits_u32_implies_fits (x:nat) : Lemma (requires fits_u32 /\ x < pow2 32) (ensures fits x) = () let fits_u64_implies_fits (x:nat) : Lemma (requires fits_u64 /\ x < pow2 64) (ensures fits x) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.SizeT.fst" }
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt32.t -> Prims.Pure FStar.SizeT.t
Prims.Pure
[]
[]
[ "FStar.UInt32.t", "FStar.SizeT.uint_to_t", "FStar.UInt32.v", "FStar.SizeT.t" ]
[]
false
false
false
false
false
let of_u32 (x: U32.t) =
uint_to_t (U32.v x)
false
FStar.SizeT.fst
FStar.SizeT.uint16_to_sizet
val uint16_to_sizet (x:U16.t) : Pure t (requires True) (ensures fun y -> v y == U16.v x)
val uint16_to_sizet (x:U16.t) : Pure t (requires True) (ensures fun y -> v y == U16.v x)
let uint16_to_sizet x = uint_to_t (U16.v x)
{ "file_name": "ulib/FStar.SizeT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 62, "start_col": 0, "start_line": 62 }
module FStar.SizeT open FStar.Ghost module I64 = FStar.Int64 (* This is only intended as a model, but will be extracted natively by Krml with the correct C semantics *) (* We assume the existence of some lower bound on the size, where the bound is at least 2^16 *) assume val bound : x:erased nat { x >= pow2 16 } let t = x:U64.t { U64.v x < bound } let fits x = FStar.UInt.fits x U64.n == true /\ x < bound let fits_at_least_16 _ = () let v x = U64.v x irreducible let uint_to_t x = U64.uint_to_t x let size_v_inj (x: t) = () let size_uint_to_t_inj (x: nat) = () /// These two predicates are only used for modeling purposes, and their definitions must /// remain abstract to ensure they can only be introduced through a static assert. /// We simply define them as True here let fits_u32 = (reveal bound >= pow2 32) == true let fits_u64 = (reveal bound == pow2 64) let fits_u64_implies_fits_32 () : Lemma (requires fits_u64) (ensures fits_u32) = () let fits_u32_implies_fits (x:nat) : Lemma (requires fits_u32 /\ x < pow2 32) (ensures fits x) = () let fits_u64_implies_fits (x:nat) : Lemma (requires fits_u64 /\ x < pow2 64) (ensures fits x) = () let of_u32 (x: U32.t) = uint_to_t (U32.v x) let of_u64 (x: U64.t) = uint_to_t (U64.v x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.SizeT.fst" }
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt16.t -> Prims.Pure FStar.SizeT.t
Prims.Pure
[]
[]
[ "FStar.UInt16.t", "FStar.SizeT.uint_to_t", "FStar.UInt16.v", "FStar.SizeT.t" ]
[]
false
false
false
false
false
let uint16_to_sizet x =
uint_to_t (U16.v x)
false
FStar.SizeT.fst
FStar.SizeT.uint32_to_sizet
val uint32_to_sizet (x:U32.t) : Pure t (requires fits_u32) (ensures fun y -> v y == U32.v x)
val uint32_to_sizet (x:U32.t) : Pure t (requires fits_u32) (ensures fun y -> v y == U32.v x)
let uint32_to_sizet x = uint_to_t (U32.v x)
{ "file_name": "ulib/FStar.SizeT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 63, "start_col": 0, "start_line": 63 }
module FStar.SizeT open FStar.Ghost module I64 = FStar.Int64 (* This is only intended as a model, but will be extracted natively by Krml with the correct C semantics *) (* We assume the existence of some lower bound on the size, where the bound is at least 2^16 *) assume val bound : x:erased nat { x >= pow2 16 } let t = x:U64.t { U64.v x < bound } let fits x = FStar.UInt.fits x U64.n == true /\ x < bound let fits_at_least_16 _ = () let v x = U64.v x irreducible let uint_to_t x = U64.uint_to_t x let size_v_inj (x: t) = () let size_uint_to_t_inj (x: nat) = () /// These two predicates are only used for modeling purposes, and their definitions must /// remain abstract to ensure they can only be introduced through a static assert. /// We simply define them as True here let fits_u32 = (reveal bound >= pow2 32) == true let fits_u64 = (reveal bound == pow2 64) let fits_u64_implies_fits_32 () : Lemma (requires fits_u64) (ensures fits_u32) = () let fits_u32_implies_fits (x:nat) : Lemma (requires fits_u32 /\ x < pow2 32) (ensures fits x) = () let fits_u64_implies_fits (x:nat) : Lemma (requires fits_u64 /\ x < pow2 64) (ensures fits x) = () let of_u32 (x: U32.t) = uint_to_t (U32.v x) let of_u64 (x: U64.t) = uint_to_t (U64.v x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.SizeT.fst" }
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt32.t -> Prims.Pure FStar.SizeT.t
Prims.Pure
[]
[]
[ "FStar.UInt32.t", "FStar.SizeT.uint_to_t", "FStar.UInt32.v", "FStar.SizeT.t" ]
[]
false
false
false
false
false
let uint32_to_sizet x =
uint_to_t (U32.v x)
false
Hacl.Impl.Frodo.Sample.fst
Hacl.Impl.Frodo.Sample.frodo_sample
val frodo_sample: a:FP.frodo_alg -> frodo_sample_st a
val frodo_sample: a:FP.frodo_alg -> frodo_sample_st a
let frodo_sample a r = push_frame(); let prnd = r >>. 1ul in let sign = r &. u16 1 in mod_mask_lemma r 1ul; assert (v #U16 #SEC (mod_mask 1ul) == 1); assert (v sign == 0 \/ v sign == 1); let sample :lbuffer uint16 1ul = create (size 1) (u16 0) in let h = ST.get () in assert (LSeq.index #_ #1 (as_seq h sample) 0 == u16 0); assert (bget h sample 0 == u16 0); let bound = cdf_table_len a -! 1ul in let h0 = ST.get () in Lib.Loops.for 0ul bound (fun h i -> modifies1 sample h0 h /\ v (bget h sample 0) == S.frodo_sample_fc a prnd i) (fun i -> let sample0 = sample.(0ul) in let samplei = frodo_sample_f a prnd i in sample.(0ul) <- samplei +. sample0 ); let sample0 = sample.(0ul) in assert (v sample0 == S.frodo_sample_fc a prnd (v bound)); let res = frodo_sample_res a sign sample0 in pop_frame(); res
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Sample.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 93, "start_col": 0, "start_line": 66 }
module Hacl.Impl.Frodo.Sample open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators module Lemmas = Spec.Frodo.Lemmas module S = Spec.Frodo.Sample module FP = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val frodo_sample_f: a:FP.frodo_alg -> t:uint16{uint_v t < pow2 15} -> i:size_t{v i < v (cdf_table_len a)} -> Stack uint16 (requires fun h -> True) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ v r == S.frodo_sample_f a t (v i)) let frodo_sample_f a t i = recall_contents (cdf_table a) (FP.cdf_table a); let ti = index (cdf_table a) i in FP.lemma_cdf_list a (v i); Lemmas.lemma_frodo_sample t ti; to_u16 (to_u32 (ti -. t)) >>. 15ul inline_for_extraction noextract val frodo_sample_res: a:FP.frodo_alg -> sign:uint16{v sign <= 1} -> sample:uint16{v sample < v (cdf_table_len a)} -> res:uint16{res == S.frodo_sample_res a sign (v sample)} let frodo_sample_res a sign sample = Lemmas.lemma_frodo_sample2 sign sample; ((lognot sign +. u16 1) ^. sample) +. sign inline_for_extraction noextract let frodo_sample_st (a:FP.frodo_alg) = r:uint16 -> Stack uint16 (requires fun h -> True) (ensures fun h0 res h1 -> modifies0 h0 h1 /\ res == S.frodo_sample a r) #push-options "--fuel 1" inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "Spec.Frodo.Sample.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.Loops.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Sample.fst" }
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Spec.Frodo.Sample", "short_module": "S" }, { "abbrev": true, "full_module": "Spec.Frodo.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Frodo.Params.frodo_alg -> Hacl.Impl.Frodo.Sample.frodo_sample_st a
Prims.Tot
[ "total" ]
[]
[ "Spec.Frodo.Params.frodo_alg", "Lib.IntTypes.uint16", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Lib.IntTypes.int_t", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Prims.eq2", "Spec.Frodo.Sample.frodo_sample_res", "Lib.IntTypes.v", "Hacl.Impl.Frodo.Sample.frodo_sample_res", "Prims._assert", "Prims.int", "Prims.l_or", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThanOrEqual", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.range", "Spec.Frodo.Sample.frodo_sample_fc", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "FStar.UInt32.uint_to_t", "FStar.UInt32.__uint_to_t", "Lib.Loops.for", "FStar.Monotonic.HyperStack.mem", "Prims.nat", "Lib.Buffer.modifies1", "Lib.Buffer.bget", "Lib.IntTypes.size_t", "Prims.op_LessThan", "Lib.Buffer.op_Array_Assignment", "Lib.IntTypes.op_Plus_Dot", "Hacl.Impl.Frodo.Sample.frodo_sample_f", "FStar.HyperStack.ST.get", "Lib.IntTypes.op_Subtraction_Bang", "Hacl.Impl.Frodo.Params.cdf_table_len", "Lib.IntTypes.u16", "Lib.IntTypes.range_t", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Buffer.as_seq", "Lib.Sequence.index", "Lib.Buffer.lbuffer_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.size", "Lib.Buffer.lbuffer", "Lib.IntTypes.mod_mask", "Lib.IntTypes.mod_mask_lemma", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.op_Greater_Greater_Dot", "FStar.HyperStack.ST.push_frame" ]
[]
false
false
false
false
false
let frodo_sample a r =
push_frame (); let prnd = r >>. 1ul in let sign = r &. u16 1 in mod_mask_lemma r 1ul; assert (v #U16 #SEC (mod_mask 1ul) == 1); assert (v sign == 0 \/ v sign == 1); let sample:lbuffer uint16 1ul = create (size 1) (u16 0) in let h = ST.get () in assert (LSeq.index #_ #1 (as_seq h sample) 0 == u16 0); assert (bget h sample 0 == u16 0); let bound = cdf_table_len a -! 1ul in let h0 = ST.get () in Lib.Loops.for 0ul bound (fun h i -> modifies1 sample h0 h /\ v (bget h sample 0) == S.frodo_sample_fc a prnd i) (fun i -> let sample0 = sample.(0ul) in let samplei = frodo_sample_f a prnd i in sample.(0ul) <- samplei +. sample0); let sample0 = sample.(0ul) in assert (v sample0 == S.frodo_sample_fc a prnd (v bound)); let res = frodo_sample_res a sign sample0 in pop_frame (); res
false
FStar.SizeT.fst
FStar.SizeT.uint64_to_sizet
val uint64_to_sizet (x:U64.t) : Pure t (requires fits_u64) (ensures fun y -> v y == U64.v x)
val uint64_to_sizet (x:U64.t) : Pure t (requires fits_u64) (ensures fun y -> v y == U64.v x)
let uint64_to_sizet x = uint_to_t (U64.v x)
{ "file_name": "ulib/FStar.SizeT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 64, "start_col": 0, "start_line": 64 }
module FStar.SizeT open FStar.Ghost module I64 = FStar.Int64 (* This is only intended as a model, but will be extracted natively by Krml with the correct C semantics *) (* We assume the existence of some lower bound on the size, where the bound is at least 2^16 *) assume val bound : x:erased nat { x >= pow2 16 } let t = x:U64.t { U64.v x < bound } let fits x = FStar.UInt.fits x U64.n == true /\ x < bound let fits_at_least_16 _ = () let v x = U64.v x irreducible let uint_to_t x = U64.uint_to_t x let size_v_inj (x: t) = () let size_uint_to_t_inj (x: nat) = () /// These two predicates are only used for modeling purposes, and their definitions must /// remain abstract to ensure they can only be introduced through a static assert. /// We simply define them as True here let fits_u32 = (reveal bound >= pow2 32) == true let fits_u64 = (reveal bound == pow2 64) let fits_u64_implies_fits_32 () : Lemma (requires fits_u64) (ensures fits_u32) = () let fits_u32_implies_fits (x:nat) : Lemma (requires fits_u32 /\ x < pow2 32) (ensures fits x) = () let fits_u64_implies_fits (x:nat) : Lemma (requires fits_u64 /\ x < pow2 64) (ensures fits x) = () let of_u32 (x: U32.t) = uint_to_t (U32.v x) let of_u64 (x: U64.t) = uint_to_t (U64.v x) let uint16_to_sizet x = uint_to_t (U16.v x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.SizeT.fst" }
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.UInt64.t -> Prims.Pure FStar.SizeT.t
Prims.Pure
[]
[]
[ "FStar.UInt64.t", "FStar.SizeT.uint_to_t", "FStar.UInt64.v", "FStar.SizeT.t" ]
[]
false
false
false
false
false
let uint64_to_sizet x =
uint_to_t (U64.v x)
false
FStar.SizeT.fst
FStar.SizeT.sizet_to_uint32
val sizet_to_uint32 (x:t) : Pure U32.t (requires True) (ensures fun y -> U32.v y == v x % pow2 32)
val sizet_to_uint32 (x:t) : Pure U32.t (requires True) (ensures fun y -> U32.v y == v x % pow2 32)
let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x
{ "file_name": "ulib/FStar.SizeT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 65, "start_col": 0, "start_line": 65 }
module FStar.SizeT open FStar.Ghost module I64 = FStar.Int64 (* This is only intended as a model, but will be extracted natively by Krml with the correct C semantics *) (* We assume the existence of some lower bound on the size, where the bound is at least 2^16 *) assume val bound : x:erased nat { x >= pow2 16 } let t = x:U64.t { U64.v x < bound } let fits x = FStar.UInt.fits x U64.n == true /\ x < bound let fits_at_least_16 _ = () let v x = U64.v x irreducible let uint_to_t x = U64.uint_to_t x let size_v_inj (x: t) = () let size_uint_to_t_inj (x: nat) = () /// These two predicates are only used for modeling purposes, and their definitions must /// remain abstract to ensure they can only be introduced through a static assert. /// We simply define them as True here let fits_u32 = (reveal bound >= pow2 32) == true let fits_u64 = (reveal bound == pow2 64) let fits_u64_implies_fits_32 () : Lemma (requires fits_u64) (ensures fits_u32) = () let fits_u32_implies_fits (x:nat) : Lemma (requires fits_u32 /\ x < pow2 32) (ensures fits x) = () let fits_u64_implies_fits (x:nat) : Lemma (requires fits_u64 /\ x < pow2 64) (ensures fits x) = () let of_u32 (x: U32.t) = uint_to_t (U32.v x) let of_u64 (x: U64.t) = uint_to_t (U64.v x) let uint16_to_sizet x = uint_to_t (U16.v x) let uint32_to_sizet x = uint_to_t (U32.v x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.SizeT.fst" }
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.SizeT.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.SizeT.t", "FStar.Int.Cast.uint64_to_uint32", "FStar.UInt32.t" ]
[]
false
false
false
false
false
let sizet_to_uint32 x =
FStar.Int.Cast.uint64_to_uint32 x
false
Hacl.Impl.Frodo.Sample.fst
Hacl.Impl.Frodo.Sample.frodo_sample_matrix1
val frodo_sample_matrix1: a:FP.frodo_alg -> frodo_sample:frodo_sample_st a -> n1:size_t -> n2:size_t{0 < 2 * v n1 * v n2 /\ 2 * v n1 * v n2 <= max_size_t} -> r:lbuffer uint8 (size 2 *! n1 *! n2) -> i:size_t{v i < v n1} -> res:matrix_t n1 n2 -> Stack unit (requires fun h -> live h r /\ live h res /\ disjoint r res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == S.frodo_sample_matrix1 a (v n1) (v n2) (as_seq h0 r) (v i) (as_matrix h0 res))
val frodo_sample_matrix1: a:FP.frodo_alg -> frodo_sample:frodo_sample_st a -> n1:size_t -> n2:size_t{0 < 2 * v n1 * v n2 /\ 2 * v n1 * v n2 <= max_size_t} -> r:lbuffer uint8 (size 2 *! n1 *! n2) -> i:size_t{v i < v n1} -> res:matrix_t n1 n2 -> Stack unit (requires fun h -> live h r /\ live h res /\ disjoint r res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == S.frodo_sample_matrix1 a (v n1) (v n2) (as_seq h0 r) (v i) (as_matrix h0 res))
let frodo_sample_matrix1 a frodo_sample n1 n2 r i res = [@ inline_let] let spec h0 = S.frodo_sample_matrix0 a (v n1) (v n2) (as_seq h0 r) (v i) in let h0 = ST.get () in loop1 h0 n2 res spec (fun j -> Loops.unfold_repeati (v n2) (spec h0) (as_seq h0 res) (v j); Lemmas.lemma_matrix_index_repeati1 (v n1) (v n2) (v i) (v j); let resij = sub r (size 2 *! (n2 *! i +! j)) (size 2) in mset res i j (frodo_sample (uint_from_bytes_le #U16 resij)) )
{ "file_name": "code/frodo/Hacl.Impl.Frodo.Sample.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 123, "start_col": 0, "start_line": 113 }
module Hacl.Impl.Frodo.Sample open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module Loops = Lib.LoopCombinators module Lemmas = Spec.Frodo.Lemmas module S = Spec.Frodo.Sample module FP = Spec.Frodo.Params #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val frodo_sample_f: a:FP.frodo_alg -> t:uint16{uint_v t < pow2 15} -> i:size_t{v i < v (cdf_table_len a)} -> Stack uint16 (requires fun h -> True) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ v r == S.frodo_sample_f a t (v i)) let frodo_sample_f a t i = recall_contents (cdf_table a) (FP.cdf_table a); let ti = index (cdf_table a) i in FP.lemma_cdf_list a (v i); Lemmas.lemma_frodo_sample t ti; to_u16 (to_u32 (ti -. t)) >>. 15ul inline_for_extraction noextract val frodo_sample_res: a:FP.frodo_alg -> sign:uint16{v sign <= 1} -> sample:uint16{v sample < v (cdf_table_len a)} -> res:uint16{res == S.frodo_sample_res a sign (v sample)} let frodo_sample_res a sign sample = Lemmas.lemma_frodo_sample2 sign sample; ((lognot sign +. u16 1) ^. sample) +. sign inline_for_extraction noextract let frodo_sample_st (a:FP.frodo_alg) = r:uint16 -> Stack uint16 (requires fun h -> True) (ensures fun h0 res h1 -> modifies0 h0 h1 /\ res == S.frodo_sample a r) #push-options "--fuel 1" inline_for_extraction noextract val frodo_sample: a:FP.frodo_alg -> frodo_sample_st a let frodo_sample a r = push_frame(); let prnd = r >>. 1ul in let sign = r &. u16 1 in mod_mask_lemma r 1ul; assert (v #U16 #SEC (mod_mask 1ul) == 1); assert (v sign == 0 \/ v sign == 1); let sample :lbuffer uint16 1ul = create (size 1) (u16 0) in let h = ST.get () in assert (LSeq.index #_ #1 (as_seq h sample) 0 == u16 0); assert (bget h sample 0 == u16 0); let bound = cdf_table_len a -! 1ul in let h0 = ST.get () in Lib.Loops.for 0ul bound (fun h i -> modifies1 sample h0 h /\ v (bget h sample 0) == S.frodo_sample_fc a prnd i) (fun i -> let sample0 = sample.(0ul) in let samplei = frodo_sample_f a prnd i in sample.(0ul) <- samplei +. sample0 ); let sample0 = sample.(0ul) in assert (v sample0 == S.frodo_sample_fc a prnd (v bound)); let res = frodo_sample_res a sign sample0 in pop_frame(); res #pop-options inline_for_extraction noextract val frodo_sample_matrix1: a:FP.frodo_alg -> frodo_sample:frodo_sample_st a -> n1:size_t -> n2:size_t{0 < 2 * v n1 * v n2 /\ 2 * v n1 * v n2 <= max_size_t} -> r:lbuffer uint8 (size 2 *! n1 *! n2) -> i:size_t{v i < v n1} -> res:matrix_t n1 n2 -> Stack unit (requires fun h -> live h r /\ live h res /\ disjoint r res) (ensures fun h0 _ h1 -> modifies1 res h0 h1 /\ as_matrix h1 res == S.frodo_sample_matrix1 a (v n1) (v n2) (as_seq h0 r) (v i) (as_matrix h0 res))
{ "checked_file": "/", "dependencies": [ "Spec.Frodo.Sample.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.Loops.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.Sample.fst" }
[ { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Spec.Frodo.Sample", "short_module": "S" }, { "abbrev": true, "full_module": "Spec.Frodo.Lemmas", "short_module": "Lemmas" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Frodo.Params.frodo_alg -> frodo_sample: Hacl.Impl.Frodo.Sample.frodo_sample_st a -> n1: Lib.IntTypes.size_t -> n2: Lib.IntTypes.size_t { 0 < (2 * Lib.IntTypes.v n1) * Lib.IntTypes.v n2 /\ (2 * Lib.IntTypes.v n1) * Lib.IntTypes.v n2 <= Lib.IntTypes.max_size_t } -> r: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Lib.IntTypes.size 2 *! n1 *! n2) -> i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n1} -> res: Hacl.Impl.Matrix.matrix_t n1 n2 -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Spec.Frodo.Params.frodo_alg", "Hacl.Impl.Frodo.Sample.frodo_sample_st", "Lib.IntTypes.size_t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.Mul.op_Star", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.size", "Hacl.Impl.Matrix.matrix_t", "Lib.Buffer.loop1", "Hacl.Impl.Matrix.elem", "Hacl.Impl.Matrix.mset", "Prims.unit", "Lib.IntTypes.int_t", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Lib.IntTypes.uint16", "Lib.ByteBuffer.uint_from_bytes_le", "Lib.IntTypes.uint_t", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.U8", "Lib.IntTypes.mk_int", "Lib.Buffer.sub", "Lib.IntTypes.op_Plus_Bang", "Spec.Frodo.Lemmas.lemma_matrix_index_repeati1", "Lib.LoopCombinators.unfold_repeati", "Lib.Sequence.lseq", "Prims.op_Multiply", "Lib.Buffer.as_seq", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Prims.nat", "Prims.op_Subtraction", "Prims.pow2", "Spec.Frodo.Sample.frodo_sample_matrix0" ]
[]
false
true
false
false
false
let frodo_sample_matrix1 a frodo_sample n1 n2 r i res =
[@@ inline_let ]let spec h0 = S.frodo_sample_matrix0 a (v n1) (v n2) (as_seq h0 r) (v i) in let h0 = ST.get () in loop1 h0 n2 res spec (fun j -> Loops.unfold_repeati (v n2) (spec h0) (as_seq h0 res) (v j); Lemmas.lemma_matrix_index_repeati1 (v n1) (v n2) (v i) (v j); let resij = sub r (size 2 *! (n2 *! i +! j)) (size 2) in mset res i j (frodo_sample (uint_from_bytes_le #U16 resij)))
false
FStar.SizeT.fst
FStar.SizeT.sub
val sub (x y: t) : Pure t (requires (v x >= v y)) (ensures (fun z -> v z == v x - v y))
val sub (x y: t) : Pure t (requires (v x >= v y)) (ensures (fun z -> v z == v x - v y))
let sub x y = U64.sub x y
{ "file_name": "ulib/FStar.SizeT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 71, "start_col": 0, "start_line": 71 }
module FStar.SizeT open FStar.Ghost module I64 = FStar.Int64 (* This is only intended as a model, but will be extracted natively by Krml with the correct C semantics *) (* We assume the existence of some lower bound on the size, where the bound is at least 2^16 *) assume val bound : x:erased nat { x >= pow2 16 } let t = x:U64.t { U64.v x < bound } let fits x = FStar.UInt.fits x U64.n == true /\ x < bound let fits_at_least_16 _ = () let v x = U64.v x irreducible let uint_to_t x = U64.uint_to_t x let size_v_inj (x: t) = () let size_uint_to_t_inj (x: nat) = () /// These two predicates are only used for modeling purposes, and their definitions must /// remain abstract to ensure they can only be introduced through a static assert. /// We simply define them as True here let fits_u32 = (reveal bound >= pow2 32) == true let fits_u64 = (reveal bound == pow2 64) let fits_u64_implies_fits_32 () : Lemma (requires fits_u64) (ensures fits_u32) = () let fits_u32_implies_fits (x:nat) : Lemma (requires fits_u32 /\ x < pow2 32) (ensures fits x) = () let fits_u64_implies_fits (x:nat) : Lemma (requires fits_u64 /\ x < pow2 64) (ensures fits x) = () let of_u32 (x: U32.t) = uint_to_t (U32.v x) let of_u64 (x: U64.t) = uint_to_t (U64.v x) let uint16_to_sizet x = uint_to_t (U16.v x) let uint32_to_sizet x = uint_to_t (U32.v x) let uint64_to_sizet x = uint_to_t (U64.v x) let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x let fits_lte x y = () #push-options "--z3rlimit 20"
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.SizeT.fst" }
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.SizeT.t -> y: FStar.SizeT.t -> Prims.Pure FStar.SizeT.t
Prims.Pure
[]
[]
[ "FStar.SizeT.t", "FStar.UInt64.sub" ]
[]
false
false
false
false
false
let sub x y =
U64.sub x y
false
Steel.Primitive.ForkJoin.fst
Steel.Primitive.ForkJoin.intro_maybe_p_false
val intro_maybe_p_false (p: vprop) : SteelT unit emp (fun _ -> maybe_p p false)
val intro_maybe_p_false (p: vprop) : SteelT unit emp (fun _ -> maybe_p p false)
let intro_maybe_p_false (p:vprop) : SteelT unit emp (fun _ -> maybe_p p false) = rewrite_slprop emp (maybe_p p false) (fun _ -> ())
{ "file_name": "lib/steel/Steel.Primitive.ForkJoin.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 54, "end_line": 46, "start_col": 0, "start_line": 44 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Primitive.ForkJoin open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module L = Steel.SpinLock open Steel.FractionalPermission open Steel.Reference //////////////////////////////////////////////////////////////////////////////// let maybe_p (p:vprop) (v:bool) = if v then p else emp [@@__reduce__] let lock_inv_pred (r:ref bool) (p:vprop) (v:bool) : vprop = pts_to r full_perm v `star` maybe_p p v let lock_inv (r:ref bool) (p:vprop) : vprop = h_exists (lock_inv_pred r p) noeq type thread (p:vprop) = { r:ref bool; l:L.lock (lock_inv r p) }
{ "checked_file": "/", "dependencies": [ "Steel.SpinLock.fsti.checked", "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.Primitive.ForkJoin.fst" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.SpinLock", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Steel.Effect.Common.vprop -> Steel.Effect.SteelT Prims.unit
Steel.Effect.SteelT
[]
[]
[ "Steel.Effect.Common.vprop", "Steel.Effect.Atomic.rewrite_slprop", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Effect.Common.emp", "Steel.Primitive.ForkJoin.maybe_p", "Steel.Memory.mem", "Prims.unit" ]
[]
false
true
false
false
false
let intro_maybe_p_false (p: vprop) : SteelT unit emp (fun _ -> maybe_p p false) =
rewrite_slprop emp (maybe_p p false) (fun _ -> ())
false
FStar.SizeT.fst
FStar.SizeT.add
val add (x y: t) : Pure t (requires (fits (v x + v y))) (ensures (fun z -> v z == v x + v y))
val add (x y: t) : Pure t (requires (fits (v x + v y))) (ensures (fun z -> v z == v x + v y))
let add x y = U64.add x y
{ "file_name": "ulib/FStar.SizeT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 70, "start_col": 0, "start_line": 70 }
module FStar.SizeT open FStar.Ghost module I64 = FStar.Int64 (* This is only intended as a model, but will be extracted natively by Krml with the correct C semantics *) (* We assume the existence of some lower bound on the size, where the bound is at least 2^16 *) assume val bound : x:erased nat { x >= pow2 16 } let t = x:U64.t { U64.v x < bound } let fits x = FStar.UInt.fits x U64.n == true /\ x < bound let fits_at_least_16 _ = () let v x = U64.v x irreducible let uint_to_t x = U64.uint_to_t x let size_v_inj (x: t) = () let size_uint_to_t_inj (x: nat) = () /// These two predicates are only used for modeling purposes, and their definitions must /// remain abstract to ensure they can only be introduced through a static assert. /// We simply define them as True here let fits_u32 = (reveal bound >= pow2 32) == true let fits_u64 = (reveal bound == pow2 64) let fits_u64_implies_fits_32 () : Lemma (requires fits_u64) (ensures fits_u32) = () let fits_u32_implies_fits (x:nat) : Lemma (requires fits_u32 /\ x < pow2 32) (ensures fits x) = () let fits_u64_implies_fits (x:nat) : Lemma (requires fits_u64 /\ x < pow2 64) (ensures fits x) = () let of_u32 (x: U32.t) = uint_to_t (U32.v x) let of_u64 (x: U64.t) = uint_to_t (U64.v x) let uint16_to_sizet x = uint_to_t (U16.v x) let uint32_to_sizet x = uint_to_t (U32.v x) let uint64_to_sizet x = uint_to_t (U64.v x) let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x let fits_lte x y = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.SizeT.fst" }
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.SizeT.t -> y: FStar.SizeT.t -> Prims.Pure FStar.SizeT.t
Prims.Pure
[]
[]
[ "FStar.SizeT.t", "FStar.UInt64.add" ]
[]
false
false
false
false
false
let add x y =
U64.add x y
false
Steel.Primitive.ForkJoin.fst
Steel.Primitive.ForkJoin.intro_maybe_p_true
val intro_maybe_p_true (p: vprop) : SteelT unit p (fun _ -> maybe_p p true)
val intro_maybe_p_true (p: vprop) : SteelT unit p (fun _ -> maybe_p p true)
let intro_maybe_p_true (p:vprop) : SteelT unit p (fun _ -> maybe_p p true) = rewrite_slprop p (maybe_p p true) (fun _ -> ())
{ "file_name": "lib/steel/Steel.Primitive.ForkJoin.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 51, "end_line": 50, "start_col": 0, "start_line": 48 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Primitive.ForkJoin open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module L = Steel.SpinLock open Steel.FractionalPermission open Steel.Reference //////////////////////////////////////////////////////////////////////////////// let maybe_p (p:vprop) (v:bool) = if v then p else emp [@@__reduce__] let lock_inv_pred (r:ref bool) (p:vprop) (v:bool) : vprop = pts_to r full_perm v `star` maybe_p p v let lock_inv (r:ref bool) (p:vprop) : vprop = h_exists (lock_inv_pred r p) noeq type thread (p:vprop) = { r:ref bool; l:L.lock (lock_inv r p) } let intro_maybe_p_false (p:vprop) : SteelT unit emp (fun _ -> maybe_p p false) = rewrite_slprop emp (maybe_p p false) (fun _ -> ())
{ "checked_file": "/", "dependencies": [ "Steel.SpinLock.fsti.checked", "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.Primitive.ForkJoin.fst" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.SpinLock", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Steel.Effect.Common.vprop -> Steel.Effect.SteelT Prims.unit
Steel.Effect.SteelT
[]
[]
[ "Steel.Effect.Common.vprop", "Steel.Effect.Atomic.rewrite_slprop", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Primitive.ForkJoin.maybe_p", "Steel.Memory.mem", "Prims.unit" ]
[]
false
true
false
false
false
let intro_maybe_p_true (p: vprop) : SteelT unit p (fun _ -> maybe_p p true) =
rewrite_slprop p (maybe_p p true) (fun _ -> ())
false
FStar.SizeT.fst
FStar.SizeT.mul
val mul (x y: t) : Pure t (requires (fits (v x * v y))) (ensures (fun z -> v z == v x * v y))
val mul (x y: t) : Pure t (requires (fits (v x * v y))) (ensures (fun z -> v z == v x * v y))
let mul x y = U64.mul x y
{ "file_name": "ulib/FStar.SizeT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 72, "start_col": 0, "start_line": 72 }
module FStar.SizeT open FStar.Ghost module I64 = FStar.Int64 (* This is only intended as a model, but will be extracted natively by Krml with the correct C semantics *) (* We assume the existence of some lower bound on the size, where the bound is at least 2^16 *) assume val bound : x:erased nat { x >= pow2 16 } let t = x:U64.t { U64.v x < bound } let fits x = FStar.UInt.fits x U64.n == true /\ x < bound let fits_at_least_16 _ = () let v x = U64.v x irreducible let uint_to_t x = U64.uint_to_t x let size_v_inj (x: t) = () let size_uint_to_t_inj (x: nat) = () /// These two predicates are only used for modeling purposes, and their definitions must /// remain abstract to ensure they can only be introduced through a static assert. /// We simply define them as True here let fits_u32 = (reveal bound >= pow2 32) == true let fits_u64 = (reveal bound == pow2 64) let fits_u64_implies_fits_32 () : Lemma (requires fits_u64) (ensures fits_u32) = () let fits_u32_implies_fits (x:nat) : Lemma (requires fits_u32 /\ x < pow2 32) (ensures fits x) = () let fits_u64_implies_fits (x:nat) : Lemma (requires fits_u64 /\ x < pow2 64) (ensures fits x) = () let of_u32 (x: U32.t) = uint_to_t (U32.v x) let of_u64 (x: U64.t) = uint_to_t (U64.v x) let uint16_to_sizet x = uint_to_t (U16.v x) let uint32_to_sizet x = uint_to_t (U32.v x) let uint64_to_sizet x = uint_to_t (U64.v x) let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x let fits_lte x y = () #push-options "--z3rlimit 20" let add x y = U64.add x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.SizeT.fst" }
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.SizeT.t -> y: FStar.SizeT.t -> Prims.Pure FStar.SizeT.t
Prims.Pure
[]
[]
[ "FStar.SizeT.t", "FStar.UInt64.mul" ]
[]
false
false
false
false
false
let mul x y =
U64.mul x y
false
FStar.SizeT.fst
FStar.SizeT.div
val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c))
val div (a:t) (b:t{v b <> 0}) : Pure t (requires (True)) (ensures (fun c -> v a / v b = v c))
let div x y = let res = U64.div x y in fits_lte (U64.v res) (U64.v x); FStar.Math.Lib.slash_decr_axiom (U64.v x) (U64.v y); assert (U64.v x / U64.v y <= U64.v x); res
{ "file_name": "ulib/FStar.SizeT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 78, "start_col": 0, "start_line": 73 }
module FStar.SizeT open FStar.Ghost module I64 = FStar.Int64 (* This is only intended as a model, but will be extracted natively by Krml with the correct C semantics *) (* We assume the existence of some lower bound on the size, where the bound is at least 2^16 *) assume val bound : x:erased nat { x >= pow2 16 } let t = x:U64.t { U64.v x < bound } let fits x = FStar.UInt.fits x U64.n == true /\ x < bound let fits_at_least_16 _ = () let v x = U64.v x irreducible let uint_to_t x = U64.uint_to_t x let size_v_inj (x: t) = () let size_uint_to_t_inj (x: nat) = () /// These two predicates are only used for modeling purposes, and their definitions must /// remain abstract to ensure they can only be introduced through a static assert. /// We simply define them as True here let fits_u32 = (reveal bound >= pow2 32) == true let fits_u64 = (reveal bound == pow2 64) let fits_u64_implies_fits_32 () : Lemma (requires fits_u64) (ensures fits_u32) = () let fits_u32_implies_fits (x:nat) : Lemma (requires fits_u32 /\ x < pow2 32) (ensures fits x) = () let fits_u64_implies_fits (x:nat) : Lemma (requires fits_u64 /\ x < pow2 64) (ensures fits x) = () let of_u32 (x: U32.t) = uint_to_t (U32.v x) let of_u64 (x: U64.t) = uint_to_t (U64.v x) let uint16_to_sizet x = uint_to_t (U16.v x) let uint32_to_sizet x = uint_to_t (U32.v x) let uint64_to_sizet x = uint_to_t (U64.v x) let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x let fits_lte x y = () #push-options "--z3rlimit 20" let add x y = U64.add x y let sub x y = U64.sub x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.SizeT.fst" }
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.SizeT.t -> b: FStar.SizeT.t{FStar.SizeT.v b <> 0} -> Prims.Pure FStar.SizeT.t
Prims.Pure
[]
[]
[ "FStar.SizeT.t", "Prims.b2t", "Prims.op_disEquality", "Prims.int", "FStar.SizeT.v", "Prims.unit", "Prims._assert", "Prims.op_LessThanOrEqual", "Prims.op_Division", "FStar.UInt64.v", "FStar.Math.Lib.slash_decr_axiom", "FStar.SizeT.fits_lte", "FStar.UInt64.t", "FStar.UInt64.div" ]
[]
false
false
false
false
false
let div x y =
let res = U64.div x y in fits_lte (U64.v res) (U64.v x); FStar.Math.Lib.slash_decr_axiom (U64.v x) (U64.v y); assert (U64.v x / U64.v y <= U64.v x); res
false
FStar.SizeT.fst
FStar.SizeT.gte
val gte (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x >= v y)))
val gte (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x >= v y)))
let gte x y = U64.gte x y
{ "file_name": "ulib/FStar.SizeT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 81, "start_col": 0, "start_line": 81 }
module FStar.SizeT open FStar.Ghost module I64 = FStar.Int64 (* This is only intended as a model, but will be extracted natively by Krml with the correct C semantics *) (* We assume the existence of some lower bound on the size, where the bound is at least 2^16 *) assume val bound : x:erased nat { x >= pow2 16 } let t = x:U64.t { U64.v x < bound } let fits x = FStar.UInt.fits x U64.n == true /\ x < bound let fits_at_least_16 _ = () let v x = U64.v x irreducible let uint_to_t x = U64.uint_to_t x let size_v_inj (x: t) = () let size_uint_to_t_inj (x: nat) = () /// These two predicates are only used for modeling purposes, and their definitions must /// remain abstract to ensure they can only be introduced through a static assert. /// We simply define them as True here let fits_u32 = (reveal bound >= pow2 32) == true let fits_u64 = (reveal bound == pow2 64) let fits_u64_implies_fits_32 () : Lemma (requires fits_u64) (ensures fits_u32) = () let fits_u32_implies_fits (x:nat) : Lemma (requires fits_u32 /\ x < pow2 32) (ensures fits x) = () let fits_u64_implies_fits (x:nat) : Lemma (requires fits_u64 /\ x < pow2 64) (ensures fits x) = () let of_u32 (x: U32.t) = uint_to_t (U32.v x) let of_u64 (x: U64.t) = uint_to_t (U64.v x) let uint16_to_sizet x = uint_to_t (U16.v x) let uint32_to_sizet x = uint_to_t (U32.v x) let uint64_to_sizet x = uint_to_t (U64.v x) let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x let fits_lte x y = () #push-options "--z3rlimit 20" let add x y = U64.add x y let sub x y = U64.sub x y let mul x y = U64.mul x y let div x y = let res = U64.div x y in fits_lte (U64.v res) (U64.v x); FStar.Math.Lib.slash_decr_axiom (U64.v x) (U64.v y); assert (U64.v x / U64.v y <= U64.v x); res let rem x y = U64.rem x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.SizeT.fst" }
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.SizeT.t -> y: FStar.SizeT.t -> Prims.Pure Prims.bool
Prims.Pure
[]
[]
[ "FStar.SizeT.t", "FStar.UInt64.gte", "Prims.bool" ]
[]
false
false
false
false
false
let gte x y =
U64.gte x y
false
FStar.SizeT.fst
FStar.SizeT.gt
val gt (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x > v y)))
val gt (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x > v y)))
let gt x y = U64.gt x y
{ "file_name": "ulib/FStar.SizeT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 23, "end_line": 80, "start_col": 0, "start_line": 80 }
module FStar.SizeT open FStar.Ghost module I64 = FStar.Int64 (* This is only intended as a model, but will be extracted natively by Krml with the correct C semantics *) (* We assume the existence of some lower bound on the size, where the bound is at least 2^16 *) assume val bound : x:erased nat { x >= pow2 16 } let t = x:U64.t { U64.v x < bound } let fits x = FStar.UInt.fits x U64.n == true /\ x < bound let fits_at_least_16 _ = () let v x = U64.v x irreducible let uint_to_t x = U64.uint_to_t x let size_v_inj (x: t) = () let size_uint_to_t_inj (x: nat) = () /// These two predicates are only used for modeling purposes, and their definitions must /// remain abstract to ensure they can only be introduced through a static assert. /// We simply define them as True here let fits_u32 = (reveal bound >= pow2 32) == true let fits_u64 = (reveal bound == pow2 64) let fits_u64_implies_fits_32 () : Lemma (requires fits_u64) (ensures fits_u32) = () let fits_u32_implies_fits (x:nat) : Lemma (requires fits_u32 /\ x < pow2 32) (ensures fits x) = () let fits_u64_implies_fits (x:nat) : Lemma (requires fits_u64 /\ x < pow2 64) (ensures fits x) = () let of_u32 (x: U32.t) = uint_to_t (U32.v x) let of_u64 (x: U64.t) = uint_to_t (U64.v x) let uint16_to_sizet x = uint_to_t (U16.v x) let uint32_to_sizet x = uint_to_t (U32.v x) let uint64_to_sizet x = uint_to_t (U64.v x) let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x let fits_lte x y = () #push-options "--z3rlimit 20" let add x y = U64.add x y let sub x y = U64.sub x y let mul x y = U64.mul x y let div x y = let res = U64.div x y in fits_lte (U64.v res) (U64.v x); FStar.Math.Lib.slash_decr_axiom (U64.v x) (U64.v y); assert (U64.v x / U64.v y <= U64.v x); res
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.SizeT.fst" }
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.SizeT.t -> y: FStar.SizeT.t -> Prims.Pure Prims.bool
Prims.Pure
[]
[]
[ "FStar.SizeT.t", "FStar.UInt64.gt", "Prims.bool" ]
[]
false
false
false
false
false
let gt x y =
U64.gt x y
false
FStar.SizeT.fst
FStar.SizeT.rem
val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> mod_spec (v a) (v b) = v c))
val rem (a:t) (b:t{v b <> 0}) : Pure t (requires True) (ensures (fun c -> mod_spec (v a) (v b) = v c))
let rem x y = U64.rem x y
{ "file_name": "ulib/FStar.SizeT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 79, "start_col": 0, "start_line": 79 }
module FStar.SizeT open FStar.Ghost module I64 = FStar.Int64 (* This is only intended as a model, but will be extracted natively by Krml with the correct C semantics *) (* We assume the existence of some lower bound on the size, where the bound is at least 2^16 *) assume val bound : x:erased nat { x >= pow2 16 } let t = x:U64.t { U64.v x < bound } let fits x = FStar.UInt.fits x U64.n == true /\ x < bound let fits_at_least_16 _ = () let v x = U64.v x irreducible let uint_to_t x = U64.uint_to_t x let size_v_inj (x: t) = () let size_uint_to_t_inj (x: nat) = () /// These two predicates are only used for modeling purposes, and their definitions must /// remain abstract to ensure they can only be introduced through a static assert. /// We simply define them as True here let fits_u32 = (reveal bound >= pow2 32) == true let fits_u64 = (reveal bound == pow2 64) let fits_u64_implies_fits_32 () : Lemma (requires fits_u64) (ensures fits_u32) = () let fits_u32_implies_fits (x:nat) : Lemma (requires fits_u32 /\ x < pow2 32) (ensures fits x) = () let fits_u64_implies_fits (x:nat) : Lemma (requires fits_u64 /\ x < pow2 64) (ensures fits x) = () let of_u32 (x: U32.t) = uint_to_t (U32.v x) let of_u64 (x: U64.t) = uint_to_t (U64.v x) let uint16_to_sizet x = uint_to_t (U16.v x) let uint32_to_sizet x = uint_to_t (U32.v x) let uint64_to_sizet x = uint_to_t (U64.v x) let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x let fits_lte x y = () #push-options "--z3rlimit 20" let add x y = U64.add x y let sub x y = U64.sub x y let mul x y = U64.mul x y let div x y = let res = U64.div x y in fits_lte (U64.v res) (U64.v x); FStar.Math.Lib.slash_decr_axiom (U64.v x) (U64.v y); assert (U64.v x / U64.v y <= U64.v x);
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.SizeT.fst" }
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.SizeT.t -> b: FStar.SizeT.t{FStar.SizeT.v b <> 0} -> Prims.Pure FStar.SizeT.t
Prims.Pure
[]
[]
[ "FStar.SizeT.t", "Prims.b2t", "Prims.op_disEquality", "Prims.int", "FStar.SizeT.v", "FStar.UInt64.rem" ]
[]
false
false
false
false
false
let rem x y =
U64.rem x y
false
FStar.SizeT.fst
FStar.SizeT.lte
val lte (x y: t) : Pure bool (requires True) (ensures (fun z -> z == (v x <= v y)))
val lte (x y: t) : Pure bool (requires True) (ensures (fun z -> z == (v x <= v y)))
let lte x y = U64.lte x y
{ "file_name": "ulib/FStar.SizeT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 83, "start_col": 0, "start_line": 83 }
module FStar.SizeT open FStar.Ghost module I64 = FStar.Int64 (* This is only intended as a model, but will be extracted natively by Krml with the correct C semantics *) (* We assume the existence of some lower bound on the size, where the bound is at least 2^16 *) assume val bound : x:erased nat { x >= pow2 16 } let t = x:U64.t { U64.v x < bound } let fits x = FStar.UInt.fits x U64.n == true /\ x < bound let fits_at_least_16 _ = () let v x = U64.v x irreducible let uint_to_t x = U64.uint_to_t x let size_v_inj (x: t) = () let size_uint_to_t_inj (x: nat) = () /// These two predicates are only used for modeling purposes, and their definitions must /// remain abstract to ensure they can only be introduced through a static assert. /// We simply define them as True here let fits_u32 = (reveal bound >= pow2 32) == true let fits_u64 = (reveal bound == pow2 64) let fits_u64_implies_fits_32 () : Lemma (requires fits_u64) (ensures fits_u32) = () let fits_u32_implies_fits (x:nat) : Lemma (requires fits_u32 /\ x < pow2 32) (ensures fits x) = () let fits_u64_implies_fits (x:nat) : Lemma (requires fits_u64 /\ x < pow2 64) (ensures fits x) = () let of_u32 (x: U32.t) = uint_to_t (U32.v x) let of_u64 (x: U64.t) = uint_to_t (U64.v x) let uint16_to_sizet x = uint_to_t (U16.v x) let uint32_to_sizet x = uint_to_t (U32.v x) let uint64_to_sizet x = uint_to_t (U64.v x) let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x let fits_lte x y = () #push-options "--z3rlimit 20" let add x y = U64.add x y let sub x y = U64.sub x y let mul x y = U64.mul x y let div x y = let res = U64.div x y in fits_lte (U64.v res) (U64.v x); FStar.Math.Lib.slash_decr_axiom (U64.v x) (U64.v y); assert (U64.v x / U64.v y <= U64.v x); res let rem x y = U64.rem x y let gt x y = U64.gt x y let gte x y = U64.gte x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.SizeT.fst" }
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.SizeT.t -> y: FStar.SizeT.t -> Prims.Pure Prims.bool
Prims.Pure
[]
[]
[ "FStar.SizeT.t", "FStar.UInt64.lte", "Prims.bool" ]
[]
false
false
false
false
false
let lte x y =
U64.lte x y
false
FStar.SizeT.fst
FStar.SizeT.lt
val lt (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x < v y)))
val lt (x y:t) : Pure bool (requires True) (ensures (fun z -> z == (v x < v y)))
let lt x y = U64.lt x y
{ "file_name": "ulib/FStar.SizeT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 23, "end_line": 82, "start_col": 0, "start_line": 82 }
module FStar.SizeT open FStar.Ghost module I64 = FStar.Int64 (* This is only intended as a model, but will be extracted natively by Krml with the correct C semantics *) (* We assume the existence of some lower bound on the size, where the bound is at least 2^16 *) assume val bound : x:erased nat { x >= pow2 16 } let t = x:U64.t { U64.v x < bound } let fits x = FStar.UInt.fits x U64.n == true /\ x < bound let fits_at_least_16 _ = () let v x = U64.v x irreducible let uint_to_t x = U64.uint_to_t x let size_v_inj (x: t) = () let size_uint_to_t_inj (x: nat) = () /// These two predicates are only used for modeling purposes, and their definitions must /// remain abstract to ensure they can only be introduced through a static assert. /// We simply define them as True here let fits_u32 = (reveal bound >= pow2 32) == true let fits_u64 = (reveal bound == pow2 64) let fits_u64_implies_fits_32 () : Lemma (requires fits_u64) (ensures fits_u32) = () let fits_u32_implies_fits (x:nat) : Lemma (requires fits_u32 /\ x < pow2 32) (ensures fits x) = () let fits_u64_implies_fits (x:nat) : Lemma (requires fits_u64 /\ x < pow2 64) (ensures fits x) = () let of_u32 (x: U32.t) = uint_to_t (U32.v x) let of_u64 (x: U64.t) = uint_to_t (U64.v x) let uint16_to_sizet x = uint_to_t (U16.v x) let uint32_to_sizet x = uint_to_t (U32.v x) let uint64_to_sizet x = uint_to_t (U64.v x) let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x let fits_lte x y = () #push-options "--z3rlimit 20" let add x y = U64.add x y let sub x y = U64.sub x y let mul x y = U64.mul x y let div x y = let res = U64.div x y in fits_lte (U64.v res) (U64.v x); FStar.Math.Lib.slash_decr_axiom (U64.v x) (U64.v y); assert (U64.v x / U64.v y <= U64.v x); res let rem x y = U64.rem x y let gt x y = U64.gt x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.SizeT.fst" }
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: FStar.SizeT.t -> y: FStar.SizeT.t -> Prims.Pure Prims.bool
Prims.Pure
[]
[]
[ "FStar.SizeT.t", "FStar.UInt64.lt", "Prims.bool" ]
[]
false
false
false
false
false
let lt x y =
U64.lt x y
false
Hacl.Spec.Bignum.AlmostMontExponentiation.fst
Hacl.Spec.Bignum.AlmostMontExponentiation.amm_refl
val amm_refl (#t: limb_t) (#len: BN.bn_len t) (n: lbignum t len {0 < bn_v n}) (x: lbignum t len) : Lib.NatMod.nat_mod (bn_v n)
val amm_refl (#t: limb_t) (#len: BN.bn_len t) (n: lbignum t len {0 < bn_v n}) (x: lbignum t len) : Lib.NatMod.nat_mod (bn_v n)
let amm_refl (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len{0 < bn_v n}) (x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n) = bn_v x % bn_v n
{ "file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 17, "end_line": 28, "start_col": 0, "start_line": 23 }
module Hacl.Spec.Bignum.AlmostMontExponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module LE = Lib.Exponentiation module SE = Spec.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas module BN = Hacl.Spec.Bignum module BM = Hacl.Spec.Bignum.Montgomery module BA = Hacl.Spec.Bignum.AlmostMontgomery module ME = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "BA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "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": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Hacl.Spec.Bignum.Definitions.lbignum t len {0 < Hacl.Spec.Bignum.Definitions.bn_v n} -> x: Hacl.Spec.Bignum.Definitions.lbignum t len -> Lib.NatMod.nat_mod (Hacl.Spec.Bignum.Definitions.bn_v n)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.op_Modulus", "Lib.NatMod.nat_mod" ]
[]
false
false
false
false
false
let amm_refl (#t: limb_t) (#len: BN.bn_len t) (n: lbignum t len {0 < bn_v n}) (x: lbignum t len) : Lib.NatMod.nat_mod (bn_v n) =
bn_v x % bn_v n
false
Hacl.Spec.Bignum.AlmostMontExponentiation.fst
Hacl.Spec.Bignum.AlmostMontExponentiation.bn_almost_mont_one
val bn_almost_mont_one: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
val bn_almost_mont_one: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_one #t #len n mu _ = let one = ME.bn_mont_one n mu () in assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); Math.Lemmas.small_mod (bn_v one) (bn_v n); assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); one
{ "file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 55, "start_col": 0, "start_line": 50 }
module Hacl.Spec.Bignum.AlmostMontExponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module LE = Lib.Exponentiation module SE = Spec.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas module BN = Hacl.Spec.Bignum module BM = Hacl.Spec.Bignum.Montgomery module BA = Hacl.Spec.Bignum.AlmostMontgomery module ME = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let amm_refl (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len{0 < bn_v n}) (x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n) = bn_v x % bn_v n let mk_to_nat_mont_ll_comm_monoid (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.to_comm_monoid (lbignum t len) = { SE.a_spec = Lib.NatMod.nat_mod (bn_v n); SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu); SE.refl = amm_refl n; } val bn_almost_mont_one: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "BA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "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": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> mu: Hacl.Spec.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre n mu} -> Spec.Exponentiation.one_st (Hacl.Spec.Bignum.Definitions.lbignum t len) (Hacl.Spec.Bignum.AlmostMontExponentiation.mk_to_nat_mont_ll_comm_monoid n mu)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "Prims.unit", "Prims._assert", "Prims.eq2", "Lib.NatMod.nat_mod", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.AlmostMontExponentiation.amm_refl", "Hacl.Spec.Exponentiation.Lemmas.mont_one_ll", "Lib.IntTypes.bits", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "FStar.Math.Lemmas.small_mod", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.MontExponentiation.bn_mont_one" ]
[]
false
false
false
false
false
let bn_almost_mont_one #t #len n mu _ =
let one = ME.bn_mont_one n mu () in assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); Math.Lemmas.small_mod (bn_v one) (bn_v n); assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); one
false
Hacl.Spec.Bignum.AlmostMontExponentiation.fst
Hacl.Spec.Bignum.AlmostMontExponentiation.bn_almost_mont_sqr
val bn_almost_mont_sqr: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
val bn_almost_mont_sqr: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_sqr #t #len n mu aM = let c = BA.bn_almost_mont_sqr n mu aM in BA.bn_almost_mont_sqr_lemma n mu aM; bn_eval_bound aM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM); c
{ "file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 86, "start_col": 0, "start_line": 81 }
module Hacl.Spec.Bignum.AlmostMontExponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module LE = Lib.Exponentiation module SE = Spec.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas module BN = Hacl.Spec.Bignum module BM = Hacl.Spec.Bignum.Montgomery module BA = Hacl.Spec.Bignum.AlmostMontgomery module ME = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let amm_refl (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len{0 < bn_v n}) (x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n) = bn_v x % bn_v n let mk_to_nat_mont_ll_comm_monoid (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.to_comm_monoid (lbignum t len) = { SE.a_spec = Lib.NatMod.nat_mod (bn_v n); SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu); SE.refl = amm_refl n; } val bn_almost_mont_one: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_one #t #len n mu _ = let one = ME.bn_mont_one n mu () in assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); Math.Lemmas.small_mod (bn_v one) (bn_v n); assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); one val bn_almost_mont_mul: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_mul #t #len n mu aM bM = let c = BA.bn_almost_mont_mul n mu aM bM in BA.bn_almost_mont_mul_lemma n mu aM bM; bn_eval_bound aM len; bn_eval_bound bM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM); c val bn_almost_mont_sqr: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "BA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "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": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> mu: Hacl.Spec.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre n mu} -> Spec.Exponentiation.sqr_st (Hacl.Spec.Bignum.Definitions.lbignum t len) (Hacl.Spec.Bignum.AlmostMontExponentiation.mk_to_nat_mont_ll_comm_monoid n mu)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "Prims.unit", "Hacl.Spec.AlmostMontgomery.Lemmas.almost_mont_mul_is_mont_mul_lemma", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Definitions.bn_v", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Hacl.Spec.Bignum.Definitions.bn_eval_bound", "Hacl.Spec.Bignum.AlmostMontgomery.bn_almost_mont_sqr_lemma", "Hacl.Spec.Bignum.AlmostMontgomery.bn_almost_mont_sqr" ]
[]
false
false
false
false
false
let bn_almost_mont_sqr #t #len n mu aM =
let c = BA.bn_almost_mont_sqr n mu aM in BA.bn_almost_mont_sqr_lemma n mu aM; bn_eval_bound aM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM); c
false
Hacl.Spec.Bignum.AlmostMontExponentiation.fst
Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st
val bn_exp_almost_mont_st : t: Hacl.Spec.Bignum.Definitions.limb_t -> len: Hacl.Spec.Bignum.bn_len t -> Type0
let bn_exp_almost_mont_st (t:limb_t) (len:BN.bn_len t) = n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> aM:ME.bn_mont_t n -> bBits:size_nat -> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} -> Pure (lbignum t len) (requires True) (ensures fun resM -> let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in bn_v resM % bn_v n == LE.pow k (bn_v aM) (bn_v b))
{ "file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 54, "end_line": 115, "start_col": 0, "start_line": 105 }
module Hacl.Spec.Bignum.AlmostMontExponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module LE = Lib.Exponentiation module SE = Spec.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas module BN = Hacl.Spec.Bignum module BM = Hacl.Spec.Bignum.Montgomery module BA = Hacl.Spec.Bignum.AlmostMontgomery module ME = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let amm_refl (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len{0 < bn_v n}) (x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n) = bn_v x % bn_v n let mk_to_nat_mont_ll_comm_monoid (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.to_comm_monoid (lbignum t len) = { SE.a_spec = Lib.NatMod.nat_mod (bn_v n); SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu); SE.refl = amm_refl n; } val bn_almost_mont_one: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_one #t #len n mu _ = let one = ME.bn_mont_one n mu () in assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); Math.Lemmas.small_mod (bn_v one) (bn_v n); assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); one val bn_almost_mont_mul: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_mul #t #len n mu aM bM = let c = BA.bn_almost_mont_mul n mu aM bM in BA.bn_almost_mont_mul_lemma n mu aM bM; bn_eval_bound aM len; bn_eval_bound bM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM); c val bn_almost_mont_sqr: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_sqr #t #len n mu aM = let c = BA.bn_almost_mont_sqr n mu aM in BA.bn_almost_mont_sqr_lemma n mu aM; bn_eval_bound aM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM); c let mk_bn_almost_mont_concrete_ops (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.concrete_ops (lbignum t len) = { SE.to = mk_to_nat_mont_ll_comm_monoid n mu; SE.one = bn_almost_mont_one #t #len n mu; SE.mul = bn_almost_mont_mul #t #len n mu; SE.sqr = bn_almost_mont_sqr #t #len n mu; } ///////////////////////////////////////////////////////////////////////////////
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "BA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "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": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Spec.Bignum.Definitions.limb_t -> len: Hacl.Spec.Bignum.bn_len t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "Hacl.Spec.Bignum.MontExponentiation.bn_mont_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.blocks0", "Lib.IntTypes.bits", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.pow2", "Prims.l_True", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Lib.Exponentiation.Definition.pow", "Lib.NatMod.nat_mod", "Lib.Exponentiation.Definition.comm_monoid", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid", "Lib.IntTypes.v", "Lib.IntTypes.SEC" ]
[]
false
false
false
false
true
let bn_exp_almost_mont_st (t: limb_t) (len: BN.bn_len t) =
n: lbignum t len -> mu: limb t {BM.bn_mont_pre n mu} -> aM: ME.bn_mont_t n -> bBits: size_nat -> b: lbignum t (blocks0 bBits (bits t)) {bn_v b < pow2 bBits} -> Pure (lbignum t len) (requires True) (ensures fun resM -> let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in bn_v resM % bn_v n == LE.pow k (bn_v aM) (bn_v b))
false
Hacl.Spec.Bignum.AlmostMontExponentiation.fst
Hacl.Spec.Bignum.AlmostMontExponentiation.bn_almost_mont_mul
val bn_almost_mont_mul: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
val bn_almost_mont_mul: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_mul #t #len n mu aM bM = let c = BA.bn_almost_mont_mul n mu aM bM in BA.bn_almost_mont_mul_lemma n mu aM bM; bn_eval_bound aM len; bn_eval_bound bM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM); c
{ "file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 71, "start_col": 0, "start_line": 65 }
module Hacl.Spec.Bignum.AlmostMontExponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module LE = Lib.Exponentiation module SE = Spec.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas module BN = Hacl.Spec.Bignum module BM = Hacl.Spec.Bignum.Montgomery module BA = Hacl.Spec.Bignum.AlmostMontgomery module ME = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let amm_refl (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len{0 < bn_v n}) (x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n) = bn_v x % bn_v n let mk_to_nat_mont_ll_comm_monoid (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.to_comm_monoid (lbignum t len) = { SE.a_spec = Lib.NatMod.nat_mod (bn_v n); SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu); SE.refl = amm_refl n; } val bn_almost_mont_one: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_one #t #len n mu _ = let one = ME.bn_mont_one n mu () in assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); Math.Lemmas.small_mod (bn_v one) (bn_v n); assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); one val bn_almost_mont_mul: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "BA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "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": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Hacl.Spec.Bignum.Definitions.lbignum t len -> mu: Hacl.Spec.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre n mu} -> Spec.Exponentiation.mul_st (Hacl.Spec.Bignum.Definitions.lbignum t len) (Hacl.Spec.Bignum.AlmostMontExponentiation.mk_to_nat_mont_ll_comm_monoid n mu)
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "Prims.unit", "Hacl.Spec.AlmostMontgomery.Lemmas.almost_mont_mul_is_mont_mul_lemma", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Definitions.bn_v", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Hacl.Spec.Bignum.Definitions.bn_eval_bound", "Hacl.Spec.Bignum.AlmostMontgomery.bn_almost_mont_mul_lemma", "Hacl.Spec.Bignum.AlmostMontgomery.bn_almost_mont_mul" ]
[]
false
false
false
false
false
let bn_almost_mont_mul #t #len n mu aM bM =
let c = BA.bn_almost_mont_mul n mu aM bM in BA.bn_almost_mont_mul_lemma n mu aM bM; bn_eval_bound aM len; bn_eval_bound bM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM); c
false
Hacl.Spec.Bignum.AlmostMontExponentiation.fst
Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_bm_vartime
val bn_exp_almost_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
val bn_exp_almost_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_bm_vartime #t #len n mu aM bBits b = let k1 = mk_bn_almost_mont_concrete_ops n mu in let k = k1.SE.to.SE.comm_monoid in let resM = SE.exp_rl k1 aM bBits (bn_v b) in //assert (bn_v resM % bn_v n == LE.exp_rl k (bn_v aM % bn_v n) bBits (bn_v b)); SE.exp_rl_lemma k1 aM bBits (bn_v b); LE.exp_rl_lemma k (bn_v aM % bn_v n) bBits (bn_v b); //assert (bn_v resM % bn_v n == LE.pow k (bn_v aM % bn_v n) (bn_v b)); E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); resM
{ "file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 6, "end_line": 130, "start_col": 0, "start_line": 120 }
module Hacl.Spec.Bignum.AlmostMontExponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module LE = Lib.Exponentiation module SE = Spec.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas module BN = Hacl.Spec.Bignum module BM = Hacl.Spec.Bignum.Montgomery module BA = Hacl.Spec.Bignum.AlmostMontgomery module ME = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let amm_refl (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len{0 < bn_v n}) (x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n) = bn_v x % bn_v n let mk_to_nat_mont_ll_comm_monoid (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.to_comm_monoid (lbignum t len) = { SE.a_spec = Lib.NatMod.nat_mod (bn_v n); SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu); SE.refl = amm_refl n; } val bn_almost_mont_one: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_one #t #len n mu _ = let one = ME.bn_mont_one n mu () in assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); Math.Lemmas.small_mod (bn_v one) (bn_v n); assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); one val bn_almost_mont_mul: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_mul #t #len n mu aM bM = let c = BA.bn_almost_mont_mul n mu aM bM in BA.bn_almost_mont_mul_lemma n mu aM bM; bn_eval_bound aM len; bn_eval_bound bM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM); c val bn_almost_mont_sqr: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_sqr #t #len n mu aM = let c = BA.bn_almost_mont_sqr n mu aM in BA.bn_almost_mont_sqr_lemma n mu aM; bn_eval_bound aM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM); c let mk_bn_almost_mont_concrete_ops (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.concrete_ops (lbignum t len) = { SE.to = mk_to_nat_mont_ll_comm_monoid n mu; SE.one = bn_almost_mont_one #t #len n mu; SE.mul = bn_almost_mont_mul #t #len n mu; SE.sqr = bn_almost_mont_sqr #t #len n mu; } /////////////////////////////////////////////////////////////////////////////// noextract let bn_exp_almost_mont_st (t:limb_t) (len:BN.bn_len t) = n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> aM:ME.bn_mont_t n -> bBits:size_nat -> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} -> Pure (lbignum t len) (requires True) (ensures fun resM -> let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in bn_v resM % bn_v n == LE.pow k (bn_v aM) (bn_v b)) // no diff between vartime and consttime at the spec level
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "BA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "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": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t len
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "Hacl.Spec.Bignum.MontExponentiation.bn_mont_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.blocks0", "Lib.IntTypes.bits", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.pow2", "Prims.unit", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_mod_base", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Lib.Exponentiation.exp_rl_lemma", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__to", "Prims.op_Modulus", "Spec.Exponentiation.exp_rl_lemma", "Spec.Exponentiation.exp_rl", "Lib.Exponentiation.Definition.comm_monoid", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid", "Spec.Exponentiation.concrete_ops", "Hacl.Spec.Bignum.AlmostMontExponentiation.mk_bn_almost_mont_concrete_ops" ]
[]
false
false
false
false
false
let bn_exp_almost_mont_bm_vartime #t #len n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in let k = k1.SE.to.SE.comm_monoid in let resM = SE.exp_rl k1 aM bBits (bn_v b) in SE.exp_rl_lemma k1 aM bBits (bn_v b); LE.exp_rl_lemma k (bn_v aM % bn_v n) bBits (bn_v b); E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); resM
false
Hacl.Spec.Bignum.AlmostMontExponentiation.fst
Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_bm_consttime
val bn_exp_almost_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
val bn_exp_almost_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_bm_consttime #t #len n mu aM bBits b = let k1 = mk_bn_almost_mont_concrete_ops n mu in let k = k1.SE.to.SE.comm_monoid in SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b); LE.exp_mont_ladder_swap_lemma k (bn_v aM % bn_v n) bBits (bn_v b); LE.exp_mont_ladder_lemma k (bn_v aM % bn_v n) bBits (bn_v b); E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); SE.exp_mont_ladder_swap k1 aM bBits (bn_v b)
{ "file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 142, "start_col": 0, "start_line": 134 }
module Hacl.Spec.Bignum.AlmostMontExponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module LE = Lib.Exponentiation module SE = Spec.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas module BN = Hacl.Spec.Bignum module BM = Hacl.Spec.Bignum.Montgomery module BA = Hacl.Spec.Bignum.AlmostMontgomery module ME = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let amm_refl (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len{0 < bn_v n}) (x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n) = bn_v x % bn_v n let mk_to_nat_mont_ll_comm_monoid (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.to_comm_monoid (lbignum t len) = { SE.a_spec = Lib.NatMod.nat_mod (bn_v n); SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu); SE.refl = amm_refl n; } val bn_almost_mont_one: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_one #t #len n mu _ = let one = ME.bn_mont_one n mu () in assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); Math.Lemmas.small_mod (bn_v one) (bn_v n); assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); one val bn_almost_mont_mul: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_mul #t #len n mu aM bM = let c = BA.bn_almost_mont_mul n mu aM bM in BA.bn_almost_mont_mul_lemma n mu aM bM; bn_eval_bound aM len; bn_eval_bound bM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM); c val bn_almost_mont_sqr: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_sqr #t #len n mu aM = let c = BA.bn_almost_mont_sqr n mu aM in BA.bn_almost_mont_sqr_lemma n mu aM; bn_eval_bound aM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM); c let mk_bn_almost_mont_concrete_ops (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.concrete_ops (lbignum t len) = { SE.to = mk_to_nat_mont_ll_comm_monoid n mu; SE.one = bn_almost_mont_one #t #len n mu; SE.mul = bn_almost_mont_mul #t #len n mu; SE.sqr = bn_almost_mont_sqr #t #len n mu; } /////////////////////////////////////////////////////////////////////////////// noextract let bn_exp_almost_mont_st (t:limb_t) (len:BN.bn_len t) = n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> aM:ME.bn_mont_t n -> bBits:size_nat -> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} -> Pure (lbignum t len) (requires True) (ensures fun resM -> let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in bn_v resM % bn_v n == LE.pow k (bn_v aM) (bn_v b)) // no diff between vartime and consttime at the spec level val bn_exp_almost_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len let bn_exp_almost_mont_bm_vartime #t #len n mu aM bBits b = let k1 = mk_bn_almost_mont_concrete_ops n mu in let k = k1.SE.to.SE.comm_monoid in let resM = SE.exp_rl k1 aM bBits (bn_v b) in //assert (bn_v resM % bn_v n == LE.exp_rl k (bn_v aM % bn_v n) bBits (bn_v b)); SE.exp_rl_lemma k1 aM bBits (bn_v b); LE.exp_rl_lemma k (bn_v aM % bn_v n) bBits (bn_v b); //assert (bn_v resM % bn_v n == LE.pow k (bn_v aM % bn_v n) (bn_v b)); E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); resM
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "BA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "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": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t len
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "Hacl.Spec.Bignum.MontExponentiation.bn_mont_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.blocks0", "Lib.IntTypes.bits", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.pow2", "Spec.Exponentiation.exp_mont_ladder_swap", "Prims.unit", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_mod_base", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Lib.Exponentiation.exp_mont_ladder_lemma", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__to", "Prims.op_Modulus", "Lib.Exponentiation.exp_mont_ladder_swap_lemma", "Spec.Exponentiation.exp_mont_ladder_swap_lemma", "Lib.Exponentiation.Definition.comm_monoid", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid", "Spec.Exponentiation.concrete_ops", "Hacl.Spec.Bignum.AlmostMontExponentiation.mk_bn_almost_mont_concrete_ops" ]
[]
false
false
false
false
false
let bn_exp_almost_mont_bm_consttime #t #len n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in let k = k1.SE.to.SE.comm_monoid in SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b); LE.exp_mont_ladder_swap_lemma k (bn_v aM % bn_v n) bBits (bn_v b); LE.exp_mont_ladder_lemma k (bn_v aM % bn_v n) bBits (bn_v b); E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); SE.exp_mont_ladder_swap k1 aM bBits (bn_v b)
false
Hacl.Spec.Bignum.AlmostMontExponentiation.fst
Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_vartime
val bn_exp_almost_mont_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
val bn_exp_almost_mont_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_vartime #t #len n mu aM bBits b = if bBits < ME.bn_exp_mont_vartime_threshold then bn_exp_almost_mont_bm_vartime n mu aM bBits b else bn_exp_almost_mont_fw 4 n mu aM bBits b
{ "file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 43, "end_line": 164, "start_col": 0, "start_line": 160 }
module Hacl.Spec.Bignum.AlmostMontExponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module LE = Lib.Exponentiation module SE = Spec.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas module BN = Hacl.Spec.Bignum module BM = Hacl.Spec.Bignum.Montgomery module BA = Hacl.Spec.Bignum.AlmostMontgomery module ME = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let amm_refl (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len{0 < bn_v n}) (x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n) = bn_v x % bn_v n let mk_to_nat_mont_ll_comm_monoid (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.to_comm_monoid (lbignum t len) = { SE.a_spec = Lib.NatMod.nat_mod (bn_v n); SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu); SE.refl = amm_refl n; } val bn_almost_mont_one: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_one #t #len n mu _ = let one = ME.bn_mont_one n mu () in assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); Math.Lemmas.small_mod (bn_v one) (bn_v n); assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); one val bn_almost_mont_mul: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_mul #t #len n mu aM bM = let c = BA.bn_almost_mont_mul n mu aM bM in BA.bn_almost_mont_mul_lemma n mu aM bM; bn_eval_bound aM len; bn_eval_bound bM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM); c val bn_almost_mont_sqr: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_sqr #t #len n mu aM = let c = BA.bn_almost_mont_sqr n mu aM in BA.bn_almost_mont_sqr_lemma n mu aM; bn_eval_bound aM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM); c let mk_bn_almost_mont_concrete_ops (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.concrete_ops (lbignum t len) = { SE.to = mk_to_nat_mont_ll_comm_monoid n mu; SE.one = bn_almost_mont_one #t #len n mu; SE.mul = bn_almost_mont_mul #t #len n mu; SE.sqr = bn_almost_mont_sqr #t #len n mu; } /////////////////////////////////////////////////////////////////////////////// noextract let bn_exp_almost_mont_st (t:limb_t) (len:BN.bn_len t) = n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> aM:ME.bn_mont_t n -> bBits:size_nat -> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} -> Pure (lbignum t len) (requires True) (ensures fun resM -> let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in bn_v resM % bn_v n == LE.pow k (bn_v aM) (bn_v b)) // no diff between vartime and consttime at the spec level val bn_exp_almost_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len let bn_exp_almost_mont_bm_vartime #t #len n mu aM bBits b = let k1 = mk_bn_almost_mont_concrete_ops n mu in let k = k1.SE.to.SE.comm_monoid in let resM = SE.exp_rl k1 aM bBits (bn_v b) in //assert (bn_v resM % bn_v n == LE.exp_rl k (bn_v aM % bn_v n) bBits (bn_v b)); SE.exp_rl_lemma k1 aM bBits (bn_v b); LE.exp_rl_lemma k (bn_v aM % bn_v n) bBits (bn_v b); //assert (bn_v resM % bn_v n == LE.pow k (bn_v aM % bn_v n) (bn_v b)); E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); resM val bn_exp_almost_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len let bn_exp_almost_mont_bm_consttime #t #len n mu aM bBits b = let k1 = mk_bn_almost_mont_concrete_ops n mu in let k = k1.SE.to.SE.comm_monoid in SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b); LE.exp_mont_ladder_swap_lemma k (bn_v aM % bn_v n) bBits (bn_v b); LE.exp_mont_ladder_lemma k (bn_v aM % bn_v n) bBits (bn_v b); E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); SE.exp_mont_ladder_swap k1 aM bBits (bn_v b) val bn_exp_almost_mont_fw: #t:limb_t -> #len:BN.bn_len t -> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} -> bn_exp_almost_mont_st t len let bn_exp_almost_mont_fw #t #len l n mu aM bBits b = let k1 = mk_bn_almost_mont_concrete_ops n mu in SE.exp_fw_lemma k1 aM bBits (bn_v b) l; LE.exp_fw_lemma k1.SE.to.SE.comm_monoid (bn_v aM % bn_v n) bBits (bn_v b) l; E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); SE.exp_fw k1 aM bBits (bn_v b) l
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "BA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "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": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t len
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "Hacl.Spec.Bignum.MontExponentiation.bn_mont_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.blocks0", "Lib.IntTypes.bits", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.pow2", "Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_vartime_threshold", "Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_bm_vartime", "Prims.bool", "Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_fw" ]
[]
false
false
false
false
false
let bn_exp_almost_mont_vartime #t #len n mu aM bBits b =
if bBits < ME.bn_exp_mont_vartime_threshold then bn_exp_almost_mont_bm_vartime n mu aM bBits b else bn_exp_almost_mont_fw 4 n mu aM bBits b
false
Hacl.Spec.Bignum.AlmostMontExponentiation.fst
Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_consttime
val bn_exp_almost_mont_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
val bn_exp_almost_mont_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_consttime #t #len n mu aM bBits b = if bBits < ME.bn_exp_mont_consttime_threshold then bn_exp_almost_mont_bm_consttime n mu aM bBits b else bn_exp_almost_mont_fw 4 n mu aM bBits b
{ "file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 43, "end_line": 172, "start_col": 0, "start_line": 168 }
module Hacl.Spec.Bignum.AlmostMontExponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module LE = Lib.Exponentiation module SE = Spec.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas module BN = Hacl.Spec.Bignum module BM = Hacl.Spec.Bignum.Montgomery module BA = Hacl.Spec.Bignum.AlmostMontgomery module ME = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let amm_refl (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len{0 < bn_v n}) (x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n) = bn_v x % bn_v n let mk_to_nat_mont_ll_comm_monoid (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.to_comm_monoid (lbignum t len) = { SE.a_spec = Lib.NatMod.nat_mod (bn_v n); SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu); SE.refl = amm_refl n; } val bn_almost_mont_one: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_one #t #len n mu _ = let one = ME.bn_mont_one n mu () in assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); Math.Lemmas.small_mod (bn_v one) (bn_v n); assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); one val bn_almost_mont_mul: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_mul #t #len n mu aM bM = let c = BA.bn_almost_mont_mul n mu aM bM in BA.bn_almost_mont_mul_lemma n mu aM bM; bn_eval_bound aM len; bn_eval_bound bM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM); c val bn_almost_mont_sqr: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_sqr #t #len n mu aM = let c = BA.bn_almost_mont_sqr n mu aM in BA.bn_almost_mont_sqr_lemma n mu aM; bn_eval_bound aM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM); c let mk_bn_almost_mont_concrete_ops (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.concrete_ops (lbignum t len) = { SE.to = mk_to_nat_mont_ll_comm_monoid n mu; SE.one = bn_almost_mont_one #t #len n mu; SE.mul = bn_almost_mont_mul #t #len n mu; SE.sqr = bn_almost_mont_sqr #t #len n mu; } /////////////////////////////////////////////////////////////////////////////// noextract let bn_exp_almost_mont_st (t:limb_t) (len:BN.bn_len t) = n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> aM:ME.bn_mont_t n -> bBits:size_nat -> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} -> Pure (lbignum t len) (requires True) (ensures fun resM -> let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in bn_v resM % bn_v n == LE.pow k (bn_v aM) (bn_v b)) // no diff between vartime and consttime at the spec level val bn_exp_almost_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len let bn_exp_almost_mont_bm_vartime #t #len n mu aM bBits b = let k1 = mk_bn_almost_mont_concrete_ops n mu in let k = k1.SE.to.SE.comm_monoid in let resM = SE.exp_rl k1 aM bBits (bn_v b) in //assert (bn_v resM % bn_v n == LE.exp_rl k (bn_v aM % bn_v n) bBits (bn_v b)); SE.exp_rl_lemma k1 aM bBits (bn_v b); LE.exp_rl_lemma k (bn_v aM % bn_v n) bBits (bn_v b); //assert (bn_v resM % bn_v n == LE.pow k (bn_v aM % bn_v n) (bn_v b)); E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); resM val bn_exp_almost_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len let bn_exp_almost_mont_bm_consttime #t #len n mu aM bBits b = let k1 = mk_bn_almost_mont_concrete_ops n mu in let k = k1.SE.to.SE.comm_monoid in SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b); LE.exp_mont_ladder_swap_lemma k (bn_v aM % bn_v n) bBits (bn_v b); LE.exp_mont_ladder_lemma k (bn_v aM % bn_v n) bBits (bn_v b); E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); SE.exp_mont_ladder_swap k1 aM bBits (bn_v b) val bn_exp_almost_mont_fw: #t:limb_t -> #len:BN.bn_len t -> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} -> bn_exp_almost_mont_st t len let bn_exp_almost_mont_fw #t #len l n mu aM bBits b = let k1 = mk_bn_almost_mont_concrete_ops n mu in SE.exp_fw_lemma k1 aM bBits (bn_v b) l; LE.exp_fw_lemma k1.SE.to.SE.comm_monoid (bn_v aM % bn_v n) bBits (bn_v b) l; E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); SE.exp_fw k1 aM bBits (bn_v b) l val bn_exp_almost_mont_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len let bn_exp_almost_mont_vartime #t #len n mu aM bBits b = if bBits < ME.bn_exp_mont_vartime_threshold then bn_exp_almost_mont_bm_vartime n mu aM bBits b else bn_exp_almost_mont_fw 4 n mu aM bBits b
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "BA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "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": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t len
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "Hacl.Spec.Bignum.MontExponentiation.bn_mont_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.blocks0", "Lib.IntTypes.bits", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Prims.pow2", "Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_consttime_threshold", "Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_bm_consttime", "Prims.bool", "Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_fw" ]
[]
false
false
false
false
false
let bn_exp_almost_mont_consttime #t #len n mu aM bBits b =
if bBits < ME.bn_exp_mont_consttime_threshold then bn_exp_almost_mont_bm_consttime n mu aM bBits b else bn_exp_almost_mont_fw 4 n mu aM bBits b
false
Steel.ST.GenElim1.fst
Steel.ST.GenElim1.compute_gen_elim_tele_correct_exists_unit0
val compute_gen_elim_tele_correct_exists_unit0 (ty: _) (body: (ty -> gen_unit_elim_i)) : Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
val compute_gen_elim_tele_correct_exists_unit0 (ty: _) (body: (ty -> gen_unit_elim_i)) : Tot (ge_to_tele_t (GEExistsUnit0 #ty body))
let compute_gen_elim_tele_correct_exists_unit0 (ty: _) (body: ty -> gen_unit_elim_i) : Tot (ge_to_tele_t (GEExistsUnit0 #ty body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x))); let x = elim_exists' () in let _ = compute_gen_unit_elim_f (body x) _ in intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x)))); rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x)))); intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x)))); rewrite_with_trefl (exists_ _) (tele_p _)
{ "file_name": "lib/steel/Steel.ST.GenElim1.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 43, "end_line": 365, "start_col": 0, "start_line": 354 }
module Steel.ST.GenElim1 let gen_elim_f (p: vprop) (a: Type) (q: (a -> vprop)) (post: (a -> prop)) : Tot Type = ((opened: inames) -> STGhost a opened p q True post) module U = FStar.Universe let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type = gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i) let compute_gen_unit_elim_f_id (v: vprop) : Tot (gen_unit_elim_t (GUEId v)) = fun _ -> noop (); U.raise_val () let compute_gen_unit_elim_f_pure (p: prop) : Tot (gen_unit_elim_t (GUEPure p)) = fun _ -> rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p); elim_pure p; U.raise_val () let compute_gen_unit_elim_f_star (i1 i2: gen_unit_elim_i) (f1: gen_unit_elim_t i1) (f2: gen_unit_elim_t i2) : Tot (gen_unit_elim_t (GUEStar i1 i2)) = fun _ -> rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2); let _ = f1 _ in let _ = f2 _ in rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2)); U.raise_val () let rec compute_gen_unit_elim_f (i: gen_unit_elim_i) : GTot (gen_unit_elim_t i) = match i returns (gen_unit_elim_t i) with | GUEId v -> compute_gen_unit_elim_f_id v | GUEPure p -> compute_gen_unit_elim_f_pure p | GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2) let gen_elim_t (i: gen_elim_i) : Tot Type = gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i) let compute_gen_elim_f_unit (i: gen_unit_elim_i) : GTot (gen_elim_t (GEUnit i)) = compute_gen_unit_elim_f i let compute_gen_elim_f_star_l (i1: gen_elim_i) (f1: gen_elim_t i1) (i2: gen_unit_elim_i) : GTot (gen_elim_t (GEStarL i1 i2)) = let f2 = compute_gen_unit_elim_f i2 in fun _ -> rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2); let res = f1 _ in let _ = f2 _ in let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res'); res' let compute_gen_elim_f_star_r (i1: gen_unit_elim_i) (i2: gen_elim_i) (f2: gen_elim_t i2) : GTot (gen_elim_t (GEStarR i1 i2)) = let f1 = compute_gen_unit_elim_f i1 in fun _ -> rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2); let _ = f1 _ in let res = f2 _ in let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res'); res' let compute_gen_elim_f_star (i1: gen_elim_i) (f1: gen_elim_t i1) (i2: gen_elim_i) (f2: gen_elim_t i2) : GTot (gen_elim_t (GEStar i1 i2)) = fun _ -> rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2); let res1 = f1 _ in let res2 = f2 _ in let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res); res let compute_gen_elim_f_exists_no_abs0 (a: Type0) (body: (a -> vprop)) : GTot (gen_elim_t (GEExistsNoAbs0 body)) = fun _ -> rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body); let gres = elim_exists () in let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res); res let rewrite_with_trefl (#opened:_) (p q:vprop) : STGhost unit opened p (fun _ -> q) (requires T.with_tactic T.trefl (p == q)) (ensures fun _ -> True) = rewrite p q let compute_gen_elim_f_exists_unit0 (a: Type0) (body: a -> gen_unit_elim_i) : Tot (gen_elim_t (GEExistsUnit0 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x))); let gres = elim_exists () in let _ = compute_gen_unit_elim_f (body gres) _ in let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res); res let compute_gen_elim_f_exists0 (a: Type0) (body: a -> gen_elim_i) (f: (x: a) -> GTot (gen_elim_t (body x))) : Tot (gen_elim_t (GEExists0 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x))); let gres1 = elim_exists () in let gres2 = f gres1 _ in let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res); res let compute_gen_elim_f_exists_no_abs1 (a: Type) (body: (a -> vprop)) : GTot (gen_elim_t (GEExistsNoAbs1 body)) = fun _ -> rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body); let gres = elim_exists () in let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res); res let compute_gen_elim_f_exists_unit1 (a: Type) (body: a -> gen_unit_elim_i) : Tot (gen_elim_t (GEExistsUnit1 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x))); let gres = elim_exists () in let _ = compute_gen_unit_elim_f (body gres) _ in let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res); res let compute_gen_elim_f_exists1 (a: Type) (body: a -> gen_elim_i) (f: (x: a) -> GTot (gen_elim_t (body x))) : Tot (gen_elim_t (GEExists1 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x))); let gres1 = elim_exists () in let gres2 = f gres1 _ in let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res); res let rec compute_gen_elim_f (i: gen_elim_i) : GTot (gen_elim_t i) = match i returns (gen_elim_t i) with | GEUnit i -> compute_gen_elim_f_unit i | GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2 | GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2) | GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2) | GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body | GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body | GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x)) | GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body | GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body | GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x)) let rec tele_p (x: gen_elim_tele) : Tot vprop = match x with | TRet v p -> v `star` pure p | TExists ty body -> exists_ (fun x -> tele_p (body x)) let elim_exists' (#a:Type) (#opened_invariants:_) (#p:a -> vprop) (_:unit) : STGhostT (a) opened_invariants (exists_ p) (fun x -> p x) = let gx = elim_exists () in let x = Ghost.reveal gx in rewrite (p gx) (p x); x let vprop_rewrite (from to: vprop) : Tot Type = gen_elim_f from unit (fun _ -> to) (fun _ -> True) let tele_star_vprop_correct_ret (v': vprop) (p': prop) (v: vprop) (p: prop) : Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p))) = fun _ -> elim_pure p; rewrite (tele_p _) (v' `star` pure p'); elim_pure p'; intro_pure (p /\ p'); rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _) let tele_star_vprop_correct_exists (v: vprop) (p: prop) (ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p)))) : Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p))) = fun _ -> rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x))); let x = elim_exists' () in ih x _; intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p)); rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _) let rec tele_star_vprop_correct (i: gen_elim_tele) (v: vprop) (p: prop) : GTot (vprop_rewrite (tele_p i `star` v `star` pure p) (tele_p (tele_star_vprop i v p)) ) = match i returns vprop_rewrite (tele_p i `star` v `star` pure p) (tele_p (tele_star_vprop i v p)) with | TRet v' p' -> tele_star_vprop_correct_ret v' p' v p | TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p) let tele_star_correct_ret_l (v1: vprop) (p1: prop) (i2: gen_elim_tele) : Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2))) = fun _ -> rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1); tele_star_vprop_correct i2 v1 p1 _; rewrite (tele_p _) (tele_p _) let tele_star_correct_ret_r (i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop) : Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2))) = fun _ -> rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2); tele_star_vprop_correct i1 v2 p2 _; rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2)) let tele_star_correct_exists (ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele) (ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2)))) : Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2)))) = fun _ -> rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1))); let x1 = elim_exists' () in rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2))); let x2 = elim_exists' () in ih x1 x2 _; intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))); intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)))); rewrite_with_trefl (exists_ _) (tele_p _) let rec tele_star_correct (i1 i2: gen_elim_tele) : GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2))) = match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with | TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2 | TExists ty1 f1 -> begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with | TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2 | TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2)) end [@@noextract_to "Plugin" ] let ge_to_tele_t (i: gen_elim_i) : Tot Type = vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i)) let compute_gen_elim_tele_correct_unit (v: gen_unit_elim_i) : Tot (ge_to_tele_t (GEUnit v)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v); let _ = compute_gen_unit_elim_f v _ in intro_pure (compute_gen_unit_elim_post v); rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _) let compute_gen_elim_tele_correct_star_l (l: gen_elim_i) (ihl: ge_to_tele_t l) (ru: gen_unit_elim_i) : Tot (ge_to_tele_t (GEStarL l ru)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru); ihl _; let _ = compute_gen_unit_elim_f ru _ in intro_pure (compute_gen_unit_elim_post ru); tele_star_vprop_correct _ _ _ _; rewrite_with_trefl (tele_p _) (tele_p _) let compute_gen_elim_tele_correct_star_r (lu: gen_unit_elim_i) (r: gen_elim_i) (ihr: ge_to_tele_t r) : Tot (ge_to_tele_t (GEStarR lu r)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r); ihr _; let _ = compute_gen_unit_elim_f lu _ in intro_pure (compute_gen_unit_elim_post lu); tele_star_vprop_correct _ _ _ _; rewrite_with_trefl (tele_p _) (tele_p _) let compute_gen_elim_tele_correct_star (l: gen_elim_i) (ihl: ge_to_tele_t l) (r: gen_elim_i) (ihr: ge_to_tele_t r) : Tot (ge_to_tele_t (GEStar l r)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r); ihl _; ihr _; tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _; rewrite_with_trefl (tele_p _) (tele_p _) let compute_gen_elim_tele_correct_exists_no_abs0 (ty: _) (body: ty -> vprop) : Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ body); let x = elim_exists' () in intro_pure True; rewrite (body x) (body (U.downgrade_val (U.raise_val x))); intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True); rewrite_with_trefl (exists_ _) (tele_p _)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.GenElim1.fst" }
[ { "abbrev": true, "full_module": "FStar.Universe", "short_module": "U" }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "Steel.ST.GenElim1.Base", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ty: Type0 -> body: (_: ty -> Steel.ST.GenElim1.Base.gen_unit_elim_i) -> Steel.ST.GenElim1.ge_to_tele_t (Steel.ST.GenElim1.Base.GEExistsUnit0 body)
Prims.Tot
[ "total" ]
[]
[ "Steel.ST.GenElim1.Base.gen_unit_elim_i", "Steel.Memory.inames", "Steel.ST.GenElim1.rewrite_with_trefl", "Steel.ST.Util.exists_", "FStar.Universe.raise_t", "Steel.Effect.Common.star", "Steel.ST.GenElim1.Base.compute_gen_unit_elim_q", "FStar.Universe.downgrade_val", "Steel.ST.Util.pure", "Steel.ST.GenElim1.Base.compute_gen_unit_elim_post", "Steel.Effect.Common.vprop", "Steel.ST.GenElim1.tele_p", "Steel.ST.GenElim1.Base.compute_gen_elim_tele", "Steel.ST.GenElim1.Base.GEExistsUnit0", "Prims.unit", "Steel.ST.Util.intro_exists", "FStar.Universe.raise_val", "Steel.ST.Util.rewrite", "Steel.ST.Util.intro_pure", "Steel.ST.GenElim1.compute_gen_unit_elim_f", "Steel.ST.GenElim1.elim_exists'", "Steel.ST.GenElim1.Base.compute_gen_unit_elim_p", "Steel.ST.GenElim1.Base.compute_gen_elim_p", "Steel.ST.GenElim1.ge_to_tele_t" ]
[]
false
false
false
false
false
let compute_gen_elim_tele_correct_exists_unit0 (ty: _) (body: (ty -> gen_unit_elim_i)) : Tot (ge_to_tele_t (GEExistsUnit0 #ty body)) =
fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x))); let x = elim_exists' () in let _ = compute_gen_unit_elim_f (body x) _ in intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x)))); rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x)))); intro_exists (U.raise_val u#0 u#1 x) (fun x -> (compute_gen_unit_elim_q (body (U.downgrade_val x))) `star` (pure (compute_gen_unit_elim_post (body (U.downgrade_val x))))); rewrite_with_trefl (exists_ _) (tele_p _)
false
Hacl.Spec.Bignum.AlmostMontExponentiation.fst
Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_fw
val bn_exp_almost_mont_fw: #t:limb_t -> #len:BN.bn_len t -> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} -> bn_exp_almost_mont_st t len
val bn_exp_almost_mont_fw: #t:limb_t -> #len:BN.bn_len t -> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_fw #t #len l n mu aM bBits b = let k1 = mk_bn_almost_mont_concrete_ops n mu in SE.exp_fw_lemma k1 aM bBits (bn_v b) l; LE.exp_fw_lemma k1.SE.to.SE.comm_monoid (bn_v aM % bn_v n) bBits (bn_v b) l; E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); SE.exp_fw k1 aM bBits (bn_v b) l
{ "file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 156, "start_col": 0, "start_line": 151 }
module Hacl.Spec.Bignum.AlmostMontExponentiation open FStar.Mul open Lib.IntTypes open Lib.Sequence open Hacl.Spec.Bignum.Definitions module LE = Lib.Exponentiation module SE = Spec.Exponentiation module E = Hacl.Spec.Exponentiation.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas module BN = Hacl.Spec.Bignum module BM = Hacl.Spec.Bignum.Montgomery module BA = Hacl.Spec.Bignum.AlmostMontgomery module ME = Hacl.Spec.Bignum.MontExponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" let amm_refl (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len{0 < bn_v n}) (x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n) = bn_v x % bn_v n let mk_to_nat_mont_ll_comm_monoid (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.to_comm_monoid (lbignum t len) = { SE.a_spec = Lib.NatMod.nat_mod (bn_v n); SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu); SE.refl = amm_refl n; } val bn_almost_mont_one: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_one #t #len n mu _ = let one = ME.bn_mont_one n mu () in assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); Math.Lemmas.small_mod (bn_v one) (bn_v n); assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu)); one val bn_almost_mont_mul: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_mul #t #len n mu aM bM = let c = BA.bn_almost_mont_mul n mu aM bM in BA.bn_almost_mont_mul_lemma n mu aM bM; bn_eval_bound aM len; bn_eval_bound bM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM); c val bn_almost_mont_sqr: #t:limb_t -> #len:BN.bn_len t -> n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) let bn_almost_mont_sqr #t #len n mu aM = let c = BA.bn_almost_mont_sqr n mu aM in BA.bn_almost_mont_sqr_lemma n mu aM; bn_eval_bound aM len; AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM); c let mk_bn_almost_mont_concrete_ops (#t:limb_t) (#len:BN.bn_len t) (n:lbignum t len) (mu:limb t{BM.bn_mont_pre n mu}) : SE.concrete_ops (lbignum t len) = { SE.to = mk_to_nat_mont_ll_comm_monoid n mu; SE.one = bn_almost_mont_one #t #len n mu; SE.mul = bn_almost_mont_mul #t #len n mu; SE.sqr = bn_almost_mont_sqr #t #len n mu; } /////////////////////////////////////////////////////////////////////////////// noextract let bn_exp_almost_mont_st (t:limb_t) (len:BN.bn_len t) = n:lbignum t len -> mu:limb t{BM.bn_mont_pre n mu} -> aM:ME.bn_mont_t n -> bBits:size_nat -> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} -> Pure (lbignum t len) (requires True) (ensures fun resM -> let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in bn_v resM % bn_v n == LE.pow k (bn_v aM) (bn_v b)) // no diff between vartime and consttime at the spec level val bn_exp_almost_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len let bn_exp_almost_mont_bm_vartime #t #len n mu aM bBits b = let k1 = mk_bn_almost_mont_concrete_ops n mu in let k = k1.SE.to.SE.comm_monoid in let resM = SE.exp_rl k1 aM bBits (bn_v b) in //assert (bn_v resM % bn_v n == LE.exp_rl k (bn_v aM % bn_v n) bBits (bn_v b)); SE.exp_rl_lemma k1 aM bBits (bn_v b); LE.exp_rl_lemma k (bn_v aM % bn_v n) bBits (bn_v b); //assert (bn_v resM % bn_v n == LE.pow k (bn_v aM % bn_v n) (bn_v b)); E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); resM val bn_exp_almost_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len let bn_exp_almost_mont_bm_consttime #t #len n mu aM bBits b = let k1 = mk_bn_almost_mont_concrete_ops n mu in let k = k1.SE.to.SE.comm_monoid in SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b); LE.exp_mont_ladder_swap_lemma k (bn_v aM % bn_v n) bBits (bn_v b); LE.exp_mont_ladder_lemma k (bn_v aM % bn_v n) bBits (bn_v b); E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); SE.exp_mont_ladder_swap k1 aM bBits (bn_v b) val bn_exp_almost_mont_fw: #t:limb_t -> #len:BN.bn_len t -> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} -> bn_exp_almost_mont_st t len
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Exponentiation.Lemmas.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.MontExponentiation.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.AlmostMontgomery", "short_module": "BA" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Exponentiation.Lemmas", "short_module": "E" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum.Definitions", "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": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: Lib.IntTypes.size_pos{l < Lib.IntTypes.bits t /\ Prims.pow2 l * len <= Lib.IntTypes.max_size_t} -> Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t len
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.Bignum.Definitions.limb_t", "Hacl.Spec.Bignum.bn_len", "Lib.IntTypes.size_pos", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.bits", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Prims.pow2", "Lib.IntTypes.max_size_t", "Hacl.Spec.Bignum.Definitions.lbignum", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Montgomery.bn_mont_pre", "Hacl.Spec.Bignum.MontExponentiation.bn_mont_t", "Lib.IntTypes.size_nat", "Hacl.Spec.Bignum.Definitions.blocks0", "Hacl.Spec.Bignum.Definitions.bn_v", "Spec.Exponentiation.exp_fw", "Prims.unit", "Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_mod_base", "Lib.IntTypes.v", "Lib.IntTypes.SEC", "Lib.Exponentiation.exp_fw_lemma", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec", "Spec.Exponentiation.__proj__Mkconcrete_ops__item__to", "Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid", "Prims.op_Modulus", "Spec.Exponentiation.exp_fw_lemma", "Spec.Exponentiation.concrete_ops", "Hacl.Spec.Bignum.AlmostMontExponentiation.mk_bn_almost_mont_concrete_ops" ]
[]
false
false
false
false
false
let bn_exp_almost_mont_fw #t #len l n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in SE.exp_fw_lemma k1 aM bBits (bn_v b) l; LE.exp_fw_lemma k1.SE.to.SE.comm_monoid (bn_v aM % bn_v n) bBits (bn_v b) l; E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b); SE.exp_fw k1 aM bBits (bn_v b) l
false
Steel.ST.GenElim1.fst
Steel.ST.GenElim1.compute_gen_elim_nondep_correct2
val compute_gen_elim_nondep_correct2 (i0: gen_elim_i) (t1 t2: Type) : Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
val compute_gen_elim_nondep_correct2 (i0: gen_elim_i) (t1 t2: Type) : Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2])
let compute_gen_elim_nondep_correct2 (i0: gen_elim_i) (t1 t2: Type) : Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2]) = fun q post intro _ -> intro _; rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ()))))); let x1 = elim_exists' () in let x2 = elim_exists' () in let res = Mktuple2 x1 x2 in elim_pure _; rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ())); res
{ "file_name": "lib/steel/Steel.ST.GenElim1.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 7, "end_line": 511, "start_col": 0, "start_line": 499 }
module Steel.ST.GenElim1 let gen_elim_f (p: vprop) (a: Type) (q: (a -> vprop)) (post: (a -> prop)) : Tot Type = ((opened: inames) -> STGhost a opened p q True post) module U = FStar.Universe let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type = gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i) let compute_gen_unit_elim_f_id (v: vprop) : Tot (gen_unit_elim_t (GUEId v)) = fun _ -> noop (); U.raise_val () let compute_gen_unit_elim_f_pure (p: prop) : Tot (gen_unit_elim_t (GUEPure p)) = fun _ -> rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p); elim_pure p; U.raise_val () let compute_gen_unit_elim_f_star (i1 i2: gen_unit_elim_i) (f1: gen_unit_elim_t i1) (f2: gen_unit_elim_t i2) : Tot (gen_unit_elim_t (GUEStar i1 i2)) = fun _ -> rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2); let _ = f1 _ in let _ = f2 _ in rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2)); U.raise_val () let rec compute_gen_unit_elim_f (i: gen_unit_elim_i) : GTot (gen_unit_elim_t i) = match i returns (gen_unit_elim_t i) with | GUEId v -> compute_gen_unit_elim_f_id v | GUEPure p -> compute_gen_unit_elim_f_pure p | GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2) let gen_elim_t (i: gen_elim_i) : Tot Type = gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i) let compute_gen_elim_f_unit (i: gen_unit_elim_i) : GTot (gen_elim_t (GEUnit i)) = compute_gen_unit_elim_f i let compute_gen_elim_f_star_l (i1: gen_elim_i) (f1: gen_elim_t i1) (i2: gen_unit_elim_i) : GTot (gen_elim_t (GEStarL i1 i2)) = let f2 = compute_gen_unit_elim_f i2 in fun _ -> rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2); let res = f1 _ in let _ = f2 _ in let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res'); res' let compute_gen_elim_f_star_r (i1: gen_unit_elim_i) (i2: gen_elim_i) (f2: gen_elim_t i2) : GTot (gen_elim_t (GEStarR i1 i2)) = let f1 = compute_gen_unit_elim_f i1 in fun _ -> rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2); let _ = f1 _ in let res = f2 _ in let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res'); res' let compute_gen_elim_f_star (i1: gen_elim_i) (f1: gen_elim_t i1) (i2: gen_elim_i) (f2: gen_elim_t i2) : GTot (gen_elim_t (GEStar i1 i2)) = fun _ -> rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2); let res1 = f1 _ in let res2 = f2 _ in let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res); res let compute_gen_elim_f_exists_no_abs0 (a: Type0) (body: (a -> vprop)) : GTot (gen_elim_t (GEExistsNoAbs0 body)) = fun _ -> rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body); let gres = elim_exists () in let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res); res let rewrite_with_trefl (#opened:_) (p q:vprop) : STGhost unit opened p (fun _ -> q) (requires T.with_tactic T.trefl (p == q)) (ensures fun _ -> True) = rewrite p q let compute_gen_elim_f_exists_unit0 (a: Type0) (body: a -> gen_unit_elim_i) : Tot (gen_elim_t (GEExistsUnit0 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x))); let gres = elim_exists () in let _ = compute_gen_unit_elim_f (body gres) _ in let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res); res let compute_gen_elim_f_exists0 (a: Type0) (body: a -> gen_elim_i) (f: (x: a) -> GTot (gen_elim_t (body x))) : Tot (gen_elim_t (GEExists0 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x))); let gres1 = elim_exists () in let gres2 = f gres1 _ in let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res); res let compute_gen_elim_f_exists_no_abs1 (a: Type) (body: (a -> vprop)) : GTot (gen_elim_t (GEExistsNoAbs1 body)) = fun _ -> rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body); let gres = elim_exists () in let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res); res let compute_gen_elim_f_exists_unit1 (a: Type) (body: a -> gen_unit_elim_i) : Tot (gen_elim_t (GEExistsUnit1 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x))); let gres = elim_exists () in let _ = compute_gen_unit_elim_f (body gres) _ in let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res); res let compute_gen_elim_f_exists1 (a: Type) (body: a -> gen_elim_i) (f: (x: a) -> GTot (gen_elim_t (body x))) : Tot (gen_elim_t (GEExists1 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x))); let gres1 = elim_exists () in let gres2 = f gres1 _ in let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res); res let rec compute_gen_elim_f (i: gen_elim_i) : GTot (gen_elim_t i) = match i returns (gen_elim_t i) with | GEUnit i -> compute_gen_elim_f_unit i | GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2 | GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2) | GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2) | GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body | GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body | GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x)) | GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body | GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body | GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x)) let rec tele_p (x: gen_elim_tele) : Tot vprop = match x with | TRet v p -> v `star` pure p | TExists ty body -> exists_ (fun x -> tele_p (body x)) let elim_exists' (#a:Type) (#opened_invariants:_) (#p:a -> vprop) (_:unit) : STGhostT (a) opened_invariants (exists_ p) (fun x -> p x) = let gx = elim_exists () in let x = Ghost.reveal gx in rewrite (p gx) (p x); x let vprop_rewrite (from to: vprop) : Tot Type = gen_elim_f from unit (fun _ -> to) (fun _ -> True) let tele_star_vprop_correct_ret (v': vprop) (p': prop) (v: vprop) (p: prop) : Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p))) = fun _ -> elim_pure p; rewrite (tele_p _) (v' `star` pure p'); elim_pure p'; intro_pure (p /\ p'); rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _) let tele_star_vprop_correct_exists (v: vprop) (p: prop) (ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p)))) : Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p))) = fun _ -> rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x))); let x = elim_exists' () in ih x _; intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p)); rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _) let rec tele_star_vprop_correct (i: gen_elim_tele) (v: vprop) (p: prop) : GTot (vprop_rewrite (tele_p i `star` v `star` pure p) (tele_p (tele_star_vprop i v p)) ) = match i returns vprop_rewrite (tele_p i `star` v `star` pure p) (tele_p (tele_star_vprop i v p)) with | TRet v' p' -> tele_star_vprop_correct_ret v' p' v p | TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p) let tele_star_correct_ret_l (v1: vprop) (p1: prop) (i2: gen_elim_tele) : Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2))) = fun _ -> rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1); tele_star_vprop_correct i2 v1 p1 _; rewrite (tele_p _) (tele_p _) let tele_star_correct_ret_r (i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop) : Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2))) = fun _ -> rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2); tele_star_vprop_correct i1 v2 p2 _; rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2)) let tele_star_correct_exists (ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele) (ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2)))) : Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2)))) = fun _ -> rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1))); let x1 = elim_exists' () in rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2))); let x2 = elim_exists' () in ih x1 x2 _; intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))); intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)))); rewrite_with_trefl (exists_ _) (tele_p _) let rec tele_star_correct (i1 i2: gen_elim_tele) : GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2))) = match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with | TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2 | TExists ty1 f1 -> begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with | TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2 | TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2)) end [@@noextract_to "Plugin" ] let ge_to_tele_t (i: gen_elim_i) : Tot Type = vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i)) let compute_gen_elim_tele_correct_unit (v: gen_unit_elim_i) : Tot (ge_to_tele_t (GEUnit v)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v); let _ = compute_gen_unit_elim_f v _ in intro_pure (compute_gen_unit_elim_post v); rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _) let compute_gen_elim_tele_correct_star_l (l: gen_elim_i) (ihl: ge_to_tele_t l) (ru: gen_unit_elim_i) : Tot (ge_to_tele_t (GEStarL l ru)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru); ihl _; let _ = compute_gen_unit_elim_f ru _ in intro_pure (compute_gen_unit_elim_post ru); tele_star_vprop_correct _ _ _ _; rewrite_with_trefl (tele_p _) (tele_p _) let compute_gen_elim_tele_correct_star_r (lu: gen_unit_elim_i) (r: gen_elim_i) (ihr: ge_to_tele_t r) : Tot (ge_to_tele_t (GEStarR lu r)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r); ihr _; let _ = compute_gen_unit_elim_f lu _ in intro_pure (compute_gen_unit_elim_post lu); tele_star_vprop_correct _ _ _ _; rewrite_with_trefl (tele_p _) (tele_p _) let compute_gen_elim_tele_correct_star (l: gen_elim_i) (ihl: ge_to_tele_t l) (r: gen_elim_i) (ihr: ge_to_tele_t r) : Tot (ge_to_tele_t (GEStar l r)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r); ihl _; ihr _; tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _; rewrite_with_trefl (tele_p _) (tele_p _) let compute_gen_elim_tele_correct_exists_no_abs0 (ty: _) (body: ty -> vprop) : Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ body); let x = elim_exists' () in intro_pure True; rewrite (body x) (body (U.downgrade_val (U.raise_val x))); intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True); rewrite_with_trefl (exists_ _) (tele_p _) let compute_gen_elim_tele_correct_exists_unit0 (ty: _) (body: ty -> gen_unit_elim_i) : Tot (ge_to_tele_t (GEExistsUnit0 #ty body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x))); let x = elim_exists' () in let _ = compute_gen_unit_elim_f (body x) _ in intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x)))); rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x)))); intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x)))); rewrite_with_trefl (exists_ _) (tele_p _) let compute_gen_elim_tele_correct_exists0 (ty: _) (body: ty -> gen_elim_i) (ih: (x: ty) -> GTot (ge_to_tele_t (body x))) : Tot (ge_to_tele_t (GEExists0 #ty body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x))); let x = elim_exists' () in ih x _; rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x))))); intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x)))); rewrite_with_trefl (exists_ _) (tele_p _) let compute_gen_elim_tele_correct_exists_no_abs1 (ty: _) (body: ty -> vprop) : Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ body); let x = elim_exists' () in intro_pure True; intro_exists x (fun x -> body x `star` pure True); rewrite_with_trefl (exists_ _) (tele_p _) let compute_gen_elim_tele_correct_exists_unit1 (ty: _) (body: ty -> gen_unit_elim_i) : Tot (ge_to_tele_t (GEExistsUnit1 #ty body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x))); let x = elim_exists' () in let _ = compute_gen_unit_elim_f (body x) _ in intro_pure (compute_gen_unit_elim_post (body x)); intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x))); rewrite_with_trefl (exists_ _) (tele_p _) let compute_gen_elim_tele_correct_exists1 (ty: _) (body: ty -> gen_elim_i) (ih: (x: ty) -> GTot (ge_to_tele_t (body x))) : Tot (ge_to_tele_t (GEExists1 #ty body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x))); let x = elim_exists' () in ih x _; intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x))); rewrite_with_trefl (exists_ _) (tele_p _) let rec compute_gen_elim_tele_correct (x: gen_elim_i) : GTot (ge_to_tele_t x) = match x returns ge_to_tele_t x with | GEUnit v -> compute_gen_elim_tele_correct_unit v | GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru | GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r) | GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r) | GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body | GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body | GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x)) | GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body | GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body | GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x)) let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) = match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with | [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ())) | t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)) let rec gen_elim_nondep_sem_correct (ty: list (Type u#a)) : Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma (tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post) ) = match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma (tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post) ) with | [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ()))) | ta :: tq -> fun q post -> let phi (x: ta) : Lemma (tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x)) = gen_elim_nondep_sem_correct tq (q x) (post x) in Classical.forall_intro phi; let prf () : Lemma (exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))) = exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x)) in assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x)))); assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))); prf () let compute_gen_elim_nondep_correct_t (i0: gen_elim_i) (ty: list (Type u#1)) : Tot Type = (q: _) -> (post: _) -> (intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) -> GTot (gen_elim_f (compute_gen_elim_p i0) (compute_gen_elim_nondep_a' ty) (fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ())) (fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ())) ) let compute_gen_elim_nondep_correct0 (i0: gen_elim_i) : Tot (compute_gen_elim_nondep_correct_t i0 []) = fun q post intro _ -> intro _; rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ()))); let res = U.raise_val () in elim_pure _; rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ())); res let compute_gen_elim_nondep_correct1 (i0: gen_elim_i) (t1: Type) : Tot (compute_gen_elim_nondep_correct_t i0 [t1]) = fun q post intro _ -> intro _; rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ())))); let res = elim_exists' () in elim_pure _; rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ())); res
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.GenElim1.fst" }
[ { "abbrev": true, "full_module": "FStar.Universe", "short_module": "U" }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "Steel.ST.GenElim1.Base", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i0: Steel.ST.GenElim1.Base.gen_elim_i -> t1: Type -> t2: Type -> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0 [t1; t2]
Prims.Tot
[ "total" ]
[]
[ "Steel.ST.GenElim1.Base.gen_elim_i", "Steel.ST.GenElim1.Base.curried_function_type", "Prims.Cons", "Prims.Nil", "FStar.Universe.raise_t", "Prims.unit", "Steel.Effect.Common.vprop", "Prims.prop", "Steel.ST.GenElim1.vprop_rewrite", "Steel.ST.GenElim1.Base.compute_gen_elim_p", "Steel.ST.GenElim1.gen_elim_nondep_p", "Steel.Memory.inames", "Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'", "Steel.ST.GenElim1.rewrite_with_trefl", "FStar.Universe.raise_val", "Steel.ST.GenElim1.Base.compute_uncurry", "Steel.ST.GenElim1.Base.compute_gen_elim_p'", "Steel.ST.Util.elim_pure", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "Steel.ST.GenElim1.elim_exists'", "Steel.Effect.Common.VStar", "Steel.ST.Util.pure", "Steel.ST.Util.exists_", "Steel.Effect.Common.star", "Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t" ]
[]
false
false
false
false
false
let compute_gen_elim_nondep_correct2 (i0: gen_elim_i) (t1 t2: Type) : Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2]) =
fun q post intro _ -> intro _; rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> (q x1 x2 (U.raise_val ())) `star` (pure (post x1 x2 (U.raise_val ())))))); let x1 = elim_exists' () in let x2 = elim_exists' () in let res = Mktuple2 x1 x2 in elim_pure _; rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ())); res
false
Steel.Primitive.ForkJoin.fst
Steel.Primitive.ForkJoin.spawn
val spawn: #p: vprop -> #q: vprop -> $f: (unit -> SteelT unit p (fun _ -> q)) -> t: thread q -> unit -> SteelT unit p (fun _ -> emp)
val spawn: #p: vprop -> #q: vprop -> $f: (unit -> SteelT unit p (fun _ -> q)) -> t: thread q -> unit -> SteelT unit p (fun _ -> emp)
let spawn (#p #q:vprop) ($f: (unit -> SteelT unit p (fun _ -> q))) (t:thread q) (_:unit) : SteelT unit p (fun _ -> emp) = let b = acquire t in f (); finish t b
{ "file_name": "lib/steel/Steel.Primitive.ForkJoin.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 14, "end_line": 83, "start_col": 0, "start_line": 76 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Primitive.ForkJoin open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module L = Steel.SpinLock open Steel.FractionalPermission open Steel.Reference //////////////////////////////////////////////////////////////////////////////// let maybe_p (p:vprop) (v:bool) = if v then p else emp [@@__reduce__] let lock_inv_pred (r:ref bool) (p:vprop) (v:bool) : vprop = pts_to r full_perm v `star` maybe_p p v let lock_inv (r:ref bool) (p:vprop) : vprop = h_exists (lock_inv_pred r p) noeq type thread (p:vprop) = { r:ref bool; l:L.lock (lock_inv r p) } let intro_maybe_p_false (p:vprop) : SteelT unit emp (fun _ -> maybe_p p false) = rewrite_slprop emp (maybe_p p false) (fun _ -> ()) let intro_maybe_p_true (p:vprop) : SteelT unit p (fun _ -> maybe_p p true) = rewrite_slprop p (maybe_p p true) (fun _ -> ()) let new_thread (p:vprop) : SteelT (thread p) emp (fun _ -> emp) = let r = alloc_pt false in intro_maybe_p_false p; intro_exists false (lock_inv_pred r p); let l = L.new_lock (lock_inv r p) in let t = {r = r; l = l} in t let finish (#p:vprop) (t:thread p) (v:bool) : SteelT unit (pts_to t.r full_perm v `star` p) (fun _ -> emp) = write_pt t.r true; intro_maybe_p_true p; intro_exists true (lock_inv_pred t.r p); L.release t.l let acquire (#p:vprop) (t:thread p) : SteelT bool emp (fun b -> pts_to t.r full_perm b) = L.acquire t.l; let b = read_refine_pt #_ #full_perm (maybe_p p) t.r in drop (maybe_p p b); return b
{ "checked_file": "/", "dependencies": [ "Steel.SpinLock.fsti.checked", "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.Primitive.ForkJoin.fst" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.SpinLock", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
$f: (_: Prims.unit -> Steel.Effect.SteelT Prims.unit) -> t: Steel.Primitive.ForkJoin.thread q -> _: Prims.unit -> Steel.Effect.SteelT Prims.unit
Steel.Effect.SteelT
[]
[]
[ "Steel.Effect.Common.vprop", "Prims.unit", "Steel.Primitive.ForkJoin.thread", "Steel.Primitive.ForkJoin.finish", "Prims.bool", "Steel.Primitive.ForkJoin.acquire", "Steel.Effect.Common.emp" ]
[]
false
true
false
false
false
let spawn (#p: vprop) (#q: vprop) ($f: (unit -> SteelT unit p (fun _ -> q))) (t: thread q) (_: unit) : SteelT unit p (fun _ -> emp) =
let b = acquire t in f (); finish t b
false
Steel.Primitive.ForkJoin.fst
Steel.Primitive.ForkJoin.fork
val fork (#p #q #r #s:vprop) (f: (unit -> SteelT unit p (fun _ -> q))) (g: (thread q -> unit -> SteelT unit r (fun _ -> s))) : SteelT unit (p `star` r) (fun _ -> s)
val fork (#p #q #r #s:vprop) (f: (unit -> SteelT unit p (fun _ -> q))) (g: (thread q -> unit -> SteelT unit r (fun _ -> s))) : SteelT unit (p `star` r) (fun _ -> s)
let fork (#p #q #r #s:vprop) (f: (unit -> SteelT unit p (fun _ -> q))) (g: (thread q -> unit -> SteelT unit r (fun _ -> s))) : SteelT unit (p `star` r) (fun _ -> s) = let t : thread q = new_thread q in let _ = par (spawn f t) (g t) in ()
{ "file_name": "lib/steel/Steel.Primitive.ForkJoin.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 6, "end_line": 91, "start_col": 0, "start_line": 85 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Primitive.ForkJoin open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module L = Steel.SpinLock open Steel.FractionalPermission open Steel.Reference //////////////////////////////////////////////////////////////////////////////// let maybe_p (p:vprop) (v:bool) = if v then p else emp [@@__reduce__] let lock_inv_pred (r:ref bool) (p:vprop) (v:bool) : vprop = pts_to r full_perm v `star` maybe_p p v let lock_inv (r:ref bool) (p:vprop) : vprop = h_exists (lock_inv_pred r p) noeq type thread (p:vprop) = { r:ref bool; l:L.lock (lock_inv r p) } let intro_maybe_p_false (p:vprop) : SteelT unit emp (fun _ -> maybe_p p false) = rewrite_slprop emp (maybe_p p false) (fun _ -> ()) let intro_maybe_p_true (p:vprop) : SteelT unit p (fun _ -> maybe_p p true) = rewrite_slprop p (maybe_p p true) (fun _ -> ()) let new_thread (p:vprop) : SteelT (thread p) emp (fun _ -> emp) = let r = alloc_pt false in intro_maybe_p_false p; intro_exists false (lock_inv_pred r p); let l = L.new_lock (lock_inv r p) in let t = {r = r; l = l} in t let finish (#p:vprop) (t:thread p) (v:bool) : SteelT unit (pts_to t.r full_perm v `star` p) (fun _ -> emp) = write_pt t.r true; intro_maybe_p_true p; intro_exists true (lock_inv_pred t.r p); L.release t.l let acquire (#p:vprop) (t:thread p) : SteelT bool emp (fun b -> pts_to t.r full_perm b) = L.acquire t.l; let b = read_refine_pt #_ #full_perm (maybe_p p) t.r in drop (maybe_p p b); return b let spawn (#p #q:vprop) ($f: (unit -> SteelT unit p (fun _ -> q))) (t:thread q) (_:unit) : SteelT unit p (fun _ -> emp) = let b = acquire t in f (); finish t b
{ "checked_file": "/", "dependencies": [ "Steel.SpinLock.fsti.checked", "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.Primitive.ForkJoin.fst" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.SpinLock", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: Prims.unit -> Steel.Effect.SteelT Prims.unit) -> g: (_: Steel.Primitive.ForkJoin.thread q -> _: Prims.unit -> Steel.Effect.SteelT Prims.unit) -> Steel.Effect.SteelT Prims.unit
Steel.Effect.SteelT
[]
[]
[ "Steel.Effect.Common.vprop", "Prims.unit", "Steel.Primitive.ForkJoin.thread", "FStar.Pervasives.Native.tuple2", "Steel.Effect.par", "Steel.Effect.Common.emp", "Steel.Primitive.ForkJoin.spawn", "Steel.Primitive.ForkJoin.new_thread", "Steel.Effect.Common.star" ]
[]
false
true
false
false
false
let fork (#p #q #r #s: vprop) (f: (unit -> SteelT unit p (fun _ -> q))) (g: (thread q -> unit -> SteelT unit r (fun _ -> s))) : SteelT unit (p `star` r) (fun _ -> s) =
let t:thread q = new_thread q in let _ = par (spawn f t) (g t) in ()
false
Steel.ST.GenElim1.fst
Steel.ST.GenElim1.tele_star_correct_exists
val tele_star_correct_exists (ty1: _) (f1: (ty1 -> gen_elim_tele)) (ty2: _) (f2: (ty2 -> gen_elim_tele)) (ih: (x1: ty1 -> x2: ty2 -> GTot (vprop_rewrite ((tele_p (f1 x1)) `star` (tele_p (f2 x2))) (tele_p ((f1 x1) `tele_star` (f2 x2)))))) : Tot (vprop_rewrite ((tele_p (TExists ty1 f1)) `star` (tele_p (TExists ty2 f2))) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
val tele_star_correct_exists (ty1: _) (f1: (ty1 -> gen_elim_tele)) (ty2: _) (f2: (ty2 -> gen_elim_tele)) (ih: (x1: ty1 -> x2: ty2 -> GTot (vprop_rewrite ((tele_p (f1 x1)) `star` (tele_p (f2 x2))) (tele_p ((f1 x1) `tele_star` (f2 x2)))))) : Tot (vprop_rewrite ((tele_p (TExists ty1 f1)) `star` (tele_p (TExists ty2 f2))) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2))))
let tele_star_correct_exists (ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele) (ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2)))) : Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2)))) = fun _ -> rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1))); let x1 = elim_exists' () in rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2))); let x2 = elim_exists' () in ih x1 x2 _; intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))); intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)))); rewrite_with_trefl (exists_ _) (tele_p _)
{ "file_name": "lib/steel/Steel.ST.GenElim1.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 43, "end_line": 275, "start_col": 0, "start_line": 263 }
module Steel.ST.GenElim1 let gen_elim_f (p: vprop) (a: Type) (q: (a -> vprop)) (post: (a -> prop)) : Tot Type = ((opened: inames) -> STGhost a opened p q True post) module U = FStar.Universe let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type = gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i) let compute_gen_unit_elim_f_id (v: vprop) : Tot (gen_unit_elim_t (GUEId v)) = fun _ -> noop (); U.raise_val () let compute_gen_unit_elim_f_pure (p: prop) : Tot (gen_unit_elim_t (GUEPure p)) = fun _ -> rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p); elim_pure p; U.raise_val () let compute_gen_unit_elim_f_star (i1 i2: gen_unit_elim_i) (f1: gen_unit_elim_t i1) (f2: gen_unit_elim_t i2) : Tot (gen_unit_elim_t (GUEStar i1 i2)) = fun _ -> rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2); let _ = f1 _ in let _ = f2 _ in rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2)); U.raise_val () let rec compute_gen_unit_elim_f (i: gen_unit_elim_i) : GTot (gen_unit_elim_t i) = match i returns (gen_unit_elim_t i) with | GUEId v -> compute_gen_unit_elim_f_id v | GUEPure p -> compute_gen_unit_elim_f_pure p | GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2) let gen_elim_t (i: gen_elim_i) : Tot Type = gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i) let compute_gen_elim_f_unit (i: gen_unit_elim_i) : GTot (gen_elim_t (GEUnit i)) = compute_gen_unit_elim_f i let compute_gen_elim_f_star_l (i1: gen_elim_i) (f1: gen_elim_t i1) (i2: gen_unit_elim_i) : GTot (gen_elim_t (GEStarL i1 i2)) = let f2 = compute_gen_unit_elim_f i2 in fun _ -> rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2); let res = f1 _ in let _ = f2 _ in let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res'); res' let compute_gen_elim_f_star_r (i1: gen_unit_elim_i) (i2: gen_elim_i) (f2: gen_elim_t i2) : GTot (gen_elim_t (GEStarR i1 i2)) = let f1 = compute_gen_unit_elim_f i1 in fun _ -> rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2); let _ = f1 _ in let res = f2 _ in let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res'); res' let compute_gen_elim_f_star (i1: gen_elim_i) (f1: gen_elim_t i1) (i2: gen_elim_i) (f2: gen_elim_t i2) : GTot (gen_elim_t (GEStar i1 i2)) = fun _ -> rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2); let res1 = f1 _ in let res2 = f2 _ in let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res); res let compute_gen_elim_f_exists_no_abs0 (a: Type0) (body: (a -> vprop)) : GTot (gen_elim_t (GEExistsNoAbs0 body)) = fun _ -> rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body); let gres = elim_exists () in let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res); res let rewrite_with_trefl (#opened:_) (p q:vprop) : STGhost unit opened p (fun _ -> q) (requires T.with_tactic T.trefl (p == q)) (ensures fun _ -> True) = rewrite p q let compute_gen_elim_f_exists_unit0 (a: Type0) (body: a -> gen_unit_elim_i) : Tot (gen_elim_t (GEExistsUnit0 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x))); let gres = elim_exists () in let _ = compute_gen_unit_elim_f (body gres) _ in let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res); res let compute_gen_elim_f_exists0 (a: Type0) (body: a -> gen_elim_i) (f: (x: a) -> GTot (gen_elim_t (body x))) : Tot (gen_elim_t (GEExists0 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x))); let gres1 = elim_exists () in let gres2 = f gres1 _ in let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res); res let compute_gen_elim_f_exists_no_abs1 (a: Type) (body: (a -> vprop)) : GTot (gen_elim_t (GEExistsNoAbs1 body)) = fun _ -> rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body); let gres = elim_exists () in let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res); res let compute_gen_elim_f_exists_unit1 (a: Type) (body: a -> gen_unit_elim_i) : Tot (gen_elim_t (GEExistsUnit1 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x))); let gres = elim_exists () in let _ = compute_gen_unit_elim_f (body gres) _ in let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res); res let compute_gen_elim_f_exists1 (a: Type) (body: a -> gen_elim_i) (f: (x: a) -> GTot (gen_elim_t (body x))) : Tot (gen_elim_t (GEExists1 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x))); let gres1 = elim_exists () in let gres2 = f gres1 _ in let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res); res let rec compute_gen_elim_f (i: gen_elim_i) : GTot (gen_elim_t i) = match i returns (gen_elim_t i) with | GEUnit i -> compute_gen_elim_f_unit i | GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2 | GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2) | GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2) | GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body | GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body | GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x)) | GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body | GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body | GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x)) let rec tele_p (x: gen_elim_tele) : Tot vprop = match x with | TRet v p -> v `star` pure p | TExists ty body -> exists_ (fun x -> tele_p (body x)) let elim_exists' (#a:Type) (#opened_invariants:_) (#p:a -> vprop) (_:unit) : STGhostT (a) opened_invariants (exists_ p) (fun x -> p x) = let gx = elim_exists () in let x = Ghost.reveal gx in rewrite (p gx) (p x); x let vprop_rewrite (from to: vprop) : Tot Type = gen_elim_f from unit (fun _ -> to) (fun _ -> True) let tele_star_vprop_correct_ret (v': vprop) (p': prop) (v: vprop) (p: prop) : Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p))) = fun _ -> elim_pure p; rewrite (tele_p _) (v' `star` pure p'); elim_pure p'; intro_pure (p /\ p'); rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _) let tele_star_vprop_correct_exists (v: vprop) (p: prop) (ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p)))) : Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p))) = fun _ -> rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x))); let x = elim_exists' () in ih x _; intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p)); rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _) let rec tele_star_vprop_correct (i: gen_elim_tele) (v: vprop) (p: prop) : GTot (vprop_rewrite (tele_p i `star` v `star` pure p) (tele_p (tele_star_vprop i v p)) ) = match i returns vprop_rewrite (tele_p i `star` v `star` pure p) (tele_p (tele_star_vprop i v p)) with | TRet v' p' -> tele_star_vprop_correct_ret v' p' v p | TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p) let tele_star_correct_ret_l (v1: vprop) (p1: prop) (i2: gen_elim_tele) : Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2))) = fun _ -> rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1); tele_star_vprop_correct i2 v1 p1 _; rewrite (tele_p _) (tele_p _) let tele_star_correct_ret_r (i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop) : Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2))) = fun _ -> rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2); tele_star_vprop_correct i1 v2 p2 _; rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.GenElim1.fst" }
[ { "abbrev": true, "full_module": "FStar.Universe", "short_module": "U" }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "Steel.ST.GenElim1.Base", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ty1: Type -> f1: (_: ty1 -> Steel.ST.GenElim1.Base.gen_elim_tele) -> ty2: Type -> f2: (_: ty2 -> Steel.ST.GenElim1.Base.gen_elim_tele) -> ih: (x1: ty1 -> x2: ty2 -> Prims.GTot (Steel.ST.GenElim1.vprop_rewrite (Steel.Effect.Common.star (Steel.ST.GenElim1.tele_p (f1 x1)) (Steel.ST.GenElim1.tele_p (f2 x2))) (Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.tele_star (f1 x1) (f2 x2))))) -> Steel.ST.GenElim1.vprop_rewrite (Steel.Effect.Common.star (Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.TExists ty1 f1)) (Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.TExists ty2 f2))) (Steel.ST.GenElim1.tele_p (Steel.ST.GenElim1.Base.tele_star (Steel.ST.GenElim1.Base.TExists ty1 f1) (Steel.ST.GenElim1.Base.TExists ty2 f2)))
Prims.Tot
[ "total" ]
[]
[ "Steel.ST.GenElim1.Base.gen_elim_tele", "Steel.ST.GenElim1.vprop_rewrite", "Steel.Effect.Common.star", "Steel.ST.GenElim1.tele_p", "Steel.ST.GenElim1.Base.tele_star", "Steel.Memory.inames", "Steel.ST.GenElim1.rewrite_with_trefl", "Steel.ST.Util.exists_", "Steel.Effect.Common.vprop", "Steel.ST.GenElim1.Base.TExists", "Prims.unit", "Steel.ST.Util.intro_exists", "Steel.ST.GenElim1.elim_exists'" ]
[]
false
false
false
false
false
let tele_star_correct_exists (ty1: _) (f1: (ty1 -> gen_elim_tele)) (ty2: _) (f2: (ty2 -> gen_elim_tele)) (ih: (x1: ty1 -> x2: ty2 -> GTot (vprop_rewrite ((tele_p (f1 x1)) `star` (tele_p (f2 x2))) (tele_p ((f1 x1) `tele_star` (f2 x2)))))) : Tot (vprop_rewrite ((tele_p (TExists ty1 f1)) `star` (tele_p (TExists ty2 f2))) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2)))) =
fun _ -> rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1))); let x1 = elim_exists' () in rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2))); let x2 = elim_exists' () in ih x1 x2 _; intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))); intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)))); rewrite_with_trefl (exists_ _) (tele_p _)
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.protocol
val protocol : a: Type0 -> Type
let protocol a = p:prot a { ok p }
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 34, "end_line": 35, "start_col": 0, "start_line": 35 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type0 -> Type
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.prot", "Steel.Channel.Protocol.ok" ]
[]
false
false
false
true
true
let protocol a =
p: prot a {ok p}
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.ok
val ok : p: Steel.Channel.Protocol.prot a -> Type0
let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 41, "end_line": 33, "start_col": 0, "start_line": 29 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Steel.Channel.Protocol.prot a -> Type0
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.prot", "Prims.l_True", "Steel.Channel.Protocol.tag", "Prims.l_Forall", "Steel.Channel.Protocol.ok", "Prims.bool", "Prims.l_and", "Prims.b2t", "Steel.Channel.Protocol.uu___is_Msg" ]
[ "recursion" ]
false
false
false
true
true
let rec ok #a (p: prot a) =
match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.flip_tag
val flip_tag : _: Steel.Channel.Protocol.tag -> Steel.Channel.Protocol.tag
let flip_tag = function | Send -> Recv | Recv -> Send
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 16, "end_line": 40, "start_col": 0, "start_line": 38 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Steel.Channel.Protocol.tag -> Steel.Channel.Protocol.tag
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.tag", "Steel.Channel.Protocol.Recv", "Steel.Channel.Protocol.Send" ]
[]
false
false
false
true
false
let flip_tag =
function | Send -> Recv | Recv -> Send
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.done
val done : Steel.Channel.Protocol.protocol Prims.unit
let done = return ()
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 20, "end_line": 68, "start_col": 0, "start_line": 68 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Steel.Channel.Protocol.protocol Prims.unit
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.return", "Prims.unit" ]
[]
false
false
false
true
false
let done =
return ()
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.dual
val dual (#a: _) (p: protocol a) : q: protocol a {Msg? p ==> Msg? q}
val dual (#a: _) (p: protocol a) : q: protocol a {Msg? p ==> Msg? q}
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k)
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 50, "end_line": 50, "start_col": 0, "start_line": 42 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Steel.Channel.Protocol.protocol a -> q: Steel.Channel.Protocol.protocol a {Msg? p ==> Msg? q}
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.protocol", "Steel.Channel.Protocol.tag", "Steel.Channel.Protocol.prot", "Steel.Channel.Protocol.Msg", "Steel.Channel.Protocol.flip_tag", "Steel.Channel.Protocol.dual", "Prims.bool", "Steel.Channel.Protocol.DoWhile", "Prims.l_imp", "Prims.b2t", "Steel.Channel.Protocol.uu___is_Msg" ]
[ "recursion" ]
false
false
false
false
false
let rec dual #a (p: protocol a) : q: protocol a {Msg? p ==> Msg? q} =
match p with | Return _ -> p | Msg tag b #a k -> let k: b -> protocol a = fun (x: b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k)
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.finished
val finished (p: protocol 'a) : GTot bool
val finished (p: protocol 'a) : GTot bool
let finished (p:protocol 'a) : GTot bool = Return? (hnf p)
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 58, "end_line": 86, "start_col": 0, "start_line": 86 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *) (* Send an int [x], recv a [y > x] *) let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return () let rec hnf (p:protocol 'a) : (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Steel.Channel.Protocol.protocol 'a -> Prims.GTot Prims.bool
Prims.GTot
[ "sometrivial" ]
[]
[ "Steel.Channel.Protocol.protocol", "Steel.Channel.Protocol.uu___is_Return", "Steel.Channel.Protocol.hnf", "Prims.bool" ]
[]
false
false
false
false
false
let finished (p: protocol 'a) : GTot bool =
Return? (hnf p)
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.xy
val xy:prot unit
val xy:prot unit
let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return ()
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 11, "end_line": 78, "start_col": 0, "start_line": 75 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Steel.Channel.Protocol.prot Prims.unit
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.op_let_Hat", "Prims.int", "Prims.unit", "Steel.Channel.Protocol.send", "Prims.b2t", "Prims.op_GreaterThan", "Steel.Channel.Protocol.recv", "Steel.Channel.Protocol.return", "Steel.Channel.Protocol.protocol" ]
[]
false
false
false
true
false
let xy:prot unit =
let^ x = send int in let^ y = recv (y: int{y > x}) in return ()
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.more_msgs
val more_msgs (p: protocol 'a) : GTot bool
val more_msgs (p: protocol 'a) : GTot bool
let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p)
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 56, "end_line": 87, "start_col": 0, "start_line": 87 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *) (* Send an int [x], recv a [y > x] *) let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return () let rec hnf (p:protocol 'a) : (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Steel.Channel.Protocol.protocol 'a -> Prims.GTot Prims.bool
Prims.GTot
[ "sometrivial" ]
[]
[ "Steel.Channel.Protocol.protocol", "Steel.Channel.Protocol.uu___is_Msg", "Steel.Channel.Protocol.hnf", "Prims.bool" ]
[]
false
false
false
false
false
let more_msgs (p: protocol 'a) : GTot bool =
Msg? (hnf p)
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.return
val return (#a: Type) (x: a) : protocol a
val return (#a: Type) (x: a) : protocol a
let return (#a:Type) (x:a) : protocol a = Return x
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 50, "end_line": 67, "start_col": 0, "start_line": 67 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> Steel.Channel.Protocol.protocol a
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.Return", "Steel.Channel.Protocol.protocol" ]
[]
false
false
false
true
false
let return (#a: Type) (x: a) : protocol a =
Return x
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.bind
val bind (#a #b: _) (p: protocol a) (q: (a -> protocol b)) : protocol b
val bind (#a #b: _) (p: protocol a) (q: (a -> protocol b)) : protocol b
let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q)
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 41, "end_line": 62, "start_col": 0, "start_line": 53 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Steel.Channel.Protocol.protocol a -> q: (_: a -> Steel.Channel.Protocol.protocol b) -> Steel.Channel.Protocol.protocol b
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.protocol", "Steel.Channel.Protocol.tag", "Steel.Channel.Protocol.prot", "Steel.Channel.Protocol.Msg", "Steel.Channel.Protocol.bind", "Prims.bool", "Steel.Channel.Protocol.DoWhile" ]
[ "recursion" ]
false
false
false
true
false
let rec bind #a #b (p: protocol a) (q: (a -> protocol b)) : protocol b =
match p with | Return v -> q v | Msg tag c #a' k -> let k: c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q)
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.recv
val recv (t: Type) : protocol t
val recv (t: Type) : protocol t
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 63, "end_line": 70, "start_col": 0, "start_line": 70 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Type0 -> Steel.Channel.Protocol.protocol t
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.Msg", "Steel.Channel.Protocol.Recv", "Steel.Channel.Protocol.return", "Steel.Channel.Protocol.prot", "Steel.Channel.Protocol.protocol" ]
[]
false
false
false
true
false
let recv (t: Type) : protocol t =
Msg Recv t (fun x -> return x)
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.send
val send (t: Type) : protocol t
val send (t: Type) : protocol t
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 63, "end_line": 69, "start_col": 0, "start_line": 69 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Type0 -> Steel.Channel.Protocol.protocol t
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.Msg", "Steel.Channel.Protocol.Send", "Steel.Channel.Protocol.return", "Steel.Channel.Protocol.prot", "Steel.Channel.Protocol.protocol" ]
[]
false
false
false
true
false
let send (t: Type) : protocol t =
Msg Send t (fun x -> return x)
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.msg_t
val msg_t : p: Steel.Channel.Protocol.protocol Prims.unit -> Type0
let msg_t (p:protocol unit) = next_msg_t p
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 42, "end_line": 150, "start_col": 0, "start_line": 150 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *) (* Send an int [x], recv a [y > x] *) let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return () let rec hnf (p:protocol 'a) : (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p let finished (p:protocol 'a) : GTot bool = Return? (hnf p) let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p) let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x noeq type trace : from:protocol unit -> to:protocol unit -> Type = | Waiting : p:protocol unit -> trace p p | Message : from:protocol unit{more_msgs from} -> x:next_msg_t from -> to:protocol unit -> trace (step from x) to-> trace from to let rec extend (#from #to:protocol unit) (t:trace from to{more_msgs to}) (m:next_msg_t to) : Tot (trace from (step to m)) (decreases t) = match t with | Waiting _ -> Message _ _ _ (Waiting (step to m)) | Message _from x _to tail -> Message _ _ _ (extend tail m) let rec last_step_of (#from #to:protocol unit) (t:trace from to { ~ (Waiting? t) }) : Tot (q:protocol unit & x:next_msg_t q & squash (more_msgs q /\to == step q x)) (decreases t) = match t with | Message _ x _ (Waiting _) -> (| from , x, () |) | Message _ _ _ tail -> last_step_of tail noeq type partial_trace_of (p:protocol unit) = { to:protocol unit; tr:trace p to } module P = FStar.Preorder module R = FStar.ReflexiveTransitiveClosure let next (#p:protocol unit) : P.relation (partial_trace_of p) = fun (t0 t1: partial_trace_of p) -> more_msgs t0.to /\ (exists (msg:next_msg_t t0.to). t1.to == step t0.to msg /\ t1.tr == extend t0.tr msg) let extended_to (#p:protocol unit) : P.preorder (partial_trace_of p) = R.closure (next #p) let extend_partial_trace (#p:protocol unit) (x:partial_trace_of p) (msg:next_msg_t x.to{more_msgs x.to}) : Tot (y:partial_trace_of p{x `extended_to` y}) = { to=_; tr=extend x.tr msg} let more (p:protocol unit) = more_msgs p
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": true, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Steel.Channel.Protocol.protocol Prims.unit -> Type0
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.protocol", "Prims.unit", "Steel.Channel.Protocol.next_msg_t" ]
[]
false
false
false
true
true
let msg_t (p: protocol unit) =
next_msg_t p
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.more
val more : p: Steel.Channel.Protocol.protocol Prims.unit -> Prims.GTot Prims.bool
let more (p:protocol unit) = more_msgs p
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 40, "end_line": 148, "start_col": 0, "start_line": 148 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *) (* Send an int [x], recv a [y > x] *) let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return () let rec hnf (p:protocol 'a) : (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p let finished (p:protocol 'a) : GTot bool = Return? (hnf p) let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p) let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x noeq type trace : from:protocol unit -> to:protocol unit -> Type = | Waiting : p:protocol unit -> trace p p | Message : from:protocol unit{more_msgs from} -> x:next_msg_t from -> to:protocol unit -> trace (step from x) to-> trace from to let rec extend (#from #to:protocol unit) (t:trace from to{more_msgs to}) (m:next_msg_t to) : Tot (trace from (step to m)) (decreases t) = match t with | Waiting _ -> Message _ _ _ (Waiting (step to m)) | Message _from x _to tail -> Message _ _ _ (extend tail m) let rec last_step_of (#from #to:protocol unit) (t:trace from to { ~ (Waiting? t) }) : Tot (q:protocol unit & x:next_msg_t q & squash (more_msgs q /\to == step q x)) (decreases t) = match t with | Message _ x _ (Waiting _) -> (| from , x, () |) | Message _ _ _ tail -> last_step_of tail noeq type partial_trace_of (p:protocol unit) = { to:protocol unit; tr:trace p to } module P = FStar.Preorder module R = FStar.ReflexiveTransitiveClosure let next (#p:protocol unit) : P.relation (partial_trace_of p) = fun (t0 t1: partial_trace_of p) -> more_msgs t0.to /\ (exists (msg:next_msg_t t0.to). t1.to == step t0.to msg /\ t1.tr == extend t0.tr msg) let extended_to (#p:protocol unit) : P.preorder (partial_trace_of p) = R.closure (next #p) let extend_partial_trace (#p:protocol unit) (x:partial_trace_of p) (msg:next_msg_t x.to{more_msgs x.to}) : Tot (y:partial_trace_of p{x `extended_to` y}) = { to=_; tr=extend x.tr msg}
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": true, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Steel.Channel.Protocol.protocol Prims.unit -> Prims.GTot Prims.bool
Prims.GTot
[ "sometrivial" ]
[]
[ "Steel.Channel.Protocol.protocol", "Prims.unit", "Steel.Channel.Protocol.more_msgs", "Prims.bool" ]
[]
false
false
false
false
false
let more (p: protocol unit) =
more_msgs p
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.extension_of
val extension_of : tr: Steel.Channel.Protocol.partial_trace_of p -> Type
let extension_of #p (tr:partial_trace_of p) = ts:partial_trace_of p{tr `extended_to` ts}
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 88, "end_line": 151, "start_col": 0, "start_line": 151 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *) (* Send an int [x], recv a [y > x] *) let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return () let rec hnf (p:protocol 'a) : (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p let finished (p:protocol 'a) : GTot bool = Return? (hnf p) let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p) let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x noeq type trace : from:protocol unit -> to:protocol unit -> Type = | Waiting : p:protocol unit -> trace p p | Message : from:protocol unit{more_msgs from} -> x:next_msg_t from -> to:protocol unit -> trace (step from x) to-> trace from to let rec extend (#from #to:protocol unit) (t:trace from to{more_msgs to}) (m:next_msg_t to) : Tot (trace from (step to m)) (decreases t) = match t with | Waiting _ -> Message _ _ _ (Waiting (step to m)) | Message _from x _to tail -> Message _ _ _ (extend tail m) let rec last_step_of (#from #to:protocol unit) (t:trace from to { ~ (Waiting? t) }) : Tot (q:protocol unit & x:next_msg_t q & squash (more_msgs q /\to == step q x)) (decreases t) = match t with | Message _ x _ (Waiting _) -> (| from , x, () |) | Message _ _ _ tail -> last_step_of tail noeq type partial_trace_of (p:protocol unit) = { to:protocol unit; tr:trace p to } module P = FStar.Preorder module R = FStar.ReflexiveTransitiveClosure let next (#p:protocol unit) : P.relation (partial_trace_of p) = fun (t0 t1: partial_trace_of p) -> more_msgs t0.to /\ (exists (msg:next_msg_t t0.to). t1.to == step t0.to msg /\ t1.tr == extend t0.tr msg) let extended_to (#p:protocol unit) : P.preorder (partial_trace_of p) = R.closure (next #p) let extend_partial_trace (#p:protocol unit) (x:partial_trace_of p) (msg:next_msg_t x.to{more_msgs x.to}) : Tot (y:partial_trace_of p{x `extended_to` y}) = { to=_; tr=extend x.tr msg} let more (p:protocol unit) = more_msgs p let tag_of (p:protocol unit{more p}) : GTot tag = Msg?._0 (hnf p)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": true, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
tr: Steel.Channel.Protocol.partial_trace_of p -> Type
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.protocol", "Prims.unit", "Steel.Channel.Protocol.partial_trace_of", "Steel.Channel.Protocol.extended_to" ]
[]
false
false
false
false
true
let extension_of #p (tr: partial_trace_of p) =
ts: partial_trace_of p {tr `extended_to` ts}
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.until
val until : tr: Steel.Channel.Protocol.partial_trace_of p -> Steel.Channel.Protocol.protocol Prims.unit
let until #p (tr:partial_trace_of p) = tr.to
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 44, "end_line": 152, "start_col": 0, "start_line": 152 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *) (* Send an int [x], recv a [y > x] *) let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return () let rec hnf (p:protocol 'a) : (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p let finished (p:protocol 'a) : GTot bool = Return? (hnf p) let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p) let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x noeq type trace : from:protocol unit -> to:protocol unit -> Type = | Waiting : p:protocol unit -> trace p p | Message : from:protocol unit{more_msgs from} -> x:next_msg_t from -> to:protocol unit -> trace (step from x) to-> trace from to let rec extend (#from #to:protocol unit) (t:trace from to{more_msgs to}) (m:next_msg_t to) : Tot (trace from (step to m)) (decreases t) = match t with | Waiting _ -> Message _ _ _ (Waiting (step to m)) | Message _from x _to tail -> Message _ _ _ (extend tail m) let rec last_step_of (#from #to:protocol unit) (t:trace from to { ~ (Waiting? t) }) : Tot (q:protocol unit & x:next_msg_t q & squash (more_msgs q /\to == step q x)) (decreases t) = match t with | Message _ x _ (Waiting _) -> (| from , x, () |) | Message _ _ _ tail -> last_step_of tail noeq type partial_trace_of (p:protocol unit) = { to:protocol unit; tr:trace p to } module P = FStar.Preorder module R = FStar.ReflexiveTransitiveClosure let next (#p:protocol unit) : P.relation (partial_trace_of p) = fun (t0 t1: partial_trace_of p) -> more_msgs t0.to /\ (exists (msg:next_msg_t t0.to). t1.to == step t0.to msg /\ t1.tr == extend t0.tr msg) let extended_to (#p:protocol unit) : P.preorder (partial_trace_of p) = R.closure (next #p) let extend_partial_trace (#p:protocol unit) (x:partial_trace_of p) (msg:next_msg_t x.to{more_msgs x.to}) : Tot (y:partial_trace_of p{x `extended_to` y}) = { to=_; tr=extend x.tr msg} let more (p:protocol unit) = more_msgs p let tag_of (p:protocol unit{more p}) : GTot tag = Msg?._0 (hnf p) let msg_t (p:protocol unit) = next_msg_t p
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": true, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
tr: Steel.Channel.Protocol.partial_trace_of p -> Steel.Channel.Protocol.protocol Prims.unit
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.protocol", "Prims.unit", "Steel.Channel.Protocol.partial_trace_of", "Steel.Channel.Protocol.__proj__Mkpartial_trace_of__item__to" ]
[]
false
false
false
false
false
let until #p (tr: partial_trace_of p) =
tr.to
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.hnf
val hnf (p: protocol 'a) : (q: protocol 'a {(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
val hnf (p: protocol 'a) : (q: protocol 'a {(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
let rec hnf (p:protocol 'a) : (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 12, "end_line": 84, "start_col": 0, "start_line": 80 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *) (* Send an int [x], recv a [y > x] *) let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Steel.Channel.Protocol.protocol 'a -> q: Steel.Channel.Protocol.protocol 'a {(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> p == q)}
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.protocol", "Steel.Channel.Protocol.prot", "Prims.bool", "Steel.Channel.Protocol.op_let_Hat", "Steel.Channel.Protocol.hnf", "Steel.Channel.Protocol.DoWhile", "Prims.l_and", "Prims.l_or", "Prims.b2t", "Steel.Channel.Protocol.uu___is_Return", "Steel.Channel.Protocol.uu___is_Msg", "Prims.l_imp", "Prims.l_not", "Steel.Channel.Protocol.uu___is_DoWhile", "Prims.eq2" ]
[ "recursion" ]
false
false
false
false
false
let rec hnf (p: protocol 'a) : (q: protocol 'a {(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) =
match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.step
val step (p: protocol 'a {more_msgs p}) (x: next_msg_t p) : protocol 'a
val step (p: protocol 'a {more_msgs p}) (x: next_msg_t p) : protocol 'a
let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 87, "end_line": 89, "start_col": 0, "start_line": 89 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *) (* Send an int [x], recv a [y > x] *) let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return () let rec hnf (p:protocol 'a) : (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p let finished (p:protocol 'a) : GTot bool = Return? (hnf p) let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Steel.Channel.Protocol.protocol 'a {Steel.Channel.Protocol.more_msgs p} -> x: Steel.Channel.Protocol.next_msg_t p -> Steel.Channel.Protocol.protocol 'a
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.protocol", "Prims.b2t", "Steel.Channel.Protocol.more_msgs", "Steel.Channel.Protocol.next_msg_t", "Steel.Channel.Protocol.__proj__Msg__item__k", "Steel.Channel.Protocol.hnf" ]
[]
false
false
false
false
false
let step (p: protocol 'a {more_msgs p}) (x: next_msg_t p) : protocol 'a =
Msg?.k (hnf p) x
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.last_step_of
val last_step_of (#from #to: protocol unit) (t: trace from to {~(Waiting? t)}) : Tot (q: protocol unit & x: next_msg_t q & squash (more_msgs q /\ to == step q x)) (decreases t)
val last_step_of (#from #to: protocol unit) (t: trace from to {~(Waiting? t)}) : Tot (q: protocol unit & x: next_msg_t q & squash (more_msgs q /\ to == step q x)) (decreases t)
let rec last_step_of (#from #to:protocol unit) (t:trace from to { ~ (Waiting? t) }) : Tot (q:protocol unit & x:next_msg_t q & squash (more_msgs q /\to == step q x)) (decreases t) = match t with | Message _ x _ (Waiting _) -> (| from , x, () |) | Message _ _ _ tail -> last_step_of tail
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 46, "end_line": 120, "start_col": 0, "start_line": 111 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *) (* Send an int [x], recv a [y > x] *) let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return () let rec hnf (p:protocol 'a) : (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p let finished (p:protocol 'a) : GTot bool = Return? (hnf p) let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p) let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x noeq type trace : from:protocol unit -> to:protocol unit -> Type = | Waiting : p:protocol unit -> trace p p | Message : from:protocol unit{more_msgs from} -> x:next_msg_t from -> to:protocol unit -> trace (step from x) to-> trace from to let rec extend (#from #to:protocol unit) (t:trace from to{more_msgs to}) (m:next_msg_t to) : Tot (trace from (step to m)) (decreases t) = match t with | Waiting _ -> Message _ _ _ (Waiting (step to m)) | Message _from x _to tail -> Message _ _ _ (extend tail m)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Steel.Channel.Protocol.trace from to {~(Waiting? t)} -> Prims.Tot (FStar.Pervasives.dtuple3 (Steel.Channel.Protocol.protocol Prims.unit) (fun q -> Steel.Channel.Protocol.next_msg_t q) (fun q x -> Prims.squash (Steel.Channel.Protocol.more_msgs q /\ to == Steel.Channel.Protocol.step q x)))
Prims.Tot
[ "total", "" ]
[]
[ "Steel.Channel.Protocol.protocol", "Prims.unit", "Steel.Channel.Protocol.trace", "Prims.l_not", "Prims.b2t", "Steel.Channel.Protocol.uu___is_Waiting", "Steel.Channel.Protocol.more_msgs", "Steel.Channel.Protocol.next_msg_t", "FStar.Pervasives.Mkdtuple3", "Prims.squash", "Prims.l_and", "Prims.eq2", "Steel.Channel.Protocol.step", "Steel.Channel.Protocol.last_step_of", "FStar.Pervasives.dtuple3" ]
[ "recursion" ]
false
false
false
false
false
let rec last_step_of (#from #to: protocol unit) (t: trace from to {~(Waiting? t)}) : Tot (q: protocol unit & x: next_msg_t q & squash (more_msgs q /\ to == step q x)) (decreases t) =
match t with | Message _ x _ (Waiting _) -> (| from, x, () |) | Message _ _ _ tail -> last_step_of tail
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.next
val next (#p: protocol unit) : P.relation (partial_trace_of p)
val next (#p: protocol unit) : P.relation (partial_trace_of p)
let next (#p:protocol unit) : P.relation (partial_trace_of p) = fun (t0 t1: partial_trace_of p) -> more_msgs t0.to /\ (exists (msg:next_msg_t t0.to). t1.to == step t0.to msg /\ t1.tr == extend t0.tr msg)
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 32, "end_line": 136, "start_col": 0, "start_line": 131 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *) (* Send an int [x], recv a [y > x] *) let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return () let rec hnf (p:protocol 'a) : (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p let finished (p:protocol 'a) : GTot bool = Return? (hnf p) let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p) let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x noeq type trace : from:protocol unit -> to:protocol unit -> Type = | Waiting : p:protocol unit -> trace p p | Message : from:protocol unit{more_msgs from} -> x:next_msg_t from -> to:protocol unit -> trace (step from x) to-> trace from to let rec extend (#from #to:protocol unit) (t:trace from to{more_msgs to}) (m:next_msg_t to) : Tot (trace from (step to m)) (decreases t) = match t with | Waiting _ -> Message _ _ _ (Waiting (step to m)) | Message _from x _to tail -> Message _ _ _ (extend tail m) let rec last_step_of (#from #to:protocol unit) (t:trace from to { ~ (Waiting? t) }) : Tot (q:protocol unit & x:next_msg_t q & squash (more_msgs q /\to == step q x)) (decreases t) = match t with | Message _ x _ (Waiting _) -> (| from , x, () |) | Message _ _ _ tail -> last_step_of tail noeq type partial_trace_of (p:protocol unit) = { to:protocol unit; tr:trace p to } module P = FStar.Preorder module R = FStar.ReflexiveTransitiveClosure
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": true, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Preorder.relation (Steel.Channel.Protocol.partial_trace_of p)
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.protocol", "Prims.unit", "Steel.Channel.Protocol.partial_trace_of", "Prims.l_and", "Prims.b2t", "Steel.Channel.Protocol.more_msgs", "Steel.Channel.Protocol.__proj__Mkpartial_trace_of__item__to", "Prims.l_Exists", "Steel.Channel.Protocol.next_msg_t", "Prims.eq2", "Steel.Channel.Protocol.step", "Steel.Channel.Protocol.trace", "Steel.Channel.Protocol.__proj__Mkpartial_trace_of__item__tr", "Steel.Channel.Protocol.extend", "FStar.Preorder.relation" ]
[]
false
false
false
false
false
let next (#p: protocol unit) : P.relation (partial_trace_of p) =
fun (t0: partial_trace_of p) (t1: partial_trace_of p) -> more_msgs t0.to /\ (exists (msg: next_msg_t t0.to). t1.to == step t0.to msg /\ t1.tr == extend t0.tr msg)
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.tag_of
val tag_of (p: protocol unit {more p}) : GTot tag
val tag_of (p: protocol unit {more p}) : GTot tag
let tag_of (p:protocol unit{more p}) : GTot tag = Msg?._0 (hnf p)
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 65, "end_line": 149, "start_col": 0, "start_line": 149 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *) (* Send an int [x], recv a [y > x] *) let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return () let rec hnf (p:protocol 'a) : (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p let finished (p:protocol 'a) : GTot bool = Return? (hnf p) let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p) let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x noeq type trace : from:protocol unit -> to:protocol unit -> Type = | Waiting : p:protocol unit -> trace p p | Message : from:protocol unit{more_msgs from} -> x:next_msg_t from -> to:protocol unit -> trace (step from x) to-> trace from to let rec extend (#from #to:protocol unit) (t:trace from to{more_msgs to}) (m:next_msg_t to) : Tot (trace from (step to m)) (decreases t) = match t with | Waiting _ -> Message _ _ _ (Waiting (step to m)) | Message _from x _to tail -> Message _ _ _ (extend tail m) let rec last_step_of (#from #to:protocol unit) (t:trace from to { ~ (Waiting? t) }) : Tot (q:protocol unit & x:next_msg_t q & squash (more_msgs q /\to == step q x)) (decreases t) = match t with | Message _ x _ (Waiting _) -> (| from , x, () |) | Message _ _ _ tail -> last_step_of tail noeq type partial_trace_of (p:protocol unit) = { to:protocol unit; tr:trace p to } module P = FStar.Preorder module R = FStar.ReflexiveTransitiveClosure let next (#p:protocol unit) : P.relation (partial_trace_of p) = fun (t0 t1: partial_trace_of p) -> more_msgs t0.to /\ (exists (msg:next_msg_t t0.to). t1.to == step t0.to msg /\ t1.tr == extend t0.tr msg) let extended_to (#p:protocol unit) : P.preorder (partial_trace_of p) = R.closure (next #p) let extend_partial_trace (#p:protocol unit) (x:partial_trace_of p) (msg:next_msg_t x.to{more_msgs x.to}) : Tot (y:partial_trace_of p{x `extended_to` y}) = { to=_; tr=extend x.tr msg}
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": true, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Steel.Channel.Protocol.protocol Prims.unit {Steel.Channel.Protocol.more p} -> Prims.GTot Steel.Channel.Protocol.tag
Prims.GTot
[ "sometrivial" ]
[]
[ "Steel.Channel.Protocol.protocol", "Prims.unit", "Prims.b2t", "Steel.Channel.Protocol.more", "Steel.Channel.Protocol.__proj__Msg__item___0", "Steel.Channel.Protocol.hnf", "Steel.Channel.Protocol.tag" ]
[]
false
false
false
false
false
let tag_of (p: protocol unit {more p}) : GTot tag =
Msg?._0 (hnf p)
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.extend_partial_trace
val extend_partial_trace (#p: protocol unit) (x: partial_trace_of p) (msg: next_msg_t x.to {more_msgs x.to}) : Tot (y: partial_trace_of p {x `extended_to` y})
val extend_partial_trace (#p: protocol unit) (x: partial_trace_of p) (msg: next_msg_t x.to {more_msgs x.to}) : Tot (y: partial_trace_of p {x `extended_to` y})
let extend_partial_trace (#p:protocol unit) (x:partial_trace_of p) (msg:next_msg_t x.to{more_msgs x.to}) : Tot (y:partial_trace_of p{x `extended_to` y}) = { to=_; tr=extend x.tr msg}
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 31, "end_line": 145, "start_col": 0, "start_line": 141 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *) (* Send an int [x], recv a [y > x] *) let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return () let rec hnf (p:protocol 'a) : (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p let finished (p:protocol 'a) : GTot bool = Return? (hnf p) let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p) let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x noeq type trace : from:protocol unit -> to:protocol unit -> Type = | Waiting : p:protocol unit -> trace p p | Message : from:protocol unit{more_msgs from} -> x:next_msg_t from -> to:protocol unit -> trace (step from x) to-> trace from to let rec extend (#from #to:protocol unit) (t:trace from to{more_msgs to}) (m:next_msg_t to) : Tot (trace from (step to m)) (decreases t) = match t with | Waiting _ -> Message _ _ _ (Waiting (step to m)) | Message _from x _to tail -> Message _ _ _ (extend tail m) let rec last_step_of (#from #to:protocol unit) (t:trace from to { ~ (Waiting? t) }) : Tot (q:protocol unit & x:next_msg_t q & squash (more_msgs q /\to == step q x)) (decreases t) = match t with | Message _ x _ (Waiting _) -> (| from , x, () |) | Message _ _ _ tail -> last_step_of tail noeq type partial_trace_of (p:protocol unit) = { to:protocol unit; tr:trace p to } module P = FStar.Preorder module R = FStar.ReflexiveTransitiveClosure let next (#p:protocol unit) : P.relation (partial_trace_of p) = fun (t0 t1: partial_trace_of p) -> more_msgs t0.to /\ (exists (msg:next_msg_t t0.to). t1.to == step t0.to msg /\ t1.tr == extend t0.tr msg) let extended_to (#p:protocol unit) : P.preorder (partial_trace_of p) = R.closure (next #p)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": true, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Steel.Channel.Protocol.partial_trace_of p -> msg: Steel.Channel.Protocol.next_msg_t (Mkpartial_trace_of?.to x) {Steel.Channel.Protocol.more_msgs (Mkpartial_trace_of?.to x)} -> y: Steel.Channel.Protocol.partial_trace_of p {Steel.Channel.Protocol.extended_to x y}
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.protocol", "Prims.unit", "Steel.Channel.Protocol.partial_trace_of", "Steel.Channel.Protocol.next_msg_t", "Steel.Channel.Protocol.__proj__Mkpartial_trace_of__item__to", "Prims.b2t", "Steel.Channel.Protocol.more_msgs", "Steel.Channel.Protocol.Mkpartial_trace_of", "Steel.Channel.Protocol.step", "Steel.Channel.Protocol.extend", "Steel.Channel.Protocol.__proj__Mkpartial_trace_of__item__tr", "Steel.Channel.Protocol.extended_to" ]
[]
false
false
false
false
false
let extend_partial_trace (#p: protocol unit) (x: partial_trace_of p) (msg: next_msg_t x.to {more_msgs x.to}) : Tot (y: partial_trace_of p {x `extended_to` y}) =
{ to = _; tr = extend x.tr msg }
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.extend
val extend (#from #to: protocol unit) (t: trace from to {more_msgs to}) (m: next_msg_t to) : Tot (trace from (step to m)) (decreases t)
val extend (#from #to: protocol unit) (t: trace from to {more_msgs to}) (m: next_msg_t to) : Tot (trace from (step to m)) (decreases t)
let rec extend (#from #to:protocol unit) (t:trace from to{more_msgs to}) (m:next_msg_t to) : Tot (trace from (step to m)) (decreases t) = match t with | Waiting _ -> Message _ _ _ (Waiting (step to m)) | Message _from x _to tail -> Message _ _ _ (extend tail m)
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 35, "end_line": 109, "start_col": 0, "start_line": 101 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *) (* Send an int [x], recv a [y > x] *) let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return () let rec hnf (p:protocol 'a) : (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p let finished (p:protocol 'a) : GTot bool = Return? (hnf p) let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p) let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x noeq type trace : from:protocol unit -> to:protocol unit -> Type = | Waiting : p:protocol unit -> trace p p | Message : from:protocol unit{more_msgs from} -> x:next_msg_t from -> to:protocol unit -> trace (step from x) to-> trace from to
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Steel.Channel.Protocol.trace from to {Steel.Channel.Protocol.more_msgs to} -> m: Steel.Channel.Protocol.next_msg_t to -> Prims.Tot (Steel.Channel.Protocol.trace from (Steel.Channel.Protocol.step to m))
Prims.Tot
[ "total", "" ]
[]
[ "Steel.Channel.Protocol.protocol", "Prims.unit", "Steel.Channel.Protocol.trace", "Prims.b2t", "Steel.Channel.Protocol.more_msgs", "Steel.Channel.Protocol.next_msg_t", "Steel.Channel.Protocol.Message", "Steel.Channel.Protocol.step", "Steel.Channel.Protocol.Waiting", "Steel.Channel.Protocol.extend" ]
[ "recursion" ]
false
false
false
false
false
let rec extend (#from #to: protocol unit) (t: trace from to {more_msgs to}) (m: next_msg_t to) : Tot (trace from (step to m)) (decreases t) =
match t with | Waiting _ -> Message _ _ _ (Waiting (step to m)) | Message _from x _to tail -> Message _ _ _ (extend tail m)
false
Steel.Channel.Protocol.fst
Steel.Channel.Protocol.extended_to
val extended_to (#p: protocol unit) : P.preorder (partial_trace_of p)
val extended_to (#p: protocol unit) : P.preorder (partial_trace_of p)
let extended_to (#p:protocol unit) : P.preorder (partial_trace_of p) = R.closure (next #p)
{ "file_name": "lib/steel/Steel.Channel.Protocol.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 21, "end_line": 139, "start_col": 0, "start_line": 138 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Channel.Protocol type tag = | Send | Recv // AF: Make it non erasable for now to implement duplex.PCM //[@@erasable] noeq type prot : Type -> Type = | Return : #a:Type -> v:a -> prot a | Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b | DoWhile : prot bool -> #a:Type -> k:prot a -> prot a let rec ok #a (p:prot a) = match p with | Return _ -> True | Msg _ a k -> (forall x. ok (k x)) | DoWhile p k -> Msg? p /\ ok p /\ ok k let protocol a = p:prot a { ok p } let flip_tag = function | Send -> Recv | Recv -> Send let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} = match p with | Return _ -> p | Msg tag b #a k -> let k : b -> protocol a = fun (x:b) -> dual #a (k x) in Msg (flip_tag tag) b #a k | DoWhile p #a k -> DoWhile (dual p) #a (dual k) let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) : protocol b = match p with | Return v -> q v | Msg tag c #a' k -> let k : c -> protocol b = fun x -> bind (k x) q in Msg tag c k | DoWhile w k -> DoWhile w (bind k q) unfold let (let^) = bind let return (#a:Type) (x:a) : protocol a = Return x let done = return () let send (t:Type) : protocol t = Msg Send t (fun x -> return x) let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) (* Some simple protocols *) (* Send an int [x], recv a [y > x] *) let xy : prot unit = let^ x = send int in let^ y = recv (y:int{y > x}) in return () let rec hnf (p:protocol 'a) : (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = match p with | DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k | _ -> p let finished (p:protocol 'a) : GTot bool = Return? (hnf p) let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p) let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x noeq type trace : from:protocol unit -> to:protocol unit -> Type = | Waiting : p:protocol unit -> trace p p | Message : from:protocol unit{more_msgs from} -> x:next_msg_t from -> to:protocol unit -> trace (step from x) to-> trace from to let rec extend (#from #to:protocol unit) (t:trace from to{more_msgs to}) (m:next_msg_t to) : Tot (trace from (step to m)) (decreases t) = match t with | Waiting _ -> Message _ _ _ (Waiting (step to m)) | Message _from x _to tail -> Message _ _ _ (extend tail m) let rec last_step_of (#from #to:protocol unit) (t:trace from to { ~ (Waiting? t) }) : Tot (q:protocol unit & x:next_msg_t q & squash (more_msgs q /\to == step q x)) (decreases t) = match t with | Message _ x _ (Waiting _) -> (| from , x, () |) | Message _ _ _ tail -> last_step_of tail noeq type partial_trace_of (p:protocol unit) = { to:protocol unit; tr:trace p to } module P = FStar.Preorder module R = FStar.ReflexiveTransitiveClosure let next (#p:protocol unit) : P.relation (partial_trace_of p) = fun (t0 t1: partial_trace_of p) -> more_msgs t0.to /\ (exists (msg:next_msg_t t0.to). t1.to == step t0.to msg /\ t1.tr == extend t0.tr msg)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.ReflexiveTransitiveClosure.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Steel.Channel.Protocol.fst" }
[ { "abbrev": true, "full_module": "FStar.ReflexiveTransitiveClosure", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "Steel.Channel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Preorder.preorder (Steel.Channel.Protocol.partial_trace_of p)
Prims.Tot
[ "total" ]
[]
[ "Steel.Channel.Protocol.protocol", "Prims.unit", "FStar.ReflexiveTransitiveClosure.closure", "Steel.Channel.Protocol.partial_trace_of", "Steel.Channel.Protocol.next", "FStar.Preorder.preorder" ]
[]
false
false
false
false
false
let extended_to (#p: protocol unit) : P.preorder (partial_trace_of p) =
R.closure (next #p)
false
Steel.Primitive.ForkJoin.fst
Steel.Primitive.ForkJoin.finish
val finish (#p: vprop) (t: thread p) (v: bool) : SteelT unit ((pts_to t.r full_perm v) `star` p) (fun _ -> emp)
val finish (#p: vprop) (t: thread p) (v: bool) : SteelT unit ((pts_to t.r full_perm v) `star` p) (fun _ -> emp)
let finish (#p:vprop) (t:thread p) (v:bool) : SteelT unit (pts_to t.r full_perm v `star` p) (fun _ -> emp) = write_pt t.r true; intro_maybe_p_true p; intro_exists true (lock_inv_pred t.r p); L.release t.l
{ "file_name": "lib/steel/Steel.Primitive.ForkJoin.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 17, "end_line": 66, "start_col": 0, "start_line": 61 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Primitive.ForkJoin open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module L = Steel.SpinLock open Steel.FractionalPermission open Steel.Reference //////////////////////////////////////////////////////////////////////////////// let maybe_p (p:vprop) (v:bool) = if v then p else emp [@@__reduce__] let lock_inv_pred (r:ref bool) (p:vprop) (v:bool) : vprop = pts_to r full_perm v `star` maybe_p p v let lock_inv (r:ref bool) (p:vprop) : vprop = h_exists (lock_inv_pred r p) noeq type thread (p:vprop) = { r:ref bool; l:L.lock (lock_inv r p) } let intro_maybe_p_false (p:vprop) : SteelT unit emp (fun _ -> maybe_p p false) = rewrite_slprop emp (maybe_p p false) (fun _ -> ()) let intro_maybe_p_true (p:vprop) : SteelT unit p (fun _ -> maybe_p p true) = rewrite_slprop p (maybe_p p true) (fun _ -> ()) let new_thread (p:vprop) : SteelT (thread p) emp (fun _ -> emp) = let r = alloc_pt false in intro_maybe_p_false p; intro_exists false (lock_inv_pred r p); let l = L.new_lock (lock_inv r p) in let t = {r = r; l = l} in t
{ "checked_file": "/", "dependencies": [ "Steel.SpinLock.fsti.checked", "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.Primitive.ForkJoin.fst" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.SpinLock", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Steel.Primitive.ForkJoin.thread p -> v: Prims.bool -> Steel.Effect.SteelT Prims.unit
Steel.Effect.SteelT
[]
[]
[ "Steel.Effect.Common.vprop", "Steel.Primitive.ForkJoin.thread", "Prims.bool", "Steel.SpinLock.release", "Steel.Primitive.ForkJoin.lock_inv", "Steel.Primitive.ForkJoin.__proj__Mkthread__item__r", "Steel.Primitive.ForkJoin.__proj__Mkthread__item__l", "Prims.unit", "Steel.Effect.Atomic.intro_exists", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Primitive.ForkJoin.lock_inv_pred", "Steel.Primitive.ForkJoin.intro_maybe_p_true", "Steel.Reference.write_pt", "Steel.Effect.Common.star", "Steel.Reference.pts_to", "Steel.FractionalPermission.full_perm", "Steel.Effect.Common.emp" ]
[]
false
true
false
false
false
let finish (#p: vprop) (t: thread p) (v: bool) : SteelT unit ((pts_to t.r full_perm v) `star` p) (fun _ -> emp) =
write_pt t.r true; intro_maybe_p_true p; intro_exists true (lock_inv_pred t.r p); L.release t.l
false
Steel.Primitive.ForkJoin.fst
Steel.Primitive.ForkJoin.acquire
val acquire (#p: vprop) (t: thread p) : SteelT bool emp (fun b -> pts_to t.r full_perm b)
val acquire (#p: vprop) (t: thread p) : SteelT bool emp (fun b -> pts_to t.r full_perm b)
let acquire (#p:vprop) (t:thread p) : SteelT bool emp (fun b -> pts_to t.r full_perm b) = L.acquire t.l; let b = read_refine_pt #_ #full_perm (maybe_p p) t.r in drop (maybe_p p b); return b
{ "file_name": "lib/steel/Steel.Primitive.ForkJoin.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 12, "end_line": 74, "start_col": 0, "start_line": 69 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.Primitive.ForkJoin open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module L = Steel.SpinLock open Steel.FractionalPermission open Steel.Reference //////////////////////////////////////////////////////////////////////////////// let maybe_p (p:vprop) (v:bool) = if v then p else emp [@@__reduce__] let lock_inv_pred (r:ref bool) (p:vprop) (v:bool) : vprop = pts_to r full_perm v `star` maybe_p p v let lock_inv (r:ref bool) (p:vprop) : vprop = h_exists (lock_inv_pred r p) noeq type thread (p:vprop) = { r:ref bool; l:L.lock (lock_inv r p) } let intro_maybe_p_false (p:vprop) : SteelT unit emp (fun _ -> maybe_p p false) = rewrite_slprop emp (maybe_p p false) (fun _ -> ()) let intro_maybe_p_true (p:vprop) : SteelT unit p (fun _ -> maybe_p p true) = rewrite_slprop p (maybe_p p true) (fun _ -> ()) let new_thread (p:vprop) : SteelT (thread p) emp (fun _ -> emp) = let r = alloc_pt false in intro_maybe_p_false p; intro_exists false (lock_inv_pred r p); let l = L.new_lock (lock_inv r p) in let t = {r = r; l = l} in t let finish (#p:vprop) (t:thread p) (v:bool) : SteelT unit (pts_to t.r full_perm v `star` p) (fun _ -> emp) = write_pt t.r true; intro_maybe_p_true p; intro_exists true (lock_inv_pred t.r p); L.release t.l
{ "checked_file": "/", "dependencies": [ "Steel.SpinLock.fsti.checked", "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.FractionalPermission.fst.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.Primitive.ForkJoin.fst" }
[ { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "Steel.SpinLock", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive", "short_module": null }, { "abbrev": false, "full_module": "Steel.Primitive", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Steel.Primitive.ForkJoin.thread p -> Steel.Effect.SteelT Prims.bool
Steel.Effect.SteelT
[]
[]
[ "Steel.Effect.Common.vprop", "Steel.Primitive.ForkJoin.thread", "Steel.Effect.Atomic.return", "Prims.bool", "FStar.Ghost.hide", "FStar.Set.set", "Steel.Memory.iname", "FStar.Set.empty", "Steel.Reference.pts_to", "Steel.Primitive.ForkJoin.__proj__Mkthread__item__r", "Steel.FractionalPermission.full_perm", "Prims.unit", "Steel.Effect.Atomic.drop", "Steel.Primitive.ForkJoin.maybe_p", "Steel.Reference.read_refine_pt", "Steel.SpinLock.acquire", "Steel.Primitive.ForkJoin.lock_inv", "Steel.Primitive.ForkJoin.__proj__Mkthread__item__l", "Steel.Effect.Common.emp" ]
[]
false
true
false
false
false
let acquire (#p: vprop) (t: thread p) : SteelT bool emp (fun b -> pts_to t.r full_perm b) =
L.acquire t.l; let b = read_refine_pt #_ #full_perm (maybe_p p) t.r in drop (maybe_p p b); return b
false
Steel.ST.GenElim1.fst
Steel.ST.GenElim1.compute_gen_elim_nondep_correct3
val compute_gen_elim_nondep_correct3 (i0: gen_elim_i) (t1 t2 t3: Type) : Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
val compute_gen_elim_nondep_correct3 (i0: gen_elim_i) (t1 t2 t3: Type) : Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3])
let compute_gen_elim_nondep_correct3 (i0: gen_elim_i) (t1 t2 t3: Type) : Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3]) = fun q post intro _ -> intro _; rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> q x1 x2 x3 (U.raise_val ()) `star` pure (post x1 x2 x3 (U.raise_val ())))))); let x1 = elim_exists' () in let x2 = elim_exists' () in let x3 = elim_exists' () in let res = Mktuple3 x1 x2 x3 in elim_pure _; rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ())); res
{ "file_name": "lib/steel/Steel.ST.GenElim1.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 7, "end_line": 526, "start_col": 0, "start_line": 513 }
module Steel.ST.GenElim1 let gen_elim_f (p: vprop) (a: Type) (q: (a -> vprop)) (post: (a -> prop)) : Tot Type = ((opened: inames) -> STGhost a opened p q True post) module U = FStar.Universe let gen_unit_elim_t (i: gen_unit_elim_i) : Tot Type = gen_elim_f (compute_gen_unit_elim_p i) (U.raise_t u#_ u#1 unit) (fun _ -> compute_gen_unit_elim_q i) (fun _ -> compute_gen_unit_elim_post i) let compute_gen_unit_elim_f_id (v: vprop) : Tot (gen_unit_elim_t (GUEId v)) = fun _ -> noop (); U.raise_val () let compute_gen_unit_elim_f_pure (p: prop) : Tot (gen_unit_elim_t (GUEPure p)) = fun _ -> rewrite (compute_gen_unit_elim_p (GUEPure p)) (pure p); elim_pure p; U.raise_val () let compute_gen_unit_elim_f_star (i1 i2: gen_unit_elim_i) (f1: gen_unit_elim_t i1) (f2: gen_unit_elim_t i2) : Tot (gen_unit_elim_t (GUEStar i1 i2)) = fun _ -> rewrite (compute_gen_unit_elim_p (GUEStar i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_unit_elim_p i2); let _ = f1 _ in let _ = f2 _ in rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_unit_elim_q i2) (compute_gen_unit_elim_q (GUEStar i1 i2)); U.raise_val () let rec compute_gen_unit_elim_f (i: gen_unit_elim_i) : GTot (gen_unit_elim_t i) = match i returns (gen_unit_elim_t i) with | GUEId v -> compute_gen_unit_elim_f_id v | GUEPure p -> compute_gen_unit_elim_f_pure p | GUEStar i1 i2 -> compute_gen_unit_elim_f_star i1 i2 (compute_gen_unit_elim_f i1) (compute_gen_unit_elim_f i2) let gen_elim_t (i: gen_elim_i) : Tot Type = gen_elim_f (compute_gen_elim_p i) (compute_gen_elim_a i) (compute_gen_elim_q i) (compute_gen_elim_post i) let compute_gen_elim_f_unit (i: gen_unit_elim_i) : GTot (gen_elim_t (GEUnit i)) = compute_gen_unit_elim_f i let compute_gen_elim_f_star_l (i1: gen_elim_i) (f1: gen_elim_t i1) (i2: gen_unit_elim_i) : GTot (gen_elim_t (GEStarL i1 i2)) = let f2 = compute_gen_unit_elim_f i2 in fun _ -> rewrite (compute_gen_elim_p (GEStarL i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_unit_elim_p i2); let res = f1 _ in let _ = f2 _ in let res' : compute_gen_elim_a (GEStarL i1 i2) = coerce_with_trefl res in rewrite (compute_gen_elim_q i1 res `star` compute_gen_unit_elim_q i2) (compute_gen_elim_q (GEStarL i1 i2) res'); res' let compute_gen_elim_f_star_r (i1: gen_unit_elim_i) (i2: gen_elim_i) (f2: gen_elim_t i2) : GTot (gen_elim_t (GEStarR i1 i2)) = let f1 = compute_gen_unit_elim_f i1 in fun _ -> rewrite (compute_gen_elim_p (GEStarR i1 i2)) (compute_gen_unit_elim_p i1 `star` compute_gen_elim_p i2); let _ = f1 _ in let res = f2 _ in let res' : compute_gen_elim_a (GEStarR i1 i2) = coerce_with_trefl res in rewrite (compute_gen_unit_elim_q i1 `star` compute_gen_elim_q i2 res) (compute_gen_elim_q (GEStarR i1 i2) res'); res' let compute_gen_elim_f_star (i1: gen_elim_i) (f1: gen_elim_t i1) (i2: gen_elim_i) (f2: gen_elim_t i2) : GTot (gen_elim_t (GEStar i1 i2)) = fun _ -> rewrite (compute_gen_elim_p (GEStar i1 i2)) (compute_gen_elim_p i1 `star` compute_gen_elim_p i2); let res1 = f1 _ in let res2 = f2 _ in let res : compute_gen_elim_a (GEStar i1 i2) = coerce_with_trefl (res1, res2) in rewrite (compute_gen_elim_q i1 res1 `star` compute_gen_elim_q i2 res2) (compute_gen_elim_q (GEStar i1 i2) res); res let compute_gen_elim_f_exists_no_abs0 (a: Type0) (body: (a -> vprop)) : GTot (gen_elim_t (GEExistsNoAbs0 body)) = fun _ -> rewrite (compute_gen_elim_p (GEExistsNoAbs0 body)) (exists_ body); let gres = elim_exists () in let res : compute_gen_elim_a (GEExistsNoAbs0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs0 body) res); res let rewrite_with_trefl (#opened:_) (p q:vprop) : STGhost unit opened p (fun _ -> q) (requires T.with_tactic T.trefl (p == q)) (ensures fun _ -> True) = rewrite p q let compute_gen_elim_f_exists_unit0 (a: Type0) (body: a -> gen_unit_elim_i) : Tot (gen_elim_t (GEExistsUnit0 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit0 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x))); let gres = elim_exists () in let _ = compute_gen_unit_elim_f (body gres) _ in let res : compute_gen_elim_a (GEExistsUnit0 body) = U.raise_val (Ghost.reveal gres) in // coerce_with_trefl (Ghost.reveal gres) in rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit0 body) res); res let compute_gen_elim_f_exists0 (a: Type0) (body: a -> gen_elim_i) (f: (x: a) -> GTot (gen_elim_t (body x))) : Tot (gen_elim_t (GEExists0 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExists0 body)) (exists_ (fun x -> compute_gen_elim_p (body x))); let gres1 = elim_exists () in let gres2 = f gres1 _ in let res : compute_gen_elim_a (GEExists0 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists0 body) res); res let compute_gen_elim_f_exists_no_abs1 (a: Type) (body: (a -> vprop)) : GTot (gen_elim_t (GEExistsNoAbs1 body)) = fun _ -> rewrite (compute_gen_elim_p (GEExistsNoAbs1 body)) (exists_ body); let gres = elim_exists () in let res : compute_gen_elim_a (GEExistsNoAbs1 body) = coerce_with_trefl (Ghost.reveal gres) in rewrite (body gres) (compute_gen_elim_q (GEExistsNoAbs1 body) res); res let compute_gen_elim_f_exists_unit1 (a: Type) (body: a -> gen_unit_elim_i) : Tot (gen_elim_t (GEExistsUnit1 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExistsUnit1 body)) (exists_ (fun x -> compute_gen_unit_elim_p (body x))); let gres = elim_exists () in let _ = compute_gen_unit_elim_f (body gres) _ in let res : compute_gen_elim_a (GEExistsUnit1 body) = coerce_with_trefl (Ghost.reveal gres) in rewrite (compute_gen_unit_elim_q (body gres)) (compute_gen_elim_q (GEExistsUnit1 body) res); res let compute_gen_elim_f_exists1 (a: Type) (body: a -> gen_elim_i) (f: (x: a) -> GTot (gen_elim_t (body x))) : Tot (gen_elim_t (GEExists1 body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p (GEExists1 body)) (exists_ (fun x -> compute_gen_elim_p (body x))); let gres1 = elim_exists () in let gres2 = f gres1 _ in let res : compute_gen_elim_a (GEExists1 body) = coerce_with_trefl (Mkdtuple2 #a #(fun x -> compute_gen_elim_a (body x)) (Ghost.reveal gres1) (Ghost.reveal gres2)) in rewrite (compute_gen_elim_q (body gres1) gres2) (compute_gen_elim_q (GEExists1 body) res); res let rec compute_gen_elim_f (i: gen_elim_i) : GTot (gen_elim_t i) = match i returns (gen_elim_t i) with | GEUnit i -> compute_gen_elim_f_unit i | GEStarL i1 i2 -> compute_gen_elim_f_star_l i1 (compute_gen_elim_f i1) i2 | GEStarR i1 i2 -> compute_gen_elim_f_star_r i1 i2 (compute_gen_elim_f i2) | GEStar i1 i2 -> compute_gen_elim_f_star i1 (compute_gen_elim_f i1) i2 (compute_gen_elim_f i2) | GEExistsNoAbs0 body -> compute_gen_elim_f_exists_no_abs0 _ body | GEExistsUnit0 body -> compute_gen_elim_f_exists_unit0 _ body | GEExists0 body -> compute_gen_elim_f_exists0 _ body (fun x -> compute_gen_elim_f (body x)) | GEExistsNoAbs1 body -> compute_gen_elim_f_exists_no_abs1 _ body | GEExistsUnit1 body -> compute_gen_elim_f_exists_unit1 _ body | GEExists1 body -> compute_gen_elim_f_exists1 _ body (fun x -> compute_gen_elim_f (body x)) let rec tele_p (x: gen_elim_tele) : Tot vprop = match x with | TRet v p -> v `star` pure p | TExists ty body -> exists_ (fun x -> tele_p (body x)) let elim_exists' (#a:Type) (#opened_invariants:_) (#p:a -> vprop) (_:unit) : STGhostT (a) opened_invariants (exists_ p) (fun x -> p x) = let gx = elim_exists () in let x = Ghost.reveal gx in rewrite (p gx) (p x); x let vprop_rewrite (from to: vprop) : Tot Type = gen_elim_f from unit (fun _ -> to) (fun _ -> True) let tele_star_vprop_correct_ret (v': vprop) (p': prop) (v: vprop) (p: prop) : Tot (vprop_rewrite (tele_p (TRet v' p') `star` v `star` pure p) (tele_p (tele_star_vprop (TRet v' p') v p))) = fun _ -> elim_pure p; rewrite (tele_p _) (v' `star` pure p'); elim_pure p'; intro_pure (p /\ p'); rewrite ((v `star` v') `star` pure (p /\ p')) (tele_p _) let tele_star_vprop_correct_exists (v: vprop) (p: prop) (ty: _) (body: ty -> gen_elim_tele) (ih: (x: ty) -> GTot (vprop_rewrite (tele_p (body x) `star` v `star` pure p) (tele_p (tele_star_vprop (body x) v p)))) : Tot (vprop_rewrite (tele_p (TExists ty body) `star` v `star` pure p) (tele_p (tele_star_vprop (TExists ty body) v p))) = fun _ -> rewrite_with_trefl (tele_p _) (exists_ (fun x -> tele_p (body x))); let x = elim_exists' () in ih x _; intro_exists x (fun x -> tele_p (tele_star_vprop (body x) v p)); rewrite_with_trefl (exists_ (fun x -> tele_p (tele_star_vprop (body x) v p))) (tele_p _) let rec tele_star_vprop_correct (i: gen_elim_tele) (v: vprop) (p: prop) : GTot (vprop_rewrite (tele_p i `star` v `star` pure p) (tele_p (tele_star_vprop i v p)) ) = match i returns vprop_rewrite (tele_p i `star` v `star` pure p) (tele_p (tele_star_vprop i v p)) with | TRet v' p' -> tele_star_vprop_correct_ret v' p' v p | TExists ty body -> tele_star_vprop_correct_exists v p ty body (fun x -> tele_star_vprop_correct (body x) v p) let tele_star_correct_ret_l (v1: vprop) (p1: prop) (i2: gen_elim_tele) : Tot (vprop_rewrite (tele_p (TRet v1 p1) `star` tele_p i2) (tele_p (TRet v1 p1 `tele_star` i2))) = fun _ -> rewrite (tele_p (TRet v1 p1)) (v1 `star` pure p1); tele_star_vprop_correct i2 v1 p1 _; rewrite (tele_p _) (tele_p _) let tele_star_correct_ret_r (i1: gen_elim_tele { ~ (TRet? i1) }) (v2: vprop) (p2: prop) : Tot (vprop_rewrite (tele_p i1 `star` tele_p (TRet v2 p2)) (tele_p (i1 `tele_star` TRet v2 p2))) = fun _ -> rewrite (tele_p (TRet v2 p2)) (v2 `star` pure p2); tele_star_vprop_correct i1 v2 p2 _; rewrite (tele_p _) (tele_p (i1 `tele_star` TRet v2 p2)) let tele_star_correct_exists (ty1: _) (f1: ty1 -> gen_elim_tele) (ty2: _) (f2: ty2 -> gen_elim_tele) (ih: (x1: ty1) -> (x2: ty2) -> GTot (vprop_rewrite (tele_p (f1 x1) `star` tele_p (f2 x2)) (tele_p (f1 x1 `tele_star` f2 x2)))) : Tot (vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p (TExists ty2 f2)) (tele_p (tele_star (TExists ty1 f1) (TExists ty2 f2)))) = fun _ -> rewrite_with_trefl (tele_p (TExists ty1 f1)) (exists_ (fun x1 -> tele_p (f1 x1))); let x1 = elim_exists' () in rewrite_with_trefl (tele_p (TExists ty2 f2)) (exists_ (fun x2 -> tele_p (f2 x2))); let x2 = elim_exists' () in ih x1 x2 _; intro_exists x2 (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2))); intro_exists x1 (fun x1 -> exists_ (fun x2 -> tele_p (tele_star (f1 x1) (f2 x2)))); rewrite_with_trefl (exists_ _) (tele_p _) let rec tele_star_correct (i1 i2: gen_elim_tele) : GTot (vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2))) = match i1 returns vprop_rewrite (tele_p i1 `star` tele_p i2) (tele_p (i1 `tele_star` i2)) with | TRet v1 p1 -> tele_star_correct_ret_l v1 p1 i2 | TExists ty1 f1 -> begin match i2 returns vprop_rewrite (tele_p (TExists ty1 f1) `star` tele_p i2) (tele_p (TExists ty1 f1 `tele_star` i2)) with | TRet v2 p2 -> tele_star_correct_ret_r (TExists ty1 f1) v2 p2 | TExists ty2 f2 -> tele_star_correct_exists ty1 f1 ty2 f2 (fun x1 x2 -> tele_star_correct (f1 x1) (f2 x2)) end [@@noextract_to "Plugin" ] let ge_to_tele_t (i: gen_elim_i) : Tot Type = vprop_rewrite (compute_gen_elim_p i) (tele_p (compute_gen_elim_tele i)) let compute_gen_elim_tele_correct_unit (v: gen_unit_elim_i) : Tot (ge_to_tele_t (GEUnit v)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p v); let _ = compute_gen_unit_elim_f v _ in intro_pure (compute_gen_unit_elim_post v); rewrite_with_trefl (compute_gen_unit_elim_q v `star` pure _) (tele_p _) let compute_gen_elim_tele_correct_star_l (l: gen_elim_i) (ihl: ge_to_tele_t l) (ru: gen_unit_elim_i) : Tot (ge_to_tele_t (GEStarL l ru)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_unit_elim_p ru); ihl _; let _ = compute_gen_unit_elim_f ru _ in intro_pure (compute_gen_unit_elim_post ru); tele_star_vprop_correct _ _ _ _; rewrite_with_trefl (tele_p _) (tele_p _) let compute_gen_elim_tele_correct_star_r (lu: gen_unit_elim_i) (r: gen_elim_i) (ihr: ge_to_tele_t r) : Tot (ge_to_tele_t (GEStarR lu r)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_unit_elim_p lu `star` compute_gen_elim_p r); ihr _; let _ = compute_gen_unit_elim_f lu _ in intro_pure (compute_gen_unit_elim_post lu); tele_star_vprop_correct _ _ _ _; rewrite_with_trefl (tele_p _) (tele_p _) let compute_gen_elim_tele_correct_star (l: gen_elim_i) (ihl: ge_to_tele_t l) (r: gen_elim_i) (ihr: ge_to_tele_t r) : Tot (ge_to_tele_t (GEStar l r)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (compute_gen_elim_p l `star` compute_gen_elim_p r); ihl _; ihr _; tele_star_correct (compute_gen_elim_tele l) (compute_gen_elim_tele r) _; rewrite_with_trefl (tele_p _) (tele_p _) let compute_gen_elim_tele_correct_exists_no_abs0 (ty: _) (body: ty -> vprop) : Tot (ge_to_tele_t (GEExistsNoAbs0 #ty body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ body); let x = elim_exists' () in intro_pure True; rewrite (body x) (body (U.downgrade_val (U.raise_val x))); intro_exists (U.raise_val u#0 u#1 x) (fun x -> body (U.downgrade_val x) `star` pure True); rewrite_with_trefl (exists_ _) (tele_p _) let compute_gen_elim_tele_correct_exists_unit0 (ty: _) (body: ty -> gen_unit_elim_i) : Tot (ge_to_tele_t (GEExistsUnit0 #ty body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x))); let x = elim_exists' () in let _ = compute_gen_unit_elim_f (body x) _ in intro_pure (compute_gen_unit_elim_post (body (U.downgrade_val (U.raise_val u#0 u#1 x)))); rewrite (compute_gen_unit_elim_q (body x)) (compute_gen_unit_elim_q (body (U.downgrade_val (U.raise_val x)))); intro_exists (U.raise_val u#0 u#1 x) (fun x -> compute_gen_unit_elim_q (body (U.downgrade_val x)) `star` pure (compute_gen_unit_elim_post (body (U.downgrade_val x)))); rewrite_with_trefl (exists_ _) (tele_p _) let compute_gen_elim_tele_correct_exists0 (ty: _) (body: ty -> gen_elim_i) (ih: (x: ty) -> GTot (ge_to_tele_t (body x))) : Tot (ge_to_tele_t (GEExists0 #ty body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x))); let x = elim_exists' () in ih x _; rewrite (tele_p (compute_gen_elim_tele (body x))) (tele_p (compute_gen_elim_tele (body (U.downgrade_val (U.raise_val u#0 u#1 x))))); intro_exists (U.raise_val u#0 u#1 x) (fun x -> tele_p (compute_gen_elim_tele (body (U.downgrade_val u#0 u#1 x)))); rewrite_with_trefl (exists_ _) (tele_p _) let compute_gen_elim_tele_correct_exists_no_abs1 (ty: _) (body: ty -> vprop) : Tot (ge_to_tele_t (GEExistsNoAbs1 #ty body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ body); let x = elim_exists' () in intro_pure True; intro_exists x (fun x -> body x `star` pure True); rewrite_with_trefl (exists_ _) (tele_p _) let compute_gen_elim_tele_correct_exists_unit1 (ty: _) (body: ty -> gen_unit_elim_i) : Tot (ge_to_tele_t (GEExistsUnit1 #ty body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_unit_elim_p (body x))); let x = elim_exists' () in let _ = compute_gen_unit_elim_f (body x) _ in intro_pure (compute_gen_unit_elim_post (body x)); intro_exists x (fun x -> compute_gen_unit_elim_q (body x) `star` pure (compute_gen_unit_elim_post (body x))); rewrite_with_trefl (exists_ _) (tele_p _) let compute_gen_elim_tele_correct_exists1 (ty: _) (body: ty -> gen_elim_i) (ih: (x: ty) -> GTot (ge_to_tele_t (body x))) : Tot (ge_to_tele_t (GEExists1 #ty body)) = fun _ -> rewrite_with_trefl (compute_gen_elim_p _) (exists_ (fun x -> compute_gen_elim_p (body x))); let x = elim_exists' () in ih x _; intro_exists x (fun x -> tele_p (compute_gen_elim_tele (body x))); rewrite_with_trefl (exists_ _) (tele_p _) let rec compute_gen_elim_tele_correct (x: gen_elim_i) : GTot (ge_to_tele_t x) = match x returns ge_to_tele_t x with | GEUnit v -> compute_gen_elim_tele_correct_unit v | GEStarL l ru -> compute_gen_elim_tele_correct_star_l l (compute_gen_elim_tele_correct l) ru | GEStarR lu r -> compute_gen_elim_tele_correct_star_r lu r (compute_gen_elim_tele_correct r) | GEStar l r -> compute_gen_elim_tele_correct_star l (compute_gen_elim_tele_correct l) r (compute_gen_elim_tele_correct r) | GEExistsNoAbs0 #ty body -> compute_gen_elim_tele_correct_exists_no_abs0 ty body | GEExistsUnit0 #ty body -> compute_gen_elim_tele_correct_exists_unit0 ty body | GEExists0 #ty body -> compute_gen_elim_tele_correct_exists0 ty body (fun x -> compute_gen_elim_tele_correct (body x)) | GEExistsNoAbs1 #ty body -> compute_gen_elim_tele_correct_exists_no_abs1 ty body | GEExistsUnit1 #ty body -> compute_gen_elim_tele_correct_exists_unit1 ty body | GEExists1 #ty body -> compute_gen_elim_tele_correct_exists1 ty body (fun x -> compute_gen_elim_tele_correct (body x)) let rec gen_elim_nondep_p (ty: list (Type u#a)) : Tot (curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop) = match ty as ty' returns curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> vprop) -> curried_function_type ty' (U.raise_t u#_ u#(max 2 a) unit -> prop) -> Tot vprop with | [] -> fun q post -> q (U.raise_val ()) `star` pure (post (U.raise_val ())) | t :: tq -> fun q post -> exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x)) let rec gen_elim_nondep_sem_correct (ty: list (Type u#a)) : Tot ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma (tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post) ) = match ty returns ((q: curried_function_type ty _) -> (post: curried_function_type ty _) -> Lemma (tele_p (gen_elim_nondep_sem ty q post) `equiv` gen_elim_nondep_p ty q post) ) with | [] -> fun q post -> equiv_refl (q (U.raise_val ()) `star` pure (post (U.raise_val ()))) | ta :: tq -> fun q post -> let phi (x: ta) : Lemma (tele_p (gen_elim_nondep_sem tq (q x) (post x)) `equiv` gen_elim_nondep_p tq (q x) (post x)) = gen_elim_nondep_sem_correct tq (q x) (post x) in Classical.forall_intro phi; let prf () : Lemma (exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) `equiv` exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))) = exists_equiv (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x))) (fun x -> gen_elim_nondep_p tq (q x) (post x)) in assert_norm (tele_p (gen_elim_nondep_sem (ta :: tq) q post) == exists_ (fun x -> tele_p (gen_elim_nondep_sem tq (q x) (post x)))); assert_norm (gen_elim_nondep_p (ta :: tq) q post == exists_ (fun x -> gen_elim_nondep_p tq (q x) (post x))); prf () let compute_gen_elim_nondep_correct_t (i0: gen_elim_i) (ty: list (Type u#1)) : Tot Type = (q: _) -> (post: _) -> (intro: vprop_rewrite (compute_gen_elim_p i0) (gen_elim_nondep_p ty q post)) -> GTot (gen_elim_f (compute_gen_elim_p i0) (compute_gen_elim_nondep_a' ty) (fun x -> compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) ty q x (U.raise_val ())) (fun x -> compute_uncurry _ (fun _ -> True) ty post x (U.raise_val ())) ) let compute_gen_elim_nondep_correct0 (i0: gen_elim_i) : Tot (compute_gen_elim_nondep_correct_t i0 []) = fun q post intro _ -> intro _; rewrite_with_trefl (gen_elim_nondep_p _ _ _) (q (U.raise_val ()) `star` pure (post (U.raise_val ()))); let res = U.raise_val () in elim_pure _; rewrite_with_trefl (q (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ())); res let compute_gen_elim_nondep_correct1 (i0: gen_elim_i) (t1: Type) : Tot (compute_gen_elim_nondep_correct_t i0 [t1]) = fun q post intro _ -> intro _; rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> q x1 (U.raise_val ()) `star` pure (post x1 (U.raise_val ())))); let res = elim_exists' () in elim_pure _; rewrite_with_trefl (q _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ())); res let compute_gen_elim_nondep_correct2 (i0: gen_elim_i) (t1 t2: Type) : Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2]) = fun q post intro _ -> intro _; rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> q x1 x2 (U.raise_val ()) `star` pure (post x1 x2 (U.raise_val ()))))); let x1 = elim_exists' () in let x2 = elim_exists' () in let res = Mktuple2 x1 x2 in elim_pure _; rewrite_with_trefl (q _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ())); res
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.GenElim1.fst" }
[ { "abbrev": true, "full_module": "FStar.Universe", "short_module": "U" }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": false, "full_module": "Steel.ST.GenElim1.Base", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i0: Steel.ST.GenElim1.Base.gen_elim_i -> t1: Type -> t2: Type -> t3: Type -> Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t i0 [t1; t2; t3]
Prims.Tot
[ "total" ]
[]
[ "Steel.ST.GenElim1.Base.gen_elim_i", "Steel.ST.GenElim1.Base.curried_function_type", "Prims.Cons", "Prims.Nil", "FStar.Universe.raise_t", "Prims.unit", "Steel.Effect.Common.vprop", "Prims.prop", "Steel.ST.GenElim1.vprop_rewrite", "Steel.ST.GenElim1.Base.compute_gen_elim_p", "Steel.ST.GenElim1.gen_elim_nondep_p", "Steel.Memory.inames", "Steel.ST.GenElim1.Base.compute_gen_elim_nondep_a'", "Steel.ST.GenElim1.rewrite_with_trefl", "FStar.Universe.raise_val", "Steel.ST.GenElim1.Base.compute_uncurry", "Steel.ST.GenElim1.Base.compute_gen_elim_p'", "Steel.ST.Util.elim_pure", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.Mktuple3", "Steel.ST.GenElim1.elim_exists'", "Steel.Effect.Common.VStar", "Steel.ST.Util.pure", "Steel.ST.Util.exists_", "Steel.Effect.Common.star", "Steel.ST.GenElim1.compute_gen_elim_nondep_correct_t" ]
[]
false
false
false
false
false
let compute_gen_elim_nondep_correct3 (i0: gen_elim_i) (t1 t2 t3: Type) : Tot (compute_gen_elim_nondep_correct_t i0 [t1; t2; t3]) =
fun q post intro _ -> intro _; rewrite_with_trefl (gen_elim_nondep_p _ _ _) (exists_ (fun x1 -> exists_ (fun x2 -> exists_ (fun x3 -> (q x1 x2 x3 (U.raise_val ())) `star` (pure (post x1 x2 x3 (U.raise_val ()))) )))); let x1 = elim_exists' () in let x2 = elim_exists' () in let x3 = elim_exists' () in let res = Mktuple3 x1 x2 x3 in elim_pure _; rewrite_with_trefl (q _ _ _ (U.raise_val ())) (compute_uncurry _ (fun _ -> compute_gen_elim_p' i0) _ _ res (U.raise_val ())); res
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.injective_fuel
val injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0
val injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 28, "end_line": 9, "start_col": 0, "start_line": 6 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fuel: Prims.nat -> p: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.bare_parser", "Prims.l_Forall", "LowParse.Bytes.bytes", "Prims.l_imp", "Prims.l_and", "LowParse.Spec.Base.injective_precond", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "LowParse.Spec.Base.injective_postcond" ]
[]
false
false
false
false
true
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1: bytes) (b2: bytes). {:pattern (injective_precond p b1 b2)\/(injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.no_lookahead_fuel
val no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0
val no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0
let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 179, "end_line": 16, "start_col": 0, "start_line": 11 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fuel: Prims.nat -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.bare_parser", "Prims.l_Forall", "LowParse.Bytes.bytes", "Prims.l_imp", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "LowParse.Spec.Base.no_lookahead_on", "LowParse.Spec.Base.no_lookahead_on_postcond", "LowParse.Spec.Base.no_lookahead_on_precond" ]
[]
false
false
false
false
true
let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (x: bytes) (x': bytes). {:pattern (no_lookahead_on_precond f x x')\/(no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.is_total_constant_size_parser_fuel
val is_total_constant_size_parser_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0
val is_total_constant_size_parser_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0
let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s))
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 44, "end_line": 66, "start_col": 0, "start_line": 59 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fuel: Prims.nat -> sz: Prims.nat -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.bare_parser", "Prims.l_Forall", "LowParse.Bytes.bytes", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.eq2", "Prims.bool", "FStar.Pervasives.Native.uu___is_None", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse" ]
[]
false
false
false
false
true
let is_total_constant_size_parser_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (s: bytes{Seq.length s < fuel}). {:pattern (parse f s)} (Seq.length s < sz) == (None? (parse f s))
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.parser_kind_prop_fuel
val parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0
val parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 41, "end_line": 82, "start_col": 0, "start_line": 77 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fuel: Prims.nat -> k: LowParse.Spec.Base.parser_kind -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.bare_parser", "Prims.l_and", "LowParse.Spec.Fuel.injective_fuel", "Prims.l_imp", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "LowParse.Spec.Fuel.parser_subkind_prop_fuel", "FStar.Pervasives.Native.__proj__Some__item__v", "LowParse.Spec.Fuel.parses_at_least_fuel", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "LowParse.Spec.Fuel.parses_at_most_fuel", "LowParse.Spec.Fuel.parser_kind_metadata_prop_fuel" ]
[]
false
false
false
false
true
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.parser_always_fails_fuel
val parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0
val parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 102, "end_line": 69, "start_col": 0, "start_line": 68 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fuel: Prims.nat -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.bare_parser", "Prims.l_Forall", "LowParse.Bytes.bytes", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "FStar.Pervasives.Native.None" ]
[]
false
false
false
false
true
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes{Seq.length input < fuel}). {:pattern (parse f input)} parse f input == None
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.parser_kind_prop'
val parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0
val parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 31, "end_line": 90, "start_col": 0, "start_line": 85 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: LowParse.Spec.Base.parser_kind -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.bare_parser", "Prims.l_and", "LowParse.Spec.Base.injective", "Prims.l_imp", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "LowParse.Spec.Base.parser_subkind_prop", "FStar.Pervasives.Native.__proj__Some__item__v", "LowParse.Spec.Base.parses_at_least", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "Prims.nat", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "LowParse.Spec.Base.parses_at_most", "LowParse.Spec.Base.parser_kind_metadata_prop" ]
[]
false
false
false
false
true
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.parser_subkind_prop_fuel
val parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0
val parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 28, "end_line": 33, "start_col": 0, "start_line": 28 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fuel: Prims.nat -> k: LowParse.Spec.Base.parser_subkind -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.bare_parser", "LowParse.Spec.Fuel.no_lookahead_fuel", "LowParse.Spec.Fuel.consumes_all_fuel" ]
[]
false
false
false
false
true
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.parses_at_most_fuel
val parses_at_most_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0
val parses_at_most_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0
let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) )
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 57, "start_col": 0, "start_line": 47 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fuel: Prims.nat -> sz: Prims.nat -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.bare_parser", "Prims.l_Forall", "LowParse.Bytes.bytes", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.l_imp", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "Prims.op_GreaterThanOrEqual", "Prims.logical", "FStar.Pervasives.Native.__proj__Some__item__v" ]
[]
false
false
false
false
true
let parses_at_most_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (s: bytes{Seq.length s < fuel}). {:pattern (parse f s)} Some? (parse f s) ==> (let _, consumed = Some?.v (parse f s) in sz >= (consumed <: nat))
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.parses_at_least_fuel
val parses_at_least_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0
val parses_at_least_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0
let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) )
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 45, "start_col": 0, "start_line": 35 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fuel: Prims.nat -> sz: Prims.nat -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.bare_parser", "Prims.l_Forall", "LowParse.Bytes.bytes", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.l_imp", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "Prims.op_LessThanOrEqual", "Prims.logical", "FStar.Pervasives.Native.__proj__Some__item__v" ]
[]
false
false
false
false
true
let parses_at_least_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (s: bytes{Seq.length s < fuel}). {:pattern (parse f s)} Some? (parse f s) ==> (let _, consumed = Some?.v (parse f s) in sz <= (consumed <: nat))
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.parser_kind_metadata_prop_fuel
val parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0
val parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 66, "end_line": 75, "start_col": 0, "start_line": 71 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fuel: Prims.nat -> k: LowParse.Spec.Base.parser_kind -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.bare_parser", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_metadata", "Prims.l_True", "Prims.l_imp", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "LowParse.Spec.Fuel.is_total_constant_size_parser_fuel", "LowParse.Spec.Fuel.parser_always_fails_fuel" ]
[]
false
false
false
false
true
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.close_by_fuel'
val close_by_fuel' (#t: Type) (f: (nat -> Tot (bare_parser t))) (closure: (b: bytes -> GTot (n: nat{Seq.length b < n}))) : Tot (bare_parser t)
val close_by_fuel' (#t: Type) (f: (nat -> Tot (bare_parser t))) (closure: (b: bytes -> GTot (n: nat{Seq.length b < n}))) : Tot (bare_parser t)
let close_by_fuel' (#t: Type) (f: (nat -> Tot (bare_parser t))) (closure: ((b: bytes) -> GTot (n: nat { Seq.length b < n }))) : Tot (bare_parser t) = fun x -> f (closure x) x
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 26, "end_line": 206, "start_col": 0, "start_line": 201 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f unfold let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f let injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . injective_fuel fuel f)) (ensures (injective f)) = assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f) let parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f) let parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f) let parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parser_subkind_prop_fuel fuel k f)) (ensures (parser_subkind_prop k f)) = assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f); assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f) let parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f)) (ensures (parser_kind_metadata_prop k f)) = assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f) let parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_prop_fuel fuel k f)) (ensures (parser_kind_prop' k f)) = injective_fuel_correct f; begin match k.parser_kind_subkind with | None -> () | Some k' -> parser_subkind_prop_fuel_correct k' f end; parses_at_least_fuel_correct k.parser_kind_low f; begin match k.parser_kind_high with | None -> () | Some max -> parses_at_most_fuel_correct max f end; parser_kind_metadata_prop_fuel_correct k f let parser_kind_prop_fuel_complete' (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop' k f)) (ensures (parser_kind_prop_fuel fuel k f)) = () let parser_kind_prop_fuel_complete (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop k f)) (ensures (parser_kind_prop_fuel fuel k f)) = parser_kind_prop_equiv k f let no_lookahead_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires ( forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b )) (ensures ( no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1 )) = Classical.forall_intro_2 (fun b1 -> Classical.move_requires (no_lookahead_on_ext p1 p2 b1)) let injective_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires ( forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b )) (ensures ( injective_fuel fuel p2 <==> injective_fuel fuel p1 )) = Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_precond_ext p1 p2 b1)); Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_postcond_ext p1 p2 b1)) let parser_kind_prop_fuel_ext (fuel: nat) (#t: Type) (k: parser_kind) (f1 f2: bare_parser t) : Lemma (requires (forall (input: bytes { Seq.length input < fuel }) . parse f1 input == parse f2 input)) (ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2)) = no_lookahead_fuel_ext fuel f1 f2; injective_fuel_ext fuel f1 f2
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: Prims.nat -> LowParse.Spec.Base.bare_parser t) -> closure: (b: LowParse.Bytes.bytes -> Prims.GTot (n: Prims.nat{FStar.Seq.Base.length b < n})) -> LowParse.Spec.Base.bare_parser t
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.bare_parser", "LowParse.Bytes.bytes", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length" ]
[]
false
false
false
false
false
let close_by_fuel' (#t: Type) (f: (nat -> Tot (bare_parser t))) (closure: (b: bytes -> GTot (n: nat{Seq.length b < n}))) : Tot (bare_parser t) =
fun x -> f (closure x) x
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.consumes_all_fuel
val consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0
val consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0
let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len )
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 26, "start_col": 0, "start_line": 18 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fuel: Prims.nat -> p: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.bare_parser", "Prims.l_Forall", "LowParse.Bytes.bytes", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.l_imp", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "Prims.eq2", "Prims.logical", "FStar.Pervasives.Native.option" ]
[]
false
false
false
false
true
let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b: bytes{Seq.length b < fuel}). {:pattern (parse p b)} Some? (parse p b) ==> (let Some (_, len) = parse p b in Seq.length b == len)
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.injective_fuel_correct
val injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel. injective_fuel fuel f)) (ensures (injective f))
val injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel. injective_fuel fuel f)) (ensures (injective f))
let injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . injective_fuel fuel f)) (ensures (injective f)) = assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 102, "end_line": 97, "start_col": 0, "start_line": 92 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f unfold let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: LowParse.Spec.Base.bare_parser t -> FStar.Pervasives.Lemma (requires forall (fuel: Prims.nat). LowParse.Spec.Fuel.injective_fuel fuel f) (ensures LowParse.Spec.Base.injective f)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.bare_parser", "Prims._assert", "Prims.l_Forall", "FStar.Seq.Base.seq", "LowParse.Bytes.byte", "Prims.l_imp", "LowParse.Spec.Base.injective_precond", "LowParse.Spec.Fuel.injective_fuel", "Prims.op_Addition", "FStar.Seq.Base.length", "Prims.unit", "Prims.nat", "Prims.squash", "LowParse.Spec.Base.injective", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel. injective_fuel fuel f)) (ensures (injective f)) =
assert (forall x y. injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.parses_at_most_fuel_correct
val parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel. parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f))
val parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel. parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f))
let parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f)
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 87, "end_line": 115, "start_col": 0, "start_line": 108 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f unfold let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f let injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . injective_fuel fuel f)) (ensures (injective f)) = assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f) let parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
sz: Prims.nat -> f: LowParse.Spec.Base.bare_parser t -> FStar.Pervasives.Lemma (requires forall (fuel: Prims.nat). LowParse.Spec.Fuel.parses_at_most_fuel fuel sz f) (ensures LowParse.Spec.Base.parses_at_most sz f)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.bare_parser", "Prims._assert", "Prims.l_Forall", "FStar.Seq.Base.seq", "LowParse.Bytes.byte", "Prims.l_imp", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "LowParse.Spec.Fuel.parses_at_most_fuel", "Prims.op_Addition", "FStar.Seq.Base.length", "Prims.unit", "Prims.squash", "LowParse.Spec.Base.parses_at_most", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel. parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) =
assert (forall x. Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f)
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.parser_subkind_prop_fuel_correct
val parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel. parser_subkind_prop_fuel fuel k f)) (ensures (parser_subkind_prop k f))
val parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel. parser_subkind_prop_fuel fuel k f)) (ensures (parser_subkind_prop k f))
let parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parser_subkind_prop_fuel fuel k f)) (ensures (parser_subkind_prop k f)) = assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f); assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f)
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 91, "end_line": 123, "start_col": 0, "start_line": 117 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f unfold let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f let injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . injective_fuel fuel f)) (ensures (injective f)) = assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f) let parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f) let parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: LowParse.Spec.Base.parser_subkind -> f: LowParse.Spec.Base.bare_parser t -> FStar.Pervasives.Lemma (requires forall (fuel: Prims.nat). LowParse.Spec.Fuel.parser_subkind_prop_fuel fuel k f) (ensures LowParse.Spec.Base.parser_subkind_prop k f)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.bare_parser", "Prims._assert", "Prims.l_Forall", "FStar.Seq.Base.seq", "LowParse.Bytes.byte", "Prims.l_imp", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "LowParse.Spec.Fuel.parser_subkind_prop_fuel", "Prims.op_Addition", "FStar.Seq.Base.length", "Prims.unit", "LowParse.Spec.Base.no_lookahead_on_precond", "Prims.nat", "Prims.squash", "LowParse.Spec.Base.parser_subkind_prop", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel. parser_subkind_prop_fuel fuel k f)) (ensures (parser_subkind_prop k f)) =
assert (forall x y. no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f); assert (forall x. Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f)
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.parser_kind_metadata_prop_fuel_correct
val parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel. parser_kind_metadata_prop_fuel fuel k f)) (ensures (parser_kind_metadata_prop k f))
val parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel. parser_kind_metadata_prop_fuel fuel k f)) (ensures (parser_kind_metadata_prop k f))
let parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f)) (ensures (parser_kind_metadata_prop k f)) = assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f)
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 99, "end_line": 130, "start_col": 0, "start_line": 125 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f unfold let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f let injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . injective_fuel fuel f)) (ensures (injective f)) = assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f) let parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f) let parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f) let parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parser_subkind_prop_fuel fuel k f)) (ensures (parser_subkind_prop k f)) = assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f); assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: LowParse.Spec.Base.parser_kind -> f: LowParse.Spec.Base.bare_parser t -> FStar.Pervasives.Lemma (requires forall (fuel: Prims.nat). LowParse.Spec.Fuel.parser_kind_metadata_prop_fuel fuel k f ) (ensures LowParse.Spec.Base.parser_kind_metadata_prop k f)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.bare_parser", "Prims._assert", "Prims.l_Forall", "FStar.Seq.Base.seq", "LowParse.Bytes.byte", "LowParse.Spec.Fuel.parser_kind_metadata_prop_fuel", "Prims.op_Addition", "FStar.Seq.Base.length", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "Prims.unit", "Prims.nat", "Prims.squash", "LowParse.Spec.Base.parser_kind_metadata_prop", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel. parser_kind_metadata_prop_fuel fuel k f)) (ensures (parser_kind_metadata_prop k f)) =
assert (forall x. let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f)
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.parses_at_least_fuel_correct
val parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel. parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f))
val parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel. parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f))
let parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f)
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 88, "end_line": 106, "start_col": 0, "start_line": 99 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f unfold let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f let injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . injective_fuel fuel f)) (ensures (injective f)) = assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
sz: Prims.nat -> f: LowParse.Spec.Base.bare_parser t -> FStar.Pervasives.Lemma (requires forall (fuel: Prims.nat). LowParse.Spec.Fuel.parses_at_least_fuel fuel sz f) (ensures LowParse.Spec.Base.parses_at_least sz f)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.bare_parser", "Prims._assert", "Prims.l_Forall", "FStar.Seq.Base.seq", "LowParse.Bytes.byte", "Prims.l_imp", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "LowParse.Spec.Fuel.parses_at_least_fuel", "Prims.op_Addition", "FStar.Seq.Base.length", "Prims.unit", "Prims.squash", "LowParse.Spec.Base.parses_at_least", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel. parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f)) =
assert (forall x. Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f)
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.parser_kind_prop_fuel_complete
val parser_kind_prop_fuel_complete (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop k f)) (ensures (parser_kind_prop_fuel fuel k f))
val parser_kind_prop_fuel_complete (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop k f)) (ensures (parser_kind_prop_fuel fuel k f))
let parser_kind_prop_fuel_complete (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop k f)) (ensures (parser_kind_prop_fuel fuel k f)) = parser_kind_prop_equiv k f
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 28, "end_line": 161, "start_col": 0, "start_line": 156 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f unfold let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f let injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . injective_fuel fuel f)) (ensures (injective f)) = assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f) let parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f) let parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f) let parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parser_subkind_prop_fuel fuel k f)) (ensures (parser_subkind_prop k f)) = assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f); assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f) let parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f)) (ensures (parser_kind_metadata_prop k f)) = assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f) let parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_prop_fuel fuel k f)) (ensures (parser_kind_prop' k f)) = injective_fuel_correct f; begin match k.parser_kind_subkind with | None -> () | Some k' -> parser_subkind_prop_fuel_correct k' f end; parses_at_least_fuel_correct k.parser_kind_low f; begin match k.parser_kind_high with | None -> () | Some max -> parses_at_most_fuel_correct max f end; parser_kind_metadata_prop_fuel_correct k f let parser_kind_prop_fuel_complete' (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop' k f)) (ensures (parser_kind_prop_fuel fuel k f)) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fuel: Prims.nat -> k: LowParse.Spec.Base.parser_kind -> f: LowParse.Spec.Base.bare_parser t -> FStar.Pervasives.Lemma (requires LowParse.Spec.Base.parser_kind_prop k f) (ensures LowParse.Spec.Fuel.parser_kind_prop_fuel fuel k f)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.bare_parser", "LowParse.Spec.Base.parser_kind_prop_equiv", "Prims.unit", "LowParse.Spec.Base.parser_kind_prop", "Prims.squash", "LowParse.Spec.Fuel.parser_kind_prop_fuel", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let parser_kind_prop_fuel_complete (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop k f)) (ensures (parser_kind_prop_fuel fuel k f)) =
parser_kind_prop_equiv k f
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.parser_kind_prop_fuel_correct
val parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel. parser_kind_prop_fuel fuel k f)) (ensures (parser_kind_prop' k f))
val parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel. parser_kind_prop_fuel fuel k f)) (ensures (parser_kind_prop' k f))
let parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_prop_fuel fuel k f)) (ensures (parser_kind_prop' k f)) = injective_fuel_correct f; begin match k.parser_kind_subkind with | None -> () | Some k' -> parser_subkind_prop_fuel_correct k' f end; parses_at_least_fuel_correct k.parser_kind_low f; begin match k.parser_kind_high with | None -> () | Some max -> parses_at_most_fuel_correct max f end; parser_kind_metadata_prop_fuel_correct k f
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 44, "end_line": 147, "start_col": 0, "start_line": 132 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f unfold let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f let injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . injective_fuel fuel f)) (ensures (injective f)) = assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f) let parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f) let parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f) let parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parser_subkind_prop_fuel fuel k f)) (ensures (parser_subkind_prop k f)) = assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f); assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f) let parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f)) (ensures (parser_kind_metadata_prop k f)) = assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: LowParse.Spec.Base.parser_kind -> f: LowParse.Spec.Base.bare_parser t -> FStar.Pervasives.Lemma (requires forall (fuel: Prims.nat). LowParse.Spec.Fuel.parser_kind_prop_fuel fuel k f) (ensures LowParse.Spec.Fuel.parser_kind_prop' k f)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.bare_parser", "LowParse.Spec.Fuel.parser_kind_metadata_prop_fuel_correct", "Prims.unit", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "Prims.nat", "LowParse.Spec.Fuel.parses_at_most_fuel_correct", "LowParse.Spec.Fuel.parses_at_least_fuel_correct", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Fuel.parser_subkind_prop_fuel_correct", "LowParse.Spec.Fuel.injective_fuel_correct", "Prims.l_Forall", "LowParse.Spec.Fuel.parser_kind_prop_fuel", "Prims.squash", "LowParse.Spec.Fuel.parser_kind_prop'", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel. parser_kind_prop_fuel fuel k f)) (ensures (parser_kind_prop' k f)) =
injective_fuel_correct f; (match k.parser_kind_subkind with | None -> () | Some k' -> parser_subkind_prop_fuel_correct k' f); parses_at_least_fuel_correct k.parser_kind_low f; (match k.parser_kind_high with | None -> () | Some max -> parses_at_most_fuel_correct max f); parser_kind_metadata_prop_fuel_correct k f
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.no_lookahead_fuel_ext
val no_lookahead_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires (forall (b: bytes{Seq.length b < fuel}). parse p2 b == parse p1 b)) (ensures (no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1))
val no_lookahead_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires (forall (b: bytes{Seq.length b < fuel}). parse p2 b == parse p1 b)) (ensures (no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1))
let no_lookahead_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires ( forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b )) (ensures ( no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1 )) = Classical.forall_intro_2 (fun b1 -> Classical.move_requires (no_lookahead_on_ext p1 p2 b1))
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 93, "end_line": 174, "start_col": 0, "start_line": 163 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f unfold let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f let injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . injective_fuel fuel f)) (ensures (injective f)) = assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f) let parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f) let parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f) let parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parser_subkind_prop_fuel fuel k f)) (ensures (parser_subkind_prop k f)) = assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f); assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f) let parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f)) (ensures (parser_kind_metadata_prop k f)) = assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f) let parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_prop_fuel fuel k f)) (ensures (parser_kind_prop' k f)) = injective_fuel_correct f; begin match k.parser_kind_subkind with | None -> () | Some k' -> parser_subkind_prop_fuel_correct k' f end; parses_at_least_fuel_correct k.parser_kind_low f; begin match k.parser_kind_high with | None -> () | Some max -> parses_at_most_fuel_correct max f end; parser_kind_metadata_prop_fuel_correct k f let parser_kind_prop_fuel_complete' (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop' k f)) (ensures (parser_kind_prop_fuel fuel k f)) = () let parser_kind_prop_fuel_complete (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop k f)) (ensures (parser_kind_prop_fuel fuel k f)) = parser_kind_prop_equiv k f
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fuel: Prims.nat -> p1: LowParse.Spec.Base.bare_parser t -> p2: LowParse.Spec.Base.bare_parser t -> FStar.Pervasives.Lemma (requires forall (b: LowParse.Bytes.bytes{FStar.Seq.Base.length b < fuel}). LowParse.Spec.Base.parse p2 b == LowParse.Spec.Base.parse p1 b) (ensures LowParse.Spec.Fuel.no_lookahead_fuel fuel p2 <==> LowParse.Spec.Fuel.no_lookahead_fuel fuel p1)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.bare_parser", "FStar.Classical.forall_intro_2", "LowParse.Bytes.bytes", "Prims.l_imp", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "Prims.l_iff", "LowParse.Spec.Base.no_lookahead_on", "FStar.Classical.move_requires", "LowParse.Spec.Base.no_lookahead_on_ext", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Prims.l_Forall", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "LowParse.Spec.Fuel.no_lookahead_fuel" ]
[]
false
false
true
false
false
let no_lookahead_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires (forall (b: bytes{Seq.length b < fuel}). parse p2 b == parse p1 b)) (ensures (no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1)) =
Classical.forall_intro_2 (fun b1 -> Classical.move_requires (no_lookahead_on_ext p1 p2 b1))
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.close_by_fuel_correct
val close_by_fuel_correct (#t: Type) (k: parser_kind) (f: (nat -> Tot (bare_parser t))) (closure: (b: bytes -> GTot (n: nat{Seq.length b < n}))) (f_ext: (fuel: nat -> b: bytes{Seq.length b < fuel} -> Lemma (f fuel b == f (closure b) b))) (f_prop: (fuel: nat -> Lemma (parser_kind_prop_fuel fuel k (f fuel)))) : Lemma (parser_kind_prop k (close_by_fuel' f closure))
val close_by_fuel_correct (#t: Type) (k: parser_kind) (f: (nat -> Tot (bare_parser t))) (closure: (b: bytes -> GTot (n: nat{Seq.length b < n}))) (f_ext: (fuel: nat -> b: bytes{Seq.length b < fuel} -> Lemma (f fuel b == f (closure b) b))) (f_prop: (fuel: nat -> Lemma (parser_kind_prop_fuel fuel k (f fuel)))) : Lemma (parser_kind_prop k (close_by_fuel' f closure))
let close_by_fuel_correct (#t: Type) (k: parser_kind) (f: (nat -> Tot (bare_parser t))) (closure: ((b: bytes) -> GTot (n: nat { Seq.length b < n }))) (f_ext: ( (fuel: nat) -> (b: bytes { Seq.length b < fuel }) -> Lemma (f fuel b == f (closure b) b) )) (f_prop: ( (fuel: nat) -> Lemma (parser_kind_prop_fuel fuel k (f fuel)) )) : Lemma (parser_kind_prop k (close_by_fuel' f closure)) = let prf (fuel: nat) : Lemma (parser_kind_prop_fuel fuel k (close_by_fuel' f closure)) = f_prop fuel; let g (b: bytes { Seq.length b < fuel }) : Lemma (parse (close_by_fuel' f closure) b == parse (f fuel) b) = f_ext fuel b in Classical.forall_intro g; parser_kind_prop_fuel_ext fuel k (close_by_fuel' f closure) (f fuel) in Classical.forall_intro prf; parser_kind_prop_fuel_correct k (close_by_fuel' f closure); parser_kind_prop_equiv k (close_by_fuel' f closure)
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 53, "end_line": 242, "start_col": 0, "start_line": 208 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f unfold let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f let injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . injective_fuel fuel f)) (ensures (injective f)) = assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f) let parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f) let parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f) let parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parser_subkind_prop_fuel fuel k f)) (ensures (parser_subkind_prop k f)) = assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f); assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f) let parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f)) (ensures (parser_kind_metadata_prop k f)) = assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f) let parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_prop_fuel fuel k f)) (ensures (parser_kind_prop' k f)) = injective_fuel_correct f; begin match k.parser_kind_subkind with | None -> () | Some k' -> parser_subkind_prop_fuel_correct k' f end; parses_at_least_fuel_correct k.parser_kind_low f; begin match k.parser_kind_high with | None -> () | Some max -> parses_at_most_fuel_correct max f end; parser_kind_metadata_prop_fuel_correct k f let parser_kind_prop_fuel_complete' (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop' k f)) (ensures (parser_kind_prop_fuel fuel k f)) = () let parser_kind_prop_fuel_complete (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop k f)) (ensures (parser_kind_prop_fuel fuel k f)) = parser_kind_prop_equiv k f let no_lookahead_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires ( forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b )) (ensures ( no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1 )) = Classical.forall_intro_2 (fun b1 -> Classical.move_requires (no_lookahead_on_ext p1 p2 b1)) let injective_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires ( forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b )) (ensures ( injective_fuel fuel p2 <==> injective_fuel fuel p1 )) = Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_precond_ext p1 p2 b1)); Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_postcond_ext p1 p2 b1)) let parser_kind_prop_fuel_ext (fuel: nat) (#t: Type) (k: parser_kind) (f1 f2: bare_parser t) : Lemma (requires (forall (input: bytes { Seq.length input < fuel }) . parse f1 input == parse f2 input)) (ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2)) = no_lookahead_fuel_ext fuel f1 f2; injective_fuel_ext fuel f1 f2 let close_by_fuel' (#t: Type) (f: (nat -> Tot (bare_parser t))) (closure: ((b: bytes) -> GTot (n: nat { Seq.length b < n }))) : Tot (bare_parser t) = fun x -> f (closure x) x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: LowParse.Spec.Base.parser_kind -> f: (_: Prims.nat -> LowParse.Spec.Base.bare_parser t) -> closure: (b: LowParse.Bytes.bytes -> Prims.GTot (n: Prims.nat{FStar.Seq.Base.length b < n})) -> f_ext: (fuel: Prims.nat -> b: LowParse.Bytes.bytes{FStar.Seq.Base.length b < fuel} -> FStar.Pervasives.Lemma (ensures f fuel b == f (closure b) b)) -> f_prop: (fuel: Prims.nat -> FStar.Pervasives.Lemma (ensures LowParse.Spec.Fuel.parser_kind_prop_fuel fuel k (f fuel))) -> FStar.Pervasives.Lemma (ensures LowParse.Spec.Base.parser_kind_prop k (LowParse.Spec.Fuel.close_by_fuel' f closure))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "Prims.nat", "LowParse.Spec.Base.bare_parser", "LowParse.Bytes.bytes", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "Prims.Nil", "FStar.Pervasives.pattern", "LowParse.Spec.Fuel.parser_kind_prop_fuel", "LowParse.Spec.Base.parser_kind_prop_equiv", "LowParse.Spec.Fuel.close_by_fuel'", "LowParse.Spec.Fuel.parser_kind_prop_fuel_correct", "FStar.Classical.forall_intro", "LowParse.Spec.Fuel.parser_kind_prop_fuel_ext", "LowParse.Spec.Base.parse", "LowParse.Spec.Base.parser_kind_prop" ]
[]
false
false
true
false
false
let close_by_fuel_correct (#t: Type) (k: parser_kind) (f: (nat -> Tot (bare_parser t))) (closure: (b: bytes -> GTot (n: nat{Seq.length b < n}))) (f_ext: (fuel: nat -> b: bytes{Seq.length b < fuel} -> Lemma (f fuel b == f (closure b) b))) (f_prop: (fuel: nat -> Lemma (parser_kind_prop_fuel fuel k (f fuel)))) : Lemma (parser_kind_prop k (close_by_fuel' f closure)) =
let prf (fuel: nat) : Lemma (parser_kind_prop_fuel fuel k (close_by_fuel' f closure)) = f_prop fuel; let g (b: bytes{Seq.length b < fuel}) : Lemma (parse (close_by_fuel' f closure) b == parse (f fuel) b) = f_ext fuel b in Classical.forall_intro g; parser_kind_prop_fuel_ext fuel k (close_by_fuel' f closure) (f fuel) in Classical.forall_intro prf; parser_kind_prop_fuel_correct k (close_by_fuel' f closure); parser_kind_prop_equiv k (close_by_fuel' f closure)
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.parser_kind_prop_fuel_ext
val parser_kind_prop_fuel_ext (fuel: nat) (#t: Type) (k: parser_kind) (f1 f2: bare_parser t) : Lemma (requires (forall (input: bytes{Seq.length input < fuel}). parse f1 input == parse f2 input)) (ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2))
val parser_kind_prop_fuel_ext (fuel: nat) (#t: Type) (k: parser_kind) (f1 f2: bare_parser t) : Lemma (requires (forall (input: bytes{Seq.length input < fuel}). parse f1 input == parse f2 input)) (ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2))
let parser_kind_prop_fuel_ext (fuel: nat) (#t: Type) (k: parser_kind) (f1 f2: bare_parser t) : Lemma (requires (forall (input: bytes { Seq.length input < fuel }) . parse f1 input == parse f2 input)) (ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2)) = no_lookahead_fuel_ext fuel f1 f2; injective_fuel_ext fuel f1 f2
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 31, "end_line": 199, "start_col": 0, "start_line": 190 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f unfold let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f let injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . injective_fuel fuel f)) (ensures (injective f)) = assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f) let parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f) let parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f) let parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parser_subkind_prop_fuel fuel k f)) (ensures (parser_subkind_prop k f)) = assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f); assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f) let parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f)) (ensures (parser_kind_metadata_prop k f)) = assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f) let parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_prop_fuel fuel k f)) (ensures (parser_kind_prop' k f)) = injective_fuel_correct f; begin match k.parser_kind_subkind with | None -> () | Some k' -> parser_subkind_prop_fuel_correct k' f end; parses_at_least_fuel_correct k.parser_kind_low f; begin match k.parser_kind_high with | None -> () | Some max -> parses_at_most_fuel_correct max f end; parser_kind_metadata_prop_fuel_correct k f let parser_kind_prop_fuel_complete' (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop' k f)) (ensures (parser_kind_prop_fuel fuel k f)) = () let parser_kind_prop_fuel_complete (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop k f)) (ensures (parser_kind_prop_fuel fuel k f)) = parser_kind_prop_equiv k f let no_lookahead_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires ( forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b )) (ensures ( no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1 )) = Classical.forall_intro_2 (fun b1 -> Classical.move_requires (no_lookahead_on_ext p1 p2 b1)) let injective_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires ( forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b )) (ensures ( injective_fuel fuel p2 <==> injective_fuel fuel p1 )) = Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_precond_ext p1 p2 b1)); Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_postcond_ext p1 p2 b1))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fuel: Prims.nat -> k: LowParse.Spec.Base.parser_kind -> f1: LowParse.Spec.Base.bare_parser t -> f2: LowParse.Spec.Base.bare_parser t -> FStar.Pervasives.Lemma (requires forall (input: LowParse.Bytes.bytes{FStar.Seq.Base.length input < fuel}). LowParse.Spec.Base.parse f1 input == LowParse.Spec.Base.parse f2 input) (ensures LowParse.Spec.Fuel.parser_kind_prop_fuel fuel k f1 <==> LowParse.Spec.Fuel.parser_kind_prop_fuel fuel k f2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.bare_parser", "LowParse.Spec.Fuel.injective_fuel_ext", "Prims.unit", "LowParse.Spec.Fuel.no_lookahead_fuel_ext", "Prims.l_Forall", "LowParse.Bytes.bytes", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "Prims.squash", "Prims.l_iff", "LowParse.Spec.Fuel.parser_kind_prop_fuel", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let parser_kind_prop_fuel_ext (fuel: nat) (#t: Type) (k: parser_kind) (f1 f2: bare_parser t) : Lemma (requires (forall (input: bytes{Seq.length input < fuel}). parse f1 input == parse f2 input)) (ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2)) =
no_lookahead_fuel_ext fuel f1 f2; injective_fuel_ext fuel f1 f2
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.injective_fuel_ext
val injective_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires (forall (b: bytes{Seq.length b < fuel}). parse p2 b == parse p1 b)) (ensures (injective_fuel fuel p2 <==> injective_fuel fuel p1))
val injective_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires (forall (b: bytes{Seq.length b < fuel}). parse p2 b == parse p1 b)) (ensures (injective_fuel fuel p2 <==> injective_fuel fuel p1))
let injective_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires ( forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b )) (ensures ( injective_fuel fuel p2 <==> injective_fuel fuel p1 )) = Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_precond_ext p1 p2 b1)); Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_postcond_ext p1 p2 b1))
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 96, "end_line": 188, "start_col": 0, "start_line": 176 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f unfold let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f let injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . injective_fuel fuel f)) (ensures (injective f)) = assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f) let parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f) let parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f) let parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parser_subkind_prop_fuel fuel k f)) (ensures (parser_subkind_prop k f)) = assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f); assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f) let parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f)) (ensures (parser_kind_metadata_prop k f)) = assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f) let parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_prop_fuel fuel k f)) (ensures (parser_kind_prop' k f)) = injective_fuel_correct f; begin match k.parser_kind_subkind with | None -> () | Some k' -> parser_subkind_prop_fuel_correct k' f end; parses_at_least_fuel_correct k.parser_kind_low f; begin match k.parser_kind_high with | None -> () | Some max -> parses_at_most_fuel_correct max f end; parser_kind_metadata_prop_fuel_correct k f let parser_kind_prop_fuel_complete' (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop' k f)) (ensures (parser_kind_prop_fuel fuel k f)) = () let parser_kind_prop_fuel_complete (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop k f)) (ensures (parser_kind_prop_fuel fuel k f)) = parser_kind_prop_equiv k f let no_lookahead_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires ( forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b )) (ensures ( no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1 )) = Classical.forall_intro_2 (fun b1 -> Classical.move_requires (no_lookahead_on_ext p1 p2 b1))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
fuel: Prims.nat -> p1: LowParse.Spec.Base.bare_parser t -> p2: LowParse.Spec.Base.bare_parser t -> FStar.Pervasives.Lemma (requires forall (b: LowParse.Bytes.bytes{FStar.Seq.Base.length b < fuel}). LowParse.Spec.Base.parse p2 b == LowParse.Spec.Base.parse p1 b) (ensures LowParse.Spec.Fuel.injective_fuel fuel p2 <==> LowParse.Spec.Fuel.injective_fuel fuel p1)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "LowParse.Spec.Base.bare_parser", "FStar.Classical.forall_intro_2", "LowParse.Bytes.bytes", "Prims.l_imp", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "Prims.l_iff", "LowParse.Spec.Base.injective_postcond", "FStar.Classical.move_requires", "LowParse.Spec.Base.injective_postcond_ext", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "LowParse.Spec.Base.injective_precond", "LowParse.Spec.Base.injective_precond_ext", "Prims.l_Forall", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "LowParse.Spec.Fuel.injective_fuel" ]
[]
false
false
true
false
false
let injective_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires (forall (b: bytes{Seq.length b < fuel}). parse p2 b == parse p1 b)) (ensures (injective_fuel fuel p2 <==> injective_fuel fuel p1)) =
Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_precond_ext p1 p2 b1)); Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_postcond_ext p1 p2 b1))
false
LowParse.Spec.Fuel.fst
LowParse.Spec.Fuel.close_by_fuel
val close_by_fuel (#k: parser_kind) (#t: Type) (f: (nat -> Tot (parser k t))) (closure: (b: bytes -> Tot (n: nat{Seq.length b < n}))) (f_ext: (fuel: nat -> b: bytes{Seq.length b < fuel} -> Lemma (f fuel b == f (closure b) b))) : Tot (parser k t)
val close_by_fuel (#k: parser_kind) (#t: Type) (f: (nat -> Tot (parser k t))) (closure: (b: bytes -> Tot (n: nat{Seq.length b < n}))) (f_ext: (fuel: nat -> b: bytes{Seq.length b < fuel} -> Lemma (f fuel b == f (closure b) b))) : Tot (parser k t)
let close_by_fuel (#k: parser_kind) (#t: Type) (f: (nat -> Tot (parser k t))) (closure: ((b: bytes) -> Tot (n: nat { Seq.length b < n }))) (f_ext: ( (fuel: nat) -> (b: bytes { Seq.length b < fuel }) -> Lemma (f fuel b == f (closure b) b) )) : Tot (parser k t) = close_by_fuel_correct k f closure f_ext (fun fuel -> parser_kind_prop_equiv k (f fuel)); close_by_fuel' f closure
{ "file_name": "src/lowparse/LowParse.Spec.Fuel.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 26, "end_line": 257, "start_col": 0, "start_line": 244 }
module LowParse.Spec.Fuel include LowParse.Spec.Base module Seq = FStar.Seq let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)} (injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==> injective_postcond p b1 b2 let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> ( let (Some (_, len)) = parse p b in Seq.length b == len ) let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 = match k with | ParserStrong -> no_lookahead_fuel fuel f | ParserConsumesAll -> consumes_all_fuel fuel f let parses_at_least_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz <= (consumed <: nat) ) let parses_at_most_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)} Some? (parse f s) ==> ( let (_, consumed) = Some?.v (parse f s) in sz >= (consumed <: nat) ) let is_total_constant_size_parser_fuel (fuel: nat) (sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) } (Seq.length s < sz) == (None? (parse f s)) let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = match k.parser_kind_metadata with | None -> True | Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f | Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective_fuel fuel f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\ parses_at_least_fuel fuel k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop_fuel fuel k f unfold let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = injective f /\ (Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\ parses_at_least k.parser_kind_low f /\ (Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\ parser_kind_metadata_prop k f let injective_fuel_correct (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . injective_fuel fuel f)) (ensures (injective f)) = assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f) let parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_least_fuel fuel sz f)) (ensures (parses_at_least sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f) let parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) = assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f) let parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t) : Lemma (requires (forall fuel . parser_subkind_prop_fuel fuel k f)) (ensures (parser_subkind_prop k f)) = assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f); assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f) let parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f)) (ensures (parser_kind_metadata_prop k f)) = assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f) let parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (forall fuel . parser_kind_prop_fuel fuel k f)) (ensures (parser_kind_prop' k f)) = injective_fuel_correct f; begin match k.parser_kind_subkind with | None -> () | Some k' -> parser_subkind_prop_fuel_correct k' f end; parses_at_least_fuel_correct k.parser_kind_low f; begin match k.parser_kind_high with | None -> () | Some max -> parses_at_most_fuel_correct max f end; parser_kind_metadata_prop_fuel_correct k f let parser_kind_prop_fuel_complete' (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop' k f)) (ensures (parser_kind_prop_fuel fuel k f)) = () let parser_kind_prop_fuel_complete (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : Lemma (requires (parser_kind_prop k f)) (ensures (parser_kind_prop_fuel fuel k f)) = parser_kind_prop_equiv k f let no_lookahead_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires ( forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b )) (ensures ( no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1 )) = Classical.forall_intro_2 (fun b1 -> Classical.move_requires (no_lookahead_on_ext p1 p2 b1)) let injective_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t) : Lemma (requires ( forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b )) (ensures ( injective_fuel fuel p2 <==> injective_fuel fuel p1 )) = Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_precond_ext p1 p2 b1)); Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_postcond_ext p1 p2 b1)) let parser_kind_prop_fuel_ext (fuel: nat) (#t: Type) (k: parser_kind) (f1 f2: bare_parser t) : Lemma (requires (forall (input: bytes { Seq.length input < fuel }) . parse f1 input == parse f2 input)) (ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2)) = no_lookahead_fuel_ext fuel f1 f2; injective_fuel_ext fuel f1 f2 let close_by_fuel' (#t: Type) (f: (nat -> Tot (bare_parser t))) (closure: ((b: bytes) -> GTot (n: nat { Seq.length b < n }))) : Tot (bare_parser t) = fun x -> f (closure x) x let close_by_fuel_correct (#t: Type) (k: parser_kind) (f: (nat -> Tot (bare_parser t))) (closure: ((b: bytes) -> GTot (n: nat { Seq.length b < n }))) (f_ext: ( (fuel: nat) -> (b: bytes { Seq.length b < fuel }) -> Lemma (f fuel b == f (closure b) b) )) (f_prop: ( (fuel: nat) -> Lemma (parser_kind_prop_fuel fuel k (f fuel)) )) : Lemma (parser_kind_prop k (close_by_fuel' f closure)) = let prf (fuel: nat) : Lemma (parser_kind_prop_fuel fuel k (close_by_fuel' f closure)) = f_prop fuel; let g (b: bytes { Seq.length b < fuel }) : Lemma (parse (close_by_fuel' f closure) b == parse (f fuel) b) = f_ext fuel b in Classical.forall_intro g; parser_kind_prop_fuel_ext fuel k (close_by_fuel' f closure) (f fuel) in Classical.forall_intro prf; parser_kind_prop_fuel_correct k (close_by_fuel' f closure); parser_kind_prop_equiv k (close_by_fuel' f closure)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.Fuel.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
f: (_: Prims.nat -> LowParse.Spec.Base.parser k t) -> closure: (b: LowParse.Bytes.bytes -> n: Prims.nat{FStar.Seq.Base.length b < n}) -> f_ext: (fuel: Prims.nat -> b: LowParse.Bytes.bytes{FStar.Seq.Base.length b < fuel} -> FStar.Pervasives.Lemma (ensures f fuel b == f (closure b) b)) -> LowParse.Spec.Base.parser k t
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "Prims.nat", "LowParse.Spec.Base.parser", "LowParse.Bytes.bytes", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "Prims.Nil", "FStar.Pervasives.pattern", "LowParse.Spec.Fuel.close_by_fuel'", "LowParse.Spec.Fuel.close_by_fuel_correct", "LowParse.Spec.Base.parser_kind_prop_equiv" ]
[]
false
false
false
false
false
let close_by_fuel (#k: parser_kind) (#t: Type) (f: (nat -> Tot (parser k t))) (closure: (b: bytes -> Tot (n: nat{Seq.length b < n}))) (f_ext: (fuel: nat -> b: bytes{Seq.length b < fuel} -> Lemma (f fuel b == f (closure b) b))) : Tot (parser k t) =
close_by_fuel_correct k f closure f_ext (fun fuel -> parser_kind_prop_equiv k (f fuel)); close_by_fuel' f closure
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.is_aes_key_LE
val is_aes_key_LE (alg: algorithm) (s: seq nat32) : prop0
val is_aes_key_LE (alg: algorithm) (s: seq nat32) : prop0
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 76, "end_line": 31, "start_col": 0, "start_line": 31 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> s: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> Vale.Def.Prop_s.prop0
Prims.Tot
[ "total" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length", "Vale.AES.AES_common_s.nk", "Vale.Def.Prop_s.prop0" ]
[]
false
false
false
true
false
let is_aes_key_LE (alg: algorithm) (s: seq nat32) : prop0 =
length s == nk alg
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.eval_round
val eval_round : state: Vale.Def.Types_s.quad32 -> round_key: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32
let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 39, "start_col": 0, "start_line": 34 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
state: Vale.Def.Types_s.quad32 -> round_key: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32
Prims.Tot
[ "total" ]
[]
[ "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.quad32_xor", "Vale.AES.AES_s.mix_columns_LE", "Vale.AES.AES_s.shift_rows_LE", "Vale.AES.AES_common_s.sub_bytes" ]
[]
false
false
false
true
false
let eval_round (state round_key: quad32) =
let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.eval_rounds
val eval_rounds : _: Vale.Def.Types_s.quad32 -> _: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> _: n: Prims.nat{n < FStar.Seq.Base.length _} -> Vale.Def.Types_s.quad32
let eval_rounds = opaque_make eval_rounds_def
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 64, "end_line": 46, "start_col": 19, "start_line": 46 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 = if n = 0 then init else
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Vale.Def.Types_s.quad32 -> _: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> _: n: Prims.nat{n < FStar.Seq.Base.length _} -> Vale.Def.Types_s.quad32
Prims.Tot
[ "total" ]
[]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.AES.AES_s.eval_rounds_def" ]
[]
false
false
false
false
false
let eval_rounds =
opaque_make eval_rounds_def
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.eval_rounds_reveal
val eval_rounds_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.AES.AES_s.eval_rounds == Vale.AES.AES_s.eval_rounds_def)
let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 96, "end_line": 47, "start_col": 12, "start_line": 47 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 = if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.AES.AES_s.eval_rounds == Vale.AES.AES_s.eval_rounds_def)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.AES.AES_s.eval_rounds", "Vale.AES.AES_s.eval_rounds_def" ]
[]
true
false
true
false
false
let eval_rounds_reveal =
opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.eval_rounds_def
val eval_rounds_def (init: quad32) (round_keys: seq quad32) (n: nat{n < length round_keys}) : quad32
val eval_rounds_def (init: quad32) (round_keys: seq quad32) (n: nat{n < length round_keys}) : quad32
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 = if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 77, "end_line": 45, "start_col": 0, "start_line": 41 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
init: Vale.Def.Types_s.quad32 -> round_keys: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> n: Prims.nat{n < FStar.Seq.Base.length round_keys} -> Vale.Def.Types_s.quad32
Prims.Tot
[ "total" ]
[]
[ "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Prims.op_Equality", "Prims.int", "Prims.bool", "Vale.AES.AES_s.eval_round", "Vale.AES.AES_s.eval_rounds_def", "Prims.op_Subtraction", "FStar.Seq.Base.index" ]
[ "recursion" ]
false
false
false
false
false
let rec eval_rounds_def (init: quad32) (round_keys: seq quad32) (n: nat{n < length round_keys}) : quad32 =
if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.eval_cipher
val eval_cipher : alg: Vale.AES.AES_common_s.algorithm -> input: Vale.Def.Types_s.quad32 -> round_keys: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> Prims.Pure Vale.Def.Types_s.quad32
let eval_cipher = opaque_make eval_cipher_def
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 64, "end_line": 59, "start_col": 19, "start_line": 59 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 = if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n) [@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) = let state = quad32_xor input (index round_keys 0) in let state = eval_rounds_def state round_keys (nr alg - 1) in let state = sub_bytes state in let state = shift_rows_LE state in let state = quad32_xor state (index round_keys (nr alg)) in
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> input: Vale.Def.Types_s.quad32 -> round_keys: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> Prims.Pure Vale.Def.Types_s.quad32
Prims.Pure
[]
[]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.AES.AES_common_s.algorithm", "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length", "Prims.op_Addition", "Vale.AES.AES_common_s.nr", "Prims.l_True", "Vale.AES.AES_s.eval_cipher_def" ]
[]
false
false
false
false
false
let eval_cipher =
opaque_make eval_cipher_def
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.eval_cipher_reveal
val eval_cipher_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.AES.AES_s.eval_cipher == Vale.AES.AES_s.eval_cipher_def)
let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 96, "end_line": 60, "start_col": 12, "start_line": 60 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 = if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n) [@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) = let state = quad32_xor input (index round_keys 0) in let state = eval_rounds_def state round_keys (nr alg - 1) in let state = sub_bytes state in let state = shift_rows_LE state in let state = quad32_xor state (index round_keys (nr alg)) in state
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.AES.AES_s.eval_cipher == Vale.AES.AES_s.eval_cipher_def)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.AES.AES_common_s.algorithm", "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length", "Prims.op_Addition", "Vale.AES.AES_common_s.nr", "Prims.l_True", "Vale.AES.AES_s.eval_cipher", "Vale.AES.AES_s.eval_cipher_def" ]
[]
true
false
true
false
false
let eval_cipher_reveal =
opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.expand_key
val expand_key : _: Vale.AES.AES_common_s.algorithm -> _: Vale.AES.AES_s.aes_key_LE _ -> _: size: Prims.nat{size <= Vale.AES.AES_common_s.nb * (Vale.AES.AES_common_s.nr _ + 1)} -> ek_LE: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 {FStar.Seq.Base.length ek_LE == _}
let expand_key = opaque_make expand_key_def
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 80, "start_col": 19, "start_line": 80 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 = if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n) [@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) = let state = quad32_xor input (index round_keys 0) in let state = eval_rounds_def state round_keys (nr alg - 1) in let state = sub_bytes state in let state = shift_rows_LE state in let state = quad32_xor state (index round_keys (nr alg)) in state [@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))}) : (ek_LE:seq nat32 {length ek_LE == size}) = if size = 0 then empty else let w = expand_key_def alg key (size - 1) in let i = size - 1 in if 0 <= i && i < nk alg then append w (create 1 (index key i)) else let temp = if i % (nk alg) = 0 then nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1)) else if nk alg > 6 && i % (nk alg) = 4 then sub_word (index w (i - 1)) else index w (i - 1) in
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Vale.AES.AES_common_s.algorithm -> _: Vale.AES.AES_s.aes_key_LE _ -> _: size: Prims.nat{size <= Vale.AES.AES_common_s.nb * (Vale.AES.AES_common_s.nr _ + 1)} -> ek_LE: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 {FStar.Seq.Base.length ek_LE == _}
Prims.Tot
[ "total" ]
[]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.AES.AES_common_s.algorithm", "Vale.AES.AES_s.aes_key_LE", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Vale.AES.AES_common_s.nb", "Prims.op_Addition", "Vale.AES.AES_common_s.nr", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Prims.eq2", "FStar.Seq.Base.length", "Vale.AES.AES_s.expand_key_def" ]
[]
false
false
false
false
false
let expand_key =
opaque_make expand_key_def
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.expand_key_reveal
val expand_key_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.AES.AES_s.expand_key == Vale.AES.AES_s.expand_key_def)
let expand_key_reveal = opaque_revealer (`%expand_key) expand_key expand_key_def
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 92, "end_line": 81, "start_col": 12, "start_line": 81 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 = if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n) [@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) = let state = quad32_xor input (index round_keys 0) in let state = eval_rounds_def state round_keys (nr alg - 1) in let state = sub_bytes state in let state = shift_rows_LE state in let state = quad32_xor state (index round_keys (nr alg)) in state [@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))}) : (ek_LE:seq nat32 {length ek_LE == size}) = if size = 0 then empty else let w = expand_key_def alg key (size - 1) in let i = size - 1 in if 0 <= i && i < nk alg then append w (create 1 (index key i)) else let temp = if i % (nk alg) = 0 then nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1)) else if nk alg > 6 && i % (nk alg) = 4 then sub_word (index w (i - 1)) else index w (i - 1) in append w (create 1 (nat32_xor (index w (i - (nk alg))) temp))
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.AES.AES_s.expand_key == Vale.AES.AES_s.expand_key_def)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.AES.AES_common_s.algorithm", "Vale.AES.AES_s.aes_key_LE", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Vale.AES.AES_common_s.nb", "Prims.op_Addition", "Vale.AES.AES_common_s.nr", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Prims.eq2", "FStar.Seq.Base.length", "Vale.AES.AES_s.expand_key", "Vale.AES.AES_s.expand_key_def" ]
[]
true
false
true
false
false
let expand_key_reveal =
opaque_revealer (`%expand_key) expand_key expand_key_def
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.eval_cipher_def
val eval_cipher_def (alg: algorithm) (input: quad32) (round_keys: seq quad32) : Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True)
val eval_cipher_def (alg: algorithm) (input: quad32) (round_keys: seq quad32) : Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True)
let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) = let state = quad32_xor input (index round_keys 0) in let state = eval_rounds_def state round_keys (nr alg - 1) in let state = sub_bytes state in let state = shift_rows_LE state in let state = quad32_xor state (index round_keys (nr alg)) in state
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 7, "end_line": 58, "start_col": 0, "start_line": 49 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 = if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n) [@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> input: Vale.Def.Types_s.quad32 -> round_keys: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> Prims.Pure Vale.Def.Types_s.quad32
Prims.Pure
[]
[]
[ "Vale.AES.AES_common_s.algorithm", "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32_xor", "FStar.Seq.Base.index", "Vale.AES.AES_common_s.nr", "Vale.AES.AES_s.shift_rows_LE", "Vale.AES.AES_common_s.sub_bytes", "Vale.AES.AES_s.eval_rounds_def", "Prims.op_Subtraction", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length", "Prims.op_Addition", "Prims.l_True" ]
[]
false
false
false
false
false
let eval_cipher_def (alg: algorithm) (input: quad32) (round_keys: seq quad32) : Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) =
let state = quad32_xor input (index round_keys 0) in let state = eval_rounds_def state round_keys (nr alg - 1) in let state = sub_bytes state in let state = shift_rows_LE state in let state = quad32_xor state (index round_keys (nr alg)) in state
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.aes_encrypt_LE
val aes_encrypt_LE : alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> input_LE: Vale.Def.Types_s.quad32 -> Prims.Pure Vale.Def.Types_s.quad32
let aes_encrypt_LE = opaque_make aes_encrypt_LE_def
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 70, "end_line": 103, "start_col": 19, "start_line": 103 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 = if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n) [@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) = let state = quad32_xor input (index round_keys 0) in let state = eval_rounds_def state round_keys (nr alg - 1) in let state = sub_bytes state in let state = shift_rows_LE state in let state = quad32_xor state (index round_keys (nr alg)) in state [@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))}) : (ek_LE:seq nat32 {length ek_LE == size}) = if size = 0 then empty else let w = expand_key_def alg key (size - 1) in let i = size - 1 in if 0 <= i && i < nk alg then append w (create 1 (index key i)) else let temp = if i % (nk alg) = 0 then nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1)) else if nk alg > 6 && i % (nk alg) = 4 then sub_word (index w (i - 1)) else index w (i - 1) in append w (create 1 (nat32_xor (index w (i - (nk alg))) temp)) [@"opaque_to_smt"] let expand_key = opaque_make expand_key_def irreducible let expand_key_reveal = opaque_revealer (`%expand_key) expand_key expand_key_def let rec key_schedule_to_round_keys (rounds:nat) (w:seq nat32 {length w >= 4 * rounds}) : (round_keys:seq quad32 {length round_keys == rounds}) = if rounds = 0 then empty else let round_keys = key_schedule_to_round_keys (rounds - 1) w in let rk = Mkfour (index w (4 * rounds - 4)) (index w (4 * rounds - 3)) (index w (4 * rounds - 2)) (index w (4 * rounds - 1)) in append round_keys (create 1 rk) [@"opaque_to_smt"] let key_to_round_keys_LE (alg:algorithm) (key:seq nat32) : Pure (seq quad32) (requires is_aes_key_LE alg key) (ensures fun round_keys -> length round_keys == nr alg + 1) = key_schedule_to_round_keys (nr alg + 1) (expand_key alg key (nb * (nr alg + 1))) let aes_encrypt_LE_def (alg:algorithm) (key:seq nat32) (input_LE:quad32) : Pure quad32 (requires is_aes_key_LE alg key) (ensures fun _ -> True) =
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> input_LE: Vale.Def.Types_s.quad32 -> Prims.Pure Vale.Def.Types_s.quad32
Prims.Pure
[]
[]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.Def.Types_s.quad32", "Vale.AES.AES_s.is_aes_key_LE", "Prims.l_True", "Vale.AES.AES_s.aes_encrypt_LE_def" ]
[]
false
false
false
false
false
let aes_encrypt_LE =
opaque_make aes_encrypt_LE_def
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.aes_encrypt_LE_reveal
val aes_encrypt_LE_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.AES.AES_s.aes_encrypt_LE == Vale.AES.AES_s.aes_encrypt_LE_def)
let aes_encrypt_LE_reveal = opaque_revealer (`%aes_encrypt_LE) aes_encrypt_LE aes_encrypt_LE_def
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 108, "end_line": 104, "start_col": 12, "start_line": 104 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 = if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n) [@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) = let state = quad32_xor input (index round_keys 0) in let state = eval_rounds_def state round_keys (nr alg - 1) in let state = sub_bytes state in let state = shift_rows_LE state in let state = quad32_xor state (index round_keys (nr alg)) in state [@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))}) : (ek_LE:seq nat32 {length ek_LE == size}) = if size = 0 then empty else let w = expand_key_def alg key (size - 1) in let i = size - 1 in if 0 <= i && i < nk alg then append w (create 1 (index key i)) else let temp = if i % (nk alg) = 0 then nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1)) else if nk alg > 6 && i % (nk alg) = 4 then sub_word (index w (i - 1)) else index w (i - 1) in append w (create 1 (nat32_xor (index w (i - (nk alg))) temp)) [@"opaque_to_smt"] let expand_key = opaque_make expand_key_def irreducible let expand_key_reveal = opaque_revealer (`%expand_key) expand_key expand_key_def let rec key_schedule_to_round_keys (rounds:nat) (w:seq nat32 {length w >= 4 * rounds}) : (round_keys:seq quad32 {length round_keys == rounds}) = if rounds = 0 then empty else let round_keys = key_schedule_to_round_keys (rounds - 1) w in let rk = Mkfour (index w (4 * rounds - 4)) (index w (4 * rounds - 3)) (index w (4 * rounds - 2)) (index w (4 * rounds - 1)) in append round_keys (create 1 rk) [@"opaque_to_smt"] let key_to_round_keys_LE (alg:algorithm) (key:seq nat32) : Pure (seq quad32) (requires is_aes_key_LE alg key) (ensures fun round_keys -> length round_keys == nr alg + 1) = key_schedule_to_round_keys (nr alg + 1) (expand_key alg key (nb * (nr alg + 1))) let aes_encrypt_LE_def (alg:algorithm) (key:seq nat32) (input_LE:quad32) : Pure quad32 (requires is_aes_key_LE alg key) (ensures fun _ -> True) = eval_cipher_def alg input_LE (key_to_round_keys_LE alg key)
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.AES.AES_s.aes_encrypt_LE == Vale.AES.AES_s.aes_encrypt_LE_def)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.Def.Types_s.quad32", "Vale.AES.AES_s.is_aes_key_LE", "Prims.l_True", "Vale.AES.AES_s.aes_encrypt_LE", "Vale.AES.AES_s.aes_encrypt_LE_def" ]
[]
true
false
true
false
false
let aes_encrypt_LE_reveal =
opaque_revealer (`%aes_encrypt_LE) aes_encrypt_LE aes_encrypt_LE_def
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.expand_key_def
val expand_key_def (alg: algorithm) (key: aes_key_LE alg) (size: nat{size <= (nb * ((nr alg) + 1))}) : (ek_LE: seq nat32 {length ek_LE == size})
val expand_key_def (alg: algorithm) (key: aes_key_LE alg) (size: nat{size <= (nb * ((nr alg) + 1))}) : (ek_LE: seq nat32 {length ek_LE == size})
let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))}) : (ek_LE:seq nat32 {length ek_LE == size}) = if size = 0 then empty else let w = expand_key_def alg key (size - 1) in let i = size - 1 in if 0 <= i && i < nk alg then append w (create 1 (index key i)) else let temp = if i % (nk alg) = 0 then nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1)) else if nk alg > 6 && i % (nk alg) = 4 then sub_word (index w (i - 1)) else index w (i - 1) in append w (create 1 (nat32_xor (index w (i - (nk alg))) temp))
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 67, "end_line": 79, "start_col": 0, "start_line": 62 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 = if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n) [@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) = let state = quad32_xor input (index round_keys 0) in let state = eval_rounds_def state round_keys (nr alg - 1) in let state = sub_bytes state in let state = shift_rows_LE state in let state = quad32_xor state (index round_keys (nr alg)) in state [@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> key: Vale.AES.AES_s.aes_key_LE alg -> size: Prims.nat{size <= Vale.AES.AES_common_s.nb * (Vale.AES.AES_common_s.nr alg + 1)} -> ek_LE: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 {FStar.Seq.Base.length ek_LE == size}
Prims.Tot
[ "total" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "Vale.AES.AES_s.aes_key_LE", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Vale.AES.AES_common_s.nb", "Prims.op_Addition", "Vale.AES.AES_common_s.nr", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.empty", "Vale.Def.Types_s.nat32", "Prims.bool", "Prims.op_AmpAmp", "Prims.op_LessThan", "Vale.AES.AES_common_s.nk", "FStar.Seq.Base.append", "FStar.Seq.Base.create", "FStar.Seq.Base.index", "Vale.Def.Types_s.nat32_xor", "Prims.op_Subtraction", "Vale.Def.Words_s.nat32", "Prims.op_Modulus", "Vale.AES.AES_common_s.sub_word", "Vale.AES.AES_s.rot_word_LE", "Vale.AES.AES_common_s.aes_rcon", "Prims.op_Division", "Prims.op_GreaterThan", "FStar.Seq.Base.seq", "Prims.eq2", "FStar.Seq.Base.length", "Vale.AES.AES_s.expand_key_def" ]
[ "recursion" ]
false
false
false
false
false
let rec expand_key_def (alg: algorithm) (key: aes_key_LE alg) (size: nat{size <= (nb * ((nr alg) + 1))}) : (ek_LE: seq nat32 {length ek_LE == size}) =
if size = 0 then empty else let w = expand_key_def alg key (size - 1) in let i = size - 1 in if 0 <= i && i < nk alg then append w (create 1 (index key i)) else let temp = if i % (nk alg) = 0 then nat32_xor (sub_word (rot_word_LE (index w (i - 1)))) (aes_rcon ((i / (nk alg)) - 1)) else if nk alg > 6 && i % (nk alg) = 4 then sub_word (index w (i - 1)) else index w (i - 1) in append w (create 1 (nat32_xor (index w (i - (nk alg))) temp))
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.key_schedule_to_round_keys
val key_schedule_to_round_keys (rounds: nat) (w: seq nat32 {length w >= 4 * rounds}) : (round_keys: seq quad32 {length round_keys == rounds})
val key_schedule_to_round_keys (rounds: nat) (w: seq nat32 {length w >= 4 * rounds}) : (round_keys: seq quad32 {length round_keys == rounds})
let rec key_schedule_to_round_keys (rounds:nat) (w:seq nat32 {length w >= 4 * rounds}) : (round_keys:seq quad32 {length round_keys == rounds}) = if rounds = 0 then empty else let round_keys = key_schedule_to_round_keys (rounds - 1) w in let rk = Mkfour (index w (4 * rounds - 4)) (index w (4 * rounds - 3)) (index w (4 * rounds - 2)) (index w (4 * rounds - 1)) in append round_keys (create 1 rk)
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 35, "end_line": 89, "start_col": 0, "start_line": 83 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 = if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n) [@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) = let state = quad32_xor input (index round_keys 0) in let state = eval_rounds_def state round_keys (nr alg - 1) in let state = sub_bytes state in let state = shift_rows_LE state in let state = quad32_xor state (index round_keys (nr alg)) in state [@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))}) : (ek_LE:seq nat32 {length ek_LE == size}) = if size = 0 then empty else let w = expand_key_def alg key (size - 1) in let i = size - 1 in if 0 <= i && i < nk alg then append w (create 1 (index key i)) else let temp = if i % (nk alg) = 0 then nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1)) else if nk alg > 6 && i % (nk alg) = 4 then sub_word (index w (i - 1)) else index w (i - 1) in append w (create 1 (nat32_xor (index w (i - (nk alg))) temp)) [@"opaque_to_smt"] let expand_key = opaque_make expand_key_def irreducible let expand_key_reveal = opaque_revealer (`%expand_key) expand_key expand_key_def
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
rounds: Prims.nat -> w: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 {FStar.Seq.Base.length w >= 4 * rounds} -> round_keys: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 {FStar.Seq.Base.length round_keys == rounds}
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.Seq.Base.length", "FStar.Mul.op_Star", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.empty", "Vale.Def.Types_s.quad32", "Prims.bool", "FStar.Seq.Base.append", "FStar.Seq.Base.create", "Vale.Def.Words_s.four", "Vale.Def.Words_s.nat32", "Vale.Def.Words_s.Mkfour", "FStar.Seq.Base.index", "Prims.op_Subtraction", "Prims.eq2", "Vale.AES.AES_s.key_schedule_to_round_keys" ]
[ "recursion" ]
false
false
false
false
false
let rec key_schedule_to_round_keys (rounds: nat) (w: seq nat32 {length w >= 4 * rounds}) : (round_keys: seq quad32 {length round_keys == rounds}) =
if rounds = 0 then empty else let round_keys = key_schedule_to_round_keys (rounds - 1) w in let rk = Mkfour (index w (4 * rounds - 4)) (index w (4 * rounds - 3)) (index w (4 * rounds - 2)) (index w (4 * rounds - 1)) in append round_keys (create 1 rk)
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.key_to_round_keys_LE
val key_to_round_keys_LE (alg: algorithm) (key: seq nat32) : Pure (seq quad32) (requires is_aes_key_LE alg key) (ensures fun round_keys -> length round_keys == nr alg + 1)
val key_to_round_keys_LE (alg: algorithm) (key: seq nat32) : Pure (seq quad32) (requires is_aes_key_LE alg key) (ensures fun round_keys -> length round_keys == nr alg + 1)
let key_to_round_keys_LE (alg:algorithm) (key:seq nat32) : Pure (seq quad32) (requires is_aes_key_LE alg key) (ensures fun round_keys -> length round_keys == nr alg + 1) = key_schedule_to_round_keys (nr alg + 1) (expand_key alg key (nb * (nr alg + 1)))
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 82, "end_line": 96, "start_col": 0, "start_line": 92 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 = if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n) [@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) = let state = quad32_xor input (index round_keys 0) in let state = eval_rounds_def state round_keys (nr alg - 1) in let state = sub_bytes state in let state = shift_rows_LE state in let state = quad32_xor state (index round_keys (nr alg)) in state [@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))}) : (ek_LE:seq nat32 {length ek_LE == size}) = if size = 0 then empty else let w = expand_key_def alg key (size - 1) in let i = size - 1 in if 0 <= i && i < nk alg then append w (create 1 (index key i)) else let temp = if i % (nk alg) = 0 then nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1)) else if nk alg > 6 && i % (nk alg) = 4 then sub_word (index w (i - 1)) else index w (i - 1) in append w (create 1 (nat32_xor (index w (i - (nk alg))) temp)) [@"opaque_to_smt"] let expand_key = opaque_make expand_key_def irreducible let expand_key_reveal = opaque_revealer (`%expand_key) expand_key expand_key_def let rec key_schedule_to_round_keys (rounds:nat) (w:seq nat32 {length w >= 4 * rounds}) : (round_keys:seq quad32 {length round_keys == rounds}) = if rounds = 0 then empty else let round_keys = key_schedule_to_round_keys (rounds - 1) w in let rk = Mkfour (index w (4 * rounds - 4)) (index w (4 * rounds - 3)) (index w (4 * rounds - 2)) (index w (4 * rounds - 1)) in append round_keys (create 1 rk)
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.quad32)
Prims.Pure
[]
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.AES.AES_s.key_schedule_to_round_keys", "Prims.op_Addition", "Vale.AES.AES_common_s.nr", "Vale.AES.AES_s.expand_key", "FStar.Mul.op_Star", "Vale.AES.AES_common_s.nb", "Vale.Def.Types_s.quad32", "Vale.AES.AES_s.is_aes_key_LE", "Prims.eq2", "Prims.int", "FStar.Seq.Base.length" ]
[]
false
false
false
false
false
let key_to_round_keys_LE (alg: algorithm) (key: seq nat32) : Pure (seq quad32) (requires is_aes_key_LE alg key) (ensures fun round_keys -> length round_keys == nr alg + 1) =
key_schedule_to_round_keys (nr alg + 1) (expand_key alg key (nb * (nr alg + 1)))
false
Vale.AES.AES_s.fst
Vale.AES.AES_s.aes_encrypt_LE_def
val aes_encrypt_LE_def (alg: algorithm) (key: seq nat32) (input_LE: quad32) : Pure quad32 (requires is_aes_key_LE alg key) (ensures fun _ -> True)
val aes_encrypt_LE_def (alg: algorithm) (key: seq nat32) (input_LE: quad32) : Pure quad32 (requires is_aes_key_LE alg key) (ensures fun _ -> True)
let aes_encrypt_LE_def (alg:algorithm) (key:seq nat32) (input_LE:quad32) : Pure quad32 (requires is_aes_key_LE alg key) (ensures fun _ -> True) = eval_cipher_def alg input_LE (key_to_round_keys_LE alg key)
{ "file_name": "vale/specs/crypto/Vale.AES.AES_s.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 61, "end_line": 102, "start_col": 0, "start_line": 98 }
module Vale.AES.AES_s // IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s // This is explicit in key_schedule_to_round_keys when we construct the round_key rk, // but it also applies implicitly to the input quad32 open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Four_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open FStar.Seq open FStar.Mul include Vale.AES.AES_common_s // operations assume that the quad32 and nat32 values are little-endian interpretations // of 16-byte and 4-byte sequences assume val mix_columns_LE (q:quad32) : quad32 assume val inv_mix_columns_LE (q:quad32) : quad32 assume val shift_rows_LE (q:quad32) : quad32 assume val inv_shift_rows_LE (q:quad32) : quad32 assume val rot_word_LE (w:nat32) : nat32 assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma (sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q)) assume val commute_rot_word_sub_word (x:nat32) : Lemma (rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} let eval_round (state round_key:quad32) = let s = sub_bytes state in let s = shift_rows_LE s in let s = mix_columns_LE s in let s = quad32_xor s round_key in s let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 = if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n) [@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) = let state = quad32_xor input (index round_keys 0) in let state = eval_rounds_def state round_keys (nr alg - 1) in let state = sub_bytes state in let state = shift_rows_LE state in let state = quad32_xor state (index round_keys (nr alg)) in state [@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))}) : (ek_LE:seq nat32 {length ek_LE == size}) = if size = 0 then empty else let w = expand_key_def alg key (size - 1) in let i = size - 1 in if 0 <= i && i < nk alg then append w (create 1 (index key i)) else let temp = if i % (nk alg) = 0 then nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1)) else if nk alg > 6 && i % (nk alg) = 4 then sub_word (index w (i - 1)) else index w (i - 1) in append w (create 1 (nat32_xor (index w (i - (nk alg))) temp)) [@"opaque_to_smt"] let expand_key = opaque_make expand_key_def irreducible let expand_key_reveal = opaque_revealer (`%expand_key) expand_key expand_key_def let rec key_schedule_to_round_keys (rounds:nat) (w:seq nat32 {length w >= 4 * rounds}) : (round_keys:seq quad32 {length round_keys == rounds}) = if rounds = 0 then empty else let round_keys = key_schedule_to_round_keys (rounds - 1) w in let rk = Mkfour (index w (4 * rounds - 4)) (index w (4 * rounds - 3)) (index w (4 * rounds - 2)) (index w (4 * rounds - 1)) in append round_keys (create 1 rk) [@"opaque_to_smt"] let key_to_round_keys_LE (alg:algorithm) (key:seq nat32) : Pure (seq quad32) (requires is_aes_key_LE alg key) (ensures fun round_keys -> length round_keys == nr alg + 1) = key_schedule_to_round_keys (nr alg + 1) (expand_key alg key (nb * (nr alg + 1)))
{ "checked_file": "/", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.AES_s.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.AES_common_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> input_LE: Vale.Def.Types_s.quad32 -> Prims.Pure Vale.Def.Types_s.quad32
Prims.Pure
[]
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Vale.Def.Types_s.quad32", "Vale.AES.AES_s.eval_cipher_def", "Vale.AES.AES_s.key_to_round_keys_LE", "Vale.AES.AES_s.is_aes_key_LE", "Prims.l_True" ]
[]
false
false
false
false
false
let aes_encrypt_LE_def (alg: algorithm) (key: seq nat32) (input_LE: quad32) : Pure quad32 (requires is_aes_key_LE alg key) (ensures fun _ -> True) =
eval_cipher_def alg input_LE (key_to_round_keys_LE alg key)
false