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
LowParse.SLow.Base.fst
LowParse.SLow.Base.parse32_total
val parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires (k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input)) (ensures (Some? (p32 input)))
val parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires (k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input)) (ensures (Some? (p32 input)))
let parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires ( k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input )) (ensures ( Some? (p32 input) )) = parser_kind_prop_equiv k p
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 28, "end_line": 298, "start_col": 0, "start_line": 283 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2)) let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2)) let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures ( k.parser_kind_low <= U32.v consumed /\ ( Some? k.parser_kind_high ==> ( let (Some hi) = k.parser_kind_high in U32.v consumed <= hi )))) = parser_kind_prop_equiv k p
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
p32: LowParse.SLow.Base.parser32 p -> input: LowParse.SLow.Base.bytes32 -> FStar.Pervasives.Lemma (requires Mkparser_kind'?.parser_kind_high k == FStar.Pervasives.Native.Some (Mkparser_kind'?.parser_kind_low k) /\ Mkparser_kind'?.parser_kind_metadata k == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserKindMetadataTotal /\ Mkparser_kind'?.parser_kind_low k <= FStar.Bytes.length input) (ensures Some? (p32 input))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.SLow.Base.bytes32", "LowParse.Spec.Base.parser_kind_prop_equiv", "Prims.unit", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "Prims.nat", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "LowParse.Spec.Base.parser_kind_metadata_some", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_metadata", "LowParse.Spec.Base.ParserKindMetadataTotal", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Bytes.length", "Prims.squash", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.tuple2", "FStar.UInt32.t", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires (k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input)) (ensures (Some? (p32 input))) =
parser_kind_prop_equiv k p
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.size32_constant_precond
val size32_constant_precond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) : GTot Type0
val size32_constant_precond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) : GTot Type0
let size32_constant_precond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) : GTot Type0 = k.parser_kind_high == Some k.parser_kind_low /\ U32.v len32 == k.parser_kind_low
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 34, "end_line": 352, "start_col": 0, "start_line": 344 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2)) let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2)) let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures ( k.parser_kind_low <= U32.v consumed /\ ( Some? k.parser_kind_high ==> ( let (Some hi) = k.parser_kind_high in U32.v consumed <= hi )))) = parser_kind_prop_equiv k p let parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires ( k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input )) (ensures ( Some? (p32 input) )) = parser_kind_prop_equiv k p inline_for_extraction let u32_max : (y: U32.t { forall (x: U32.t) . {:pattern (U32.v x)} U32.v x <= U32.v y } ) = 4294967295ul inline_for_extraction let add_overflow (x y: U32.t) : Pure U32.t (requires True) (ensures (fun z -> if U32.v x + U32.v y > U32.v u32_max then z == u32_max else U32.v z == U32.v x + U32.v y )) = if U32.lt (U32.sub u32_max y) x then u32_max else U32.add x y let size32_postcond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (x: t) (y: U32.t) : GTot Type0 = let sz = Seq.length (serialize s x) in if sz > U32.v u32_max then y == u32_max else U32.v y == sz [@unifier_hint_injective] inline_for_extraction let size32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (x: t) -> Tot (y: U32.t { size32_postcond s x y })
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: LowParse.Spec.Base.serializer p -> len32: FStar.UInt32.t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "FStar.UInt32.t", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "Prims.nat", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt32.v" ]
[]
false
false
false
false
true
let size32_constant_precond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) : GTot Type0 =
k.parser_kind_high == Some k.parser_kind_low /\ U32.v len32 == k.parser_kind_low
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.bytes_of_seq'
val bytes_of_seq' (x: Seq.seq byte) (accu: bytes32{B32.length accu + Seq.length x < 4294967296}) : Tot (y: bytes32{(B32.reveal y) `Seq.equal` ((B32.reveal accu) `Seq.append` x)}) (decreases (Seq.length x))
val bytes_of_seq' (x: Seq.seq byte) (accu: bytes32{B32.length accu + Seq.length x < 4294967296}) : Tot (y: bytes32{(B32.reveal y) `Seq.equal` ((B32.reveal accu) `Seq.append` x)}) (decreases (Seq.length x))
let rec bytes_of_seq' (x: Seq.seq byte) (accu: bytes32 { B32.length accu + Seq.length x < 4294967296 }) : Tot (y: bytes32 { B32.reveal y `Seq.equal` (B32.reveal accu `Seq.append` x) }) (decreases (Seq.length x)) = if Seq.length x = 0 then accu else bytes_of_seq' (Seq.tail x) (B32.append accu (B32.create 1ul (Seq.head x)))
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 81, "end_line": 393, "start_col": 0, "start_line": 386 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2)) let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2)) let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures ( k.parser_kind_low <= U32.v consumed /\ ( Some? k.parser_kind_high ==> ( let (Some hi) = k.parser_kind_high in U32.v consumed <= hi )))) = parser_kind_prop_equiv k p let parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires ( k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input )) (ensures ( Some? (p32 input) )) = parser_kind_prop_equiv k p inline_for_extraction let u32_max : (y: U32.t { forall (x: U32.t) . {:pattern (U32.v x)} U32.v x <= U32.v y } ) = 4294967295ul inline_for_extraction let add_overflow (x y: U32.t) : Pure U32.t (requires True) (ensures (fun z -> if U32.v x + U32.v y > U32.v u32_max then z == u32_max else U32.v z == U32.v x + U32.v y )) = if U32.lt (U32.sub u32_max y) x then u32_max else U32.add x y let size32_postcond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (x: t) (y: U32.t) : GTot Type0 = let sz = Seq.length (serialize s x) in if sz > U32.v u32_max then y == u32_max else U32.v y == sz [@unifier_hint_injective] inline_for_extraction let size32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (x: t) -> Tot (y: U32.t { size32_postcond s x y }) let size32_constant_precond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) : GTot Type0 = k.parser_kind_high == Some k.parser_kind_low /\ U32.v len32 == k.parser_kind_low inline_for_extraction let size32_constant (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) (u: unit { size32_constant_precond s len32 } ) : Tot (size32 s) = fun x -> [@inline_let] let (z: U32.t { size32_postcond s x z } ) = len32 in z inline_for_extraction let size32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': size32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (size32 (serialize_ext p1 s1 p2)) = fun input -> s1' input (* Total parsers for sequences *) [@"opaque_to_smt"]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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.Seq.Base.seq LowParse.Bytes.byte -> accu: LowParse.SLow.Base.bytes32{FStar.Bytes.length accu + FStar.Seq.Base.length x < 4294967296} -> Prims.Tot (y: LowParse.SLow.Base.bytes32 { FStar.Seq.Base.equal (FStar.Bytes.reveal y) (FStar.Seq.Base.append (FStar.Bytes.reveal accu) x) })
Prims.Tot
[ "total", "" ]
[]
[ "FStar.Seq.Base.seq", "LowParse.Bytes.byte", "LowParse.SLow.Base.bytes32", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Addition", "FStar.Bytes.length", "FStar.Seq.Base.length", "Prims.op_Equality", "Prims.int", "Prims.bool", "LowParse.SLow.Base.bytes_of_seq'", "FStar.Seq.Properties.tail", "FStar.Bytes.append", "FStar.Bytes.create", "FStar.UInt32.__uint_to_t", "FStar.Seq.Properties.head", "FStar.Seq.Base.equal", "FStar.Bytes.byte", "FStar.Bytes.reveal", "FStar.Seq.Base.append" ]
[ "recursion" ]
false
false
false
false
false
let rec bytes_of_seq' (x: Seq.seq byte) (accu: bytes32{B32.length accu + Seq.length x < 4294967296}) : Tot (y: bytes32{(B32.reveal y) `Seq.equal` ((B32.reveal accu) `Seq.append` x)}) (decreases (Seq.length x)) =
if Seq.length x = 0 then accu else bytes_of_seq' (Seq.tail x) (B32.append accu (B32.create 1ul (Seq.head x)))
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.u32_max
val u32_max:(y: U32.t{forall (x: U32.t). {:pattern (U32.v x)} U32.v x <= U32.v y})
val u32_max:(y: U32.t{forall (x: U32.t). {:pattern (U32.v x)} U32.v x <= U32.v y})
let u32_max : (y: U32.t { forall (x: U32.t) . {:pattern (U32.v x)} U32.v x <= U32.v y } ) = 4294967295ul
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 14, "end_line": 302, "start_col": 0, "start_line": 301 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2)) let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2)) let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures ( k.parser_kind_low <= U32.v consumed /\ ( Some? k.parser_kind_high ==> ( let (Some hi) = k.parser_kind_high in U32.v consumed <= hi )))) = parser_kind_prop_equiv k p let parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires ( k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input )) (ensures ( Some? (p32 input) )) = parser_kind_prop_equiv k p
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
y: FStar.UInt32.t {forall (x: FStar.UInt32.t). {:pattern FStar.UInt32.v x} FStar.UInt32.v x <= FStar.UInt32.v y}
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.__uint_to_t" ]
[]
false
false
false
false
false
let u32_max:(y: U32.t{forall (x: U32.t). {:pattern (U32.v x)} U32.v x <= U32.v y}) =
4294967295ul
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.size32_constant
val size32_constant (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) (u: unit{size32_constant_precond s len32}) : Tot (size32 s)
val size32_constant (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) (u: unit{size32_constant_precond s len32}) : Tot (size32 s)
let size32_constant (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) (u: unit { size32_constant_precond s len32 } ) : Tot (size32 s) = fun x -> [@inline_let] let (z: U32.t { size32_postcond s x z } ) = len32 in z
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 3, "end_line": 366, "start_col": 0, "start_line": 355 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2)) let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2)) let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures ( k.parser_kind_low <= U32.v consumed /\ ( Some? k.parser_kind_high ==> ( let (Some hi) = k.parser_kind_high in U32.v consumed <= hi )))) = parser_kind_prop_equiv k p let parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires ( k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input )) (ensures ( Some? (p32 input) )) = parser_kind_prop_equiv k p inline_for_extraction let u32_max : (y: U32.t { forall (x: U32.t) . {:pattern (U32.v x)} U32.v x <= U32.v y } ) = 4294967295ul inline_for_extraction let add_overflow (x y: U32.t) : Pure U32.t (requires True) (ensures (fun z -> if U32.v x + U32.v y > U32.v u32_max then z == u32_max else U32.v z == U32.v x + U32.v y )) = if U32.lt (U32.sub u32_max y) x then u32_max else U32.add x y let size32_postcond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (x: t) (y: U32.t) : GTot Type0 = let sz = Seq.length (serialize s x) in if sz > U32.v u32_max then y == u32_max else U32.v y == sz [@unifier_hint_injective] inline_for_extraction let size32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (x: t) -> Tot (y: U32.t { size32_postcond s x y }) let size32_constant_precond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) : GTot Type0 = k.parser_kind_high == Some k.parser_kind_low /\ U32.v len32 == k.parser_kind_low
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: LowParse.Spec.Base.serializer p -> len32: FStar.UInt32.t -> u353: u354: Prims.unit{LowParse.SLow.Base.size32_constant_precond s len32} -> LowParse.SLow.Base.size32 s
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "FStar.UInt32.t", "Prims.unit", "LowParse.SLow.Base.size32_constant_precond", "LowParse.SLow.Base.size32_postcond", "LowParse.SLow.Base.size32" ]
[]
false
false
false
false
false
let size32_constant (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) (u: unit{size32_constant_precond s len32}) : Tot (size32 s) =
fun x -> [@@ inline_let ]let z:z: U32.t{size32_postcond s x z} = len32 in z
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.serializer32_correct_length
val serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures (let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ (match k.parser_kind_high with | Some max -> len <= max | _ -> True))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)]
val serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures (let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ (match k.parser_kind_high with | Some max -> len <= max | _ -> True))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)]
let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 26, "end_line": 147, "start_col": 0, "start_line": 130 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } )
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: LowParse.Spec.Base.serializer p -> input: t -> res: LowParse.SLow.Base.bytes32 -> FStar.Pervasives.Lemma (requires LowParse.SLow.Base.serializer32_correct s input res) (ensures (let len = FStar.Bytes.length res in Mkparser_kind'?.parser_kind_low k <= len /\ (match Mkparser_kind'?.parser_kind_high k with | FStar.Pervasives.Native.Some #_ max -> len <= max | _ -> Prims.l_True))) [ SMTPat (LowParse.SLow.Base.serializer32_correct s input res); SMTPat (FStar.Bytes.length res) ]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.bytes32", "LowParse.Spec.Base.serialize_length", "Prims.unit", "LowParse.SLow.Base.serializer32_correct", "Prims.squash", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "Prims.nat", "FStar.Pervasives.Native.option", "Prims.l_True", "Prims.logical", "FStar.UInt.uint_t", "FStar.Bytes.length", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures (let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ (match k.parser_kind_high with | Some max -> len <= max | _ -> True))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] =
serialize_length s input
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.serializer32_injective
val serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2))
val serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2))
let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2))
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 71, "end_line": 263, "start_col": 0, "start_line": 253 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: LowParse.Spec.Base.serializer p -> s32: LowParse.SLow.Base.serializer32 s -> input1: t -> input2: t -> FStar.Pervasives.Lemma (requires s32 input1 == s32 input2) (ensures input1 == input2)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "Prims._assert", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.serialize", "LowParse.Spec.Base.parse", "Prims.unit", "LowParse.SLow.Base.bytes32", "Prims.l_or", "LowParse.SLow.Base.serializer32_correct", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) =
assert (parse p (serialize s input1) == parse p (serialize s input2))
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.size32_postcond
val size32_postcond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (x: t) (y: U32.t) : GTot Type0
val size32_postcond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (x: t) (y: U32.t) : GTot Type0
let size32_postcond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (x: t) (y: U32.t) : GTot Type0 = let sz = Seq.length (serialize s x) in if sz > U32.v u32_max then y == u32_max else U32.v y == sz
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 20, "end_line": 329, "start_col": 0, "start_line": 318 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2)) let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2)) let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures ( k.parser_kind_low <= U32.v consumed /\ ( Some? k.parser_kind_high ==> ( let (Some hi) = k.parser_kind_high in U32.v consumed <= hi )))) = parser_kind_prop_equiv k p let parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires ( k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input )) (ensures ( Some? (p32 input) )) = parser_kind_prop_equiv k p inline_for_extraction let u32_max : (y: U32.t { forall (x: U32.t) . {:pattern (U32.v x)} U32.v x <= U32.v y } ) = 4294967295ul inline_for_extraction let add_overflow (x y: U32.t) : Pure U32.t (requires True) (ensures (fun z -> if U32.v x + U32.v y > U32.v u32_max then z == u32_max else U32.v z == U32.v x + U32.v y )) = if U32.lt (U32.sub u32_max y) x then u32_max else U32.add x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: LowParse.Spec.Base.serializer p -> x: t -> y: FStar.UInt32.t -> Prims.GTot Type0
Prims.GTot
[ "sometrivial" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "FStar.UInt32.t", "Prims.op_GreaterThan", "FStar.UInt32.v", "LowParse.SLow.Base.u32_max", "Prims.eq2", "Prims.bool", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt32.n", "Prims.nat", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "LowParse.Spec.Base.serialize" ]
[]
false
false
false
false
true
let size32_postcond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (x: t) (y: U32.t) : GTot Type0 =
let sz = Seq.length (serialize s x) in if sz > U32.v u32_max then y == u32_max else U32.v y == sz
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.parser32_then_serializer32
val parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures (let Some (v, consumed) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed))
val parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures (let Some (v, consumed) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed))
let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 41, "end_line": 199, "start_col": 0, "start_line": 184 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: LowParse.Spec.Base.serializer p -> p32: LowParse.SLow.Base.parser32 p -> s32: LowParse.SLow.Base.serializer32 s -> input: LowParse.SLow.Base.bytes32 -> FStar.Pervasives.Lemma (requires Some? (p32 input)) (ensures (let _ = p32 input in (let FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ v consumed) = _ in FStar.UInt32.v consumed <= FStar.Bytes.length input /\ s32 v == LowParse.Bytes32.b32slice input 0ul consumed) <: Type0))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.parser32", "LowParse.SLow.Base.serializer32", "LowParse.SLow.Base.bytes32", "LowParse.Spec.Base.serializer_correct_implies_complete", "Prims.unit", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.tuple2", "FStar.UInt32.t", "Prims.squash", "Prims.l_and", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "FStar.Bytes.length", "Prims.eq2", "FStar.Bytes.bytes", "LowParse.Bytes32.b32slice", "FStar.UInt32.__uint_to_t", "FStar.Pervasives.Native.option", "LowParse.SLow.Base.parser32_correct", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures (let Some (v, consumed) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed)) =
serializer_correct_implies_complete p s
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.prime
val prime:pos
val prime:pos
let prime: pos = Scalar.prime
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 13, "start_col": 0, "start_line": 13 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false"
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.pos
Prims.Tot
[ "total" ]
[]
[ "Spec.Poly1305.prime" ]
[]
false
false
false
true
false
let prime:pos =
Scalar.prime
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.parse32_size
val parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures (k.parser_kind_low <= U32.v consumed /\ (Some? k.parser_kind_high ==> (let Some hi = k.parser_kind_high in U32.v consumed <= hi))))
val parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures (k.parser_kind_low <= U32.v consumed /\ (Some? k.parser_kind_high ==> (let Some hi = k.parser_kind_high in U32.v consumed <= hi))))
let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures ( k.parser_kind_low <= U32.v consumed /\ ( Some? k.parser_kind_high ==> ( let (Some hi) = k.parser_kind_high in U32.v consumed <= hi )))) = parser_kind_prop_equiv k p
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 28, "end_line": 281, "start_col": 0, "start_line": 265 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2)) let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
p32: LowParse.SLow.Base.parser32 p -> input: LowParse.SLow.Base.bytes32 -> data: t -> consumed: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires p32 input == FStar.Pervasives.Native.Some (data, consumed)) (ensures Mkparser_kind'?.parser_kind_low k <= FStar.UInt32.v consumed /\ (Some? (Mkparser_kind'?.parser_kind_high k) ==> (let _ = Mkparser_kind'?.parser_kind_high k in (let FStar.Pervasives.Native.Some #_ hi = _ in FStar.UInt32.v consumed <= hi) <: Prims.logical)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.SLow.Base.bytes32", "FStar.UInt32.t", "LowParse.Spec.Base.parser_kind_prop_equiv", "Prims.unit", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "Prims.squash", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low", "FStar.UInt32.v", "Prims.l_imp", "FStar.Pervasives.Native.uu___is_Some", "Prims.nat", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "Prims.logical", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures (k.parser_kind_low <= U32.v consumed /\ (Some? k.parser_kind_high ==> (let Some hi = k.parser_kind_high in U32.v consumed <= hi)))) =
parser_kind_prop_equiv k p
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.add_overflow
val add_overflow (x y: U32.t) : Pure U32.t (requires True) (ensures (fun z -> if U32.v x + U32.v y > U32.v u32_max then z == u32_max else U32.v z == U32.v x + U32.v y ))
val add_overflow (x y: U32.t) : Pure U32.t (requires True) (ensures (fun z -> if U32.v x + U32.v y > U32.v u32_max then z == u32_max else U32.v z == U32.v x + U32.v y ))
let add_overflow (x y: U32.t) : Pure U32.t (requires True) (ensures (fun z -> if U32.v x + U32.v y > U32.v u32_max then z == u32_max else U32.v z == U32.v x + U32.v y )) = if U32.lt (U32.sub u32_max y) x then u32_max else U32.add x y
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 18, "end_line": 316, "start_col": 0, "start_line": 305 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2)) let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2)) let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures ( k.parser_kind_low <= U32.v consumed /\ ( Some? k.parser_kind_high ==> ( let (Some hi) = k.parser_kind_high in U32.v consumed <= hi )))) = parser_kind_prop_equiv k p let parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires ( k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input )) (ensures ( Some? (p32 input) )) = parser_kind_prop_equiv k p inline_for_extraction let u32_max : (y: U32.t { forall (x: U32.t) . {:pattern (U32.v x)} U32.v x <= U32.v y } ) = 4294967295ul
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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 -> y: FStar.UInt32.t -> Prims.Pure FStar.UInt32.t
Prims.Pure
[]
[]
[ "FStar.UInt32.t", "FStar.UInt32.lt", "FStar.UInt32.sub", "LowParse.SLow.Base.u32_max", "Prims.bool", "FStar.UInt32.add", "Prims.l_True", "Prims.op_GreaterThan", "Prims.op_Addition", "FStar.UInt32.v", "Prims.eq2", "Prims.int" ]
[]
false
false
false
false
false
let add_overflow (x y: U32.t) : Pure U32.t (requires True) (ensures (fun z -> if U32.v x + U32.v y > U32.v u32_max then z == u32_max else U32.v z == U32.v x + U32.v y )) =
if U32.lt (U32.sub u32_max y) x then u32_max else U32.add x y
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.seq_of_bytes
val seq_of_bytes (x: bytes32) : Tot (y: Seq.seq byte {y `Seq.equal` (B32.reveal x)})
val seq_of_bytes (x: bytes32) : Tot (y: Seq.seq byte {y `Seq.equal` (B32.reveal x)})
let seq_of_bytes (x: bytes32) : Tot (y: Seq.seq byte { y `Seq.equal` B32.reveal x }) = seq_of_bytes' x Seq.empty
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 27, "end_line": 451, "start_col": 0, "start_line": 448 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2)) let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2)) let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures ( k.parser_kind_low <= U32.v consumed /\ ( Some? k.parser_kind_high ==> ( let (Some hi) = k.parser_kind_high in U32.v consumed <= hi )))) = parser_kind_prop_equiv k p let parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires ( k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input )) (ensures ( Some? (p32 input) )) = parser_kind_prop_equiv k p inline_for_extraction let u32_max : (y: U32.t { forall (x: U32.t) . {:pattern (U32.v x)} U32.v x <= U32.v y } ) = 4294967295ul inline_for_extraction let add_overflow (x y: U32.t) : Pure U32.t (requires True) (ensures (fun z -> if U32.v x + U32.v y > U32.v u32_max then z == u32_max else U32.v z == U32.v x + U32.v y )) = if U32.lt (U32.sub u32_max y) x then u32_max else U32.add x y let size32_postcond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (x: t) (y: U32.t) : GTot Type0 = let sz = Seq.length (serialize s x) in if sz > U32.v u32_max then y == u32_max else U32.v y == sz [@unifier_hint_injective] inline_for_extraction let size32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (x: t) -> Tot (y: U32.t { size32_postcond s x y }) let size32_constant_precond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) : GTot Type0 = k.parser_kind_high == Some k.parser_kind_low /\ U32.v len32 == k.parser_kind_low inline_for_extraction let size32_constant (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) (u: unit { size32_constant_precond s len32 } ) : Tot (size32 s) = fun x -> [@inline_let] let (z: U32.t { size32_postcond s x z } ) = len32 in z inline_for_extraction let size32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': size32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (size32 (serialize_ext p1 s1 p2)) = fun input -> s1' input (* Total parsers for sequences *) [@"opaque_to_smt"] irreducible let rec bytes_of_seq' (x: Seq.seq byte) (accu: bytes32 { B32.length accu + Seq.length x < 4294967296 }) : Tot (y: bytes32 { B32.reveal y `Seq.equal` (B32.reveal accu `Seq.append` x) }) (decreases (Seq.length x)) = if Seq.length x = 0 then accu else bytes_of_seq' (Seq.tail x) (B32.append accu (B32.create 1ul (Seq.head x))) [@"opaque_to_smt"] inline_for_extraction let bytes_of_seq (x: Seq.seq byte { Seq.length x < 4294967296 }) : Tot (y: bytes32 { B32.reveal y `Seq.equal` x }) = bytes_of_seq' x B32.empty_bytes inline_for_extraction let parse_tot_seq_of_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p { k.parser_kind_subkind == Some ParserStrong /\ begin match k.parser_kind_high with | None -> False | Some max -> max < 4294967296 end }) (x: Seq.seq byte) : Tot (y: _ { y == parse p x }) = match k.parser_kind_high with | Some max -> if Seq.length x < max then match p32 (bytes_of_seq x) with | None -> None | Some (x, consumed) -> Some (x, U32.v consumed) else begin [@inline_let] let max32 = U32.uint_to_t max in let res = p32 (bytes_of_seq (Seq.slice x 0 max)) in Classical.move_requires (parse_strong_prefix p x) (Seq.slice x 0 max); Classical.move_requires (parse_strong_prefix p (Seq.slice x 0 max)) x; parser_kind_prop_equiv k p; match res with | None -> None | Some (x, consumed) -> Some (x, U32.v consumed) end [@"opaque_to_smt"] irreducible let rec seq_of_bytes' (x: bytes32) (accu: Seq.seq byte) : Tot (y: Seq.seq byte { y `Seq.equal` (accu `Seq.append` B32.reveal x) }) (decreases (B32.length x)) = if B32.len x = 0ul then accu else (seq_of_bytes' (B32.slice x 1ul (B32.len x)) (Seq.append accu (Seq.create 1 (B32.index x 0))) <: Seq.seq byte) [@"opaque_to_smt"]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: LowParse.SLow.Base.bytes32 -> y: FStar.Seq.Base.seq LowParse.Bytes.byte {FStar.Seq.Base.equal y (FStar.Bytes.reveal x)}
Prims.Tot
[ "total" ]
[]
[ "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.seq_of_bytes'", "FStar.Seq.Base.empty", "LowParse.Bytes.byte", "FStar.Seq.Base.seq", "FStar.Seq.Base.equal", "FStar.Bytes.reveal" ]
[]
false
false
false
false
false
let seq_of_bytes (x: bytes32) : Tot (y: Seq.seq byte {y `Seq.equal` (B32.reveal x)}) =
seq_of_bytes' x Seq.empty
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.parser32_then_serializer32'
val parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures (B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed)))
val parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures (B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed)))
let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 44, "end_line": 218, "start_col": 0, "start_line": 201 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
p32: LowParse.SLow.Base.parser32 p -> s32: LowParse.SLow.Base.serializer32 s -> input: LowParse.SLow.Base.bytes32 -> v: t -> consumed: FStar.UInt32.t -> FStar.Pervasives.Lemma (requires p32 input == FStar.Pervasives.Native.Some (v, consumed)) (ensures FStar.Bytes.length (s32 v) == FStar.UInt32.v consumed /\ FStar.UInt32.v consumed <= FStar.Bytes.length input /\ FStar.Bytes.reveal (s32 v) == FStar.Seq.Base.slice (FStar.Bytes.reveal input) 0 (FStar.UInt32.v consumed))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.parser32", "LowParse.SLow.Base.serializer32", "LowParse.SLow.Base.bytes32", "FStar.UInt32.t", "LowParse.SLow.Base.parser32_then_serializer32", "Prims.unit", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "Prims.squash", "Prims.l_and", "FStar.UInt.uint_t", "FStar.Bytes.length", "FStar.UInt32.v", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.seq", "FStar.Bytes.byte", "FStar.Bytes.reveal", "FStar.Seq.Base.slice", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures (B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed))) =
parser32_then_serializer32 s p32 s32 input
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.size32_ext
val size32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': size32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes). parse p1 input == parse p2 input))) : Tot (size32 (serialize_ext p1 s1 p2))
val size32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': size32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes). parse p1 input == parse p2 input))) : Tot (size32 (serialize_ext p1 s1 p2))
let size32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': size32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (size32 (serialize_ext p1 s1 p2)) = fun input -> s1' input
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 24, "end_line": 380, "start_col": 0, "start_line": 369 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2)) let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2)) let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures ( k.parser_kind_low <= U32.v consumed /\ ( Some? k.parser_kind_high ==> ( let (Some hi) = k.parser_kind_high in U32.v consumed <= hi )))) = parser_kind_prop_equiv k p let parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires ( k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input )) (ensures ( Some? (p32 input) )) = parser_kind_prop_equiv k p inline_for_extraction let u32_max : (y: U32.t { forall (x: U32.t) . {:pattern (U32.v x)} U32.v x <= U32.v y } ) = 4294967295ul inline_for_extraction let add_overflow (x y: U32.t) : Pure U32.t (requires True) (ensures (fun z -> if U32.v x + U32.v y > U32.v u32_max then z == u32_max else U32.v z == U32.v x + U32.v y )) = if U32.lt (U32.sub u32_max y) x then u32_max else U32.add x y let size32_postcond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (x: t) (y: U32.t) : GTot Type0 = let sz = Seq.length (serialize s x) in if sz > U32.v u32_max then y == u32_max else U32.v y == sz [@unifier_hint_injective] inline_for_extraction let size32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (x: t) -> Tot (y: U32.t { size32_postcond s x y }) let size32_constant_precond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) : GTot Type0 = k.parser_kind_high == Some k.parser_kind_low /\ U32.v len32 == k.parser_kind_low inline_for_extraction let size32_constant (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) (u: unit { size32_constant_precond s len32 } ) : Tot (size32 s) = fun x -> [@inline_let] let (z: U32.t { size32_postcond s x z } ) = len32 in z
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
p1: LowParse.Spec.Base.parser k1 t1 -> s1: LowParse.Spec.Base.serializer p1 -> s1': LowParse.SLow.Base.size32 s1 -> p2: LowParse.Spec.Base.parser k2 t2 -> u374: Prims.squash (t1 == t2 /\ (forall (input: LowParse.Bytes.bytes). LowParse.Spec.Base.parse p1 input == LowParse.Spec.Base.parse p2 input)) -> LowParse.SLow.Base.size32 (LowParse.Spec.Base.serialize_ext p1 s1 p2)
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.size32", "Prims.squash", "Prims.l_and", "Prims.eq2", "Prims.l_Forall", "LowParse.Bytes.bytes", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "LowParse.Spec.Base.parse", "FStar.UInt32.t", "LowParse.SLow.Base.size32_postcond", "LowParse.Spec.Base.serialize_ext" ]
[]
false
false
false
false
false
let size32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': size32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes). parse p1 input == parse p2 input))) : Tot (size32 (serialize_ext p1 s1 p2)) =
fun input -> s1' input
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.bytes_of_seq
val bytes_of_seq (x: Seq.seq byte {Seq.length x < 4294967296}) : Tot (y: bytes32{(B32.reveal y) `Seq.equal` x})
val bytes_of_seq (x: Seq.seq byte {Seq.length x < 4294967296}) : Tot (y: bytes32{(B32.reveal y) `Seq.equal` x})
let bytes_of_seq (x: Seq.seq byte { Seq.length x < 4294967296 }) : Tot (y: bytes32 { B32.reveal y `Seq.equal` x }) = bytes_of_seq' x B32.empty_bytes
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 33, "end_line": 400, "start_col": 0, "start_line": 397 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2)) let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2)) let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures ( k.parser_kind_low <= U32.v consumed /\ ( Some? k.parser_kind_high ==> ( let (Some hi) = k.parser_kind_high in U32.v consumed <= hi )))) = parser_kind_prop_equiv k p let parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires ( k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input )) (ensures ( Some? (p32 input) )) = parser_kind_prop_equiv k p inline_for_extraction let u32_max : (y: U32.t { forall (x: U32.t) . {:pattern (U32.v x)} U32.v x <= U32.v y } ) = 4294967295ul inline_for_extraction let add_overflow (x y: U32.t) : Pure U32.t (requires True) (ensures (fun z -> if U32.v x + U32.v y > U32.v u32_max then z == u32_max else U32.v z == U32.v x + U32.v y )) = if U32.lt (U32.sub u32_max y) x then u32_max else U32.add x y let size32_postcond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (x: t) (y: U32.t) : GTot Type0 = let sz = Seq.length (serialize s x) in if sz > U32.v u32_max then y == u32_max else U32.v y == sz [@unifier_hint_injective] inline_for_extraction let size32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (x: t) -> Tot (y: U32.t { size32_postcond s x y }) let size32_constant_precond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) : GTot Type0 = k.parser_kind_high == Some k.parser_kind_low /\ U32.v len32 == k.parser_kind_low inline_for_extraction let size32_constant (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) (u: unit { size32_constant_precond s len32 } ) : Tot (size32 s) = fun x -> [@inline_let] let (z: U32.t { size32_postcond s x z } ) = len32 in z inline_for_extraction let size32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': size32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (size32 (serialize_ext p1 s1 p2)) = fun input -> s1' input (* Total parsers for sequences *) [@"opaque_to_smt"] irreducible let rec bytes_of_seq' (x: Seq.seq byte) (accu: bytes32 { B32.length accu + Seq.length x < 4294967296 }) : Tot (y: bytes32 { B32.reveal y `Seq.equal` (B32.reveal accu `Seq.append` x) }) (decreases (Seq.length x)) = if Seq.length x = 0 then accu else bytes_of_seq' (Seq.tail x) (B32.append accu (B32.create 1ul (Seq.head x))) [@"opaque_to_smt"]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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.Seq.Base.seq LowParse.Bytes.byte {FStar.Seq.Base.length x < 4294967296} -> y: LowParse.SLow.Base.bytes32{FStar.Seq.Base.equal (FStar.Bytes.reveal y) x}
Prims.Tot
[ "total" ]
[]
[ "FStar.Seq.Base.seq", "LowParse.Bytes.byte", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "LowParse.SLow.Base.bytes_of_seq'", "FStar.Bytes.empty_bytes", "LowParse.SLow.Base.bytes32", "FStar.Seq.Base.equal", "FStar.Bytes.byte", "FStar.Bytes.reveal" ]
[]
false
false
false
false
false
let bytes_of_seq (x: Seq.seq byte {Seq.length x < 4294967296}) : Tot (y: bytes32{(B32.reveal y) `Seq.equal` x}) =
bytes_of_seq' x B32.empty_bytes
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.serialize_tot_seq_of_serializer32
val serialize_tot_seq_of_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (x: t) : Tot (y: _{y == serialize s x})
val serialize_tot_seq_of_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (x: t) : Tot (y: _{y == serialize s x})
let serialize_tot_seq_of_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (x: t) : Tot (y: _ { y == serialize s x }) = seq_of_bytes (s32 x)
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 22, "end_line": 462, "start_col": 0, "start_line": 454 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2)) let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2)) let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures ( k.parser_kind_low <= U32.v consumed /\ ( Some? k.parser_kind_high ==> ( let (Some hi) = k.parser_kind_high in U32.v consumed <= hi )))) = parser_kind_prop_equiv k p let parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires ( k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input )) (ensures ( Some? (p32 input) )) = parser_kind_prop_equiv k p inline_for_extraction let u32_max : (y: U32.t { forall (x: U32.t) . {:pattern (U32.v x)} U32.v x <= U32.v y } ) = 4294967295ul inline_for_extraction let add_overflow (x y: U32.t) : Pure U32.t (requires True) (ensures (fun z -> if U32.v x + U32.v y > U32.v u32_max then z == u32_max else U32.v z == U32.v x + U32.v y )) = if U32.lt (U32.sub u32_max y) x then u32_max else U32.add x y let size32_postcond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (x: t) (y: U32.t) : GTot Type0 = let sz = Seq.length (serialize s x) in if sz > U32.v u32_max then y == u32_max else U32.v y == sz [@unifier_hint_injective] inline_for_extraction let size32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (x: t) -> Tot (y: U32.t { size32_postcond s x y }) let size32_constant_precond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) : GTot Type0 = k.parser_kind_high == Some k.parser_kind_low /\ U32.v len32 == k.parser_kind_low inline_for_extraction let size32_constant (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) (u: unit { size32_constant_precond s len32 } ) : Tot (size32 s) = fun x -> [@inline_let] let (z: U32.t { size32_postcond s x z } ) = len32 in z inline_for_extraction let size32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': size32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (size32 (serialize_ext p1 s1 p2)) = fun input -> s1' input (* Total parsers for sequences *) [@"opaque_to_smt"] irreducible let rec bytes_of_seq' (x: Seq.seq byte) (accu: bytes32 { B32.length accu + Seq.length x < 4294967296 }) : Tot (y: bytes32 { B32.reveal y `Seq.equal` (B32.reveal accu `Seq.append` x) }) (decreases (Seq.length x)) = if Seq.length x = 0 then accu else bytes_of_seq' (Seq.tail x) (B32.append accu (B32.create 1ul (Seq.head x))) [@"opaque_to_smt"] inline_for_extraction let bytes_of_seq (x: Seq.seq byte { Seq.length x < 4294967296 }) : Tot (y: bytes32 { B32.reveal y `Seq.equal` x }) = bytes_of_seq' x B32.empty_bytes inline_for_extraction let parse_tot_seq_of_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p { k.parser_kind_subkind == Some ParserStrong /\ begin match k.parser_kind_high with | None -> False | Some max -> max < 4294967296 end }) (x: Seq.seq byte) : Tot (y: _ { y == parse p x }) = match k.parser_kind_high with | Some max -> if Seq.length x < max then match p32 (bytes_of_seq x) with | None -> None | Some (x, consumed) -> Some (x, U32.v consumed) else begin [@inline_let] let max32 = U32.uint_to_t max in let res = p32 (bytes_of_seq (Seq.slice x 0 max)) in Classical.move_requires (parse_strong_prefix p x) (Seq.slice x 0 max); Classical.move_requires (parse_strong_prefix p (Seq.slice x 0 max)) x; parser_kind_prop_equiv k p; match res with | None -> None | Some (x, consumed) -> Some (x, U32.v consumed) end [@"opaque_to_smt"] irreducible let rec seq_of_bytes' (x: bytes32) (accu: Seq.seq byte) : Tot (y: Seq.seq byte { y `Seq.equal` (accu `Seq.append` B32.reveal x) }) (decreases (B32.length x)) = if B32.len x = 0ul then accu else (seq_of_bytes' (B32.slice x 1ul (B32.len x)) (Seq.append accu (Seq.create 1 (B32.index x 0))) <: Seq.seq byte) [@"opaque_to_smt"] inline_for_extraction let seq_of_bytes (x: bytes32) : Tot (y: Seq.seq byte { y `Seq.equal` B32.reveal x }) = seq_of_bytes' x Seq.empty
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
s32: LowParse.SLow.Base.serializer32 s -> x: t -> y: LowParse.Bytes.bytes{y == LowParse.Spec.Base.serialize s x}
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "LowParse.SLow.Base.serializer32", "LowParse.SLow.Base.seq_of_bytes", "LowParse.Bytes.bytes", "Prims.eq2", "LowParse.Spec.Base.serialize" ]
[]
false
false
false
false
false
let serialize_tot_seq_of_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (s32: serializer32 s) (x: t) : Tot (y: _{y == serialize s x}) =
seq_of_bytes (s32 x)
false
LowStar.Endianness.fst
LowStar.Endianness.upd_32_be
val upd_32_be (#rrel #rel: MB.srel u8) (b: MB.mbuffer u8 rrel rel) (i v: u32) : Stack unit (requires fun h -> MB.length b % 4 = 0 /\ U32.v i < MB.length b / 4 /\ store_pre b (let open U32 in v (4ul *^ i)) 4 (fun s -> be_to_n s == U32.v v) h) (ensures fun h0 _ h1 -> MB.(modifies (loc_buffer b) h0 h1) /\ (seq_uint32_of_be (MB.length b / 4) (MB.as_seq h1 b)) `Seq.equal` (Seq.upd (seq_uint32_of_be (MB.length b / 4) (MB.as_seq h0 b)) (U32.v i) v))
val upd_32_be (#rrel #rel: MB.srel u8) (b: MB.mbuffer u8 rrel rel) (i v: u32) : Stack unit (requires fun h -> MB.length b % 4 = 0 /\ U32.v i < MB.length b / 4 /\ store_pre b (let open U32 in v (4ul *^ i)) 4 (fun s -> be_to_n s == U32.v v) h) (ensures fun h0 _ h1 -> MB.(modifies (loc_buffer b) h0 h1) /\ (seq_uint32_of_be (MB.length b / 4) (MB.as_seq h1 b)) `Seq.equal` (Seq.upd (seq_uint32_of_be (MB.length b / 4) (MB.as_seq h0 b)) (U32.v i) v))
let upd_32_be (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32) (v:u32) : Stack unit (requires fun h -> MB.length b % 4 = 0 /\ U32.v i < MB.length b / 4 /\ store_pre b (U32.(v (4ul *^ i))) 4 (fun s -> be_to_n s == U32.v v) h) (ensures fun h0 _ h1 -> MB.(modifies (loc_buffer b) h0 h1) /\ seq_uint32_of_be (MB.length b / 4) (MB.as_seq h1 b) `Seq.equal` Seq.upd (seq_uint32_of_be (MB.length b / 4) (MB.as_seq h0 b)) (U32.v i) v) = let h0 = get () in store32_be_i b U32.(4ul *^ i) v; let h1 = get () in //AR: 03/01: the following 3 assertions say how the buffer changed assert (be_to_n (Seq.slice (MB.as_seq h1 b) (U32.(v (4ul *^ i))) (U32.(v (4ul *^ i) + 4))) == U32.v v); assert (Seq.equal (Seq.slice (MB.as_seq h0 b) 0 (U32.(v (4ul *^ i)))) (Seq.slice (MB.as_seq h1 b) 0 (U32.(v (4ul *^ i))))); assert (Seq.equal (Seq.slice (MB.as_seq h0 b) (U32.(v (4ul *^ i) + 4)) (MB.length b)) (Seq.slice (MB.as_seq h1 b) (U32.(v (4ul *^ i) + 4)) (MB.length b))); let f () : Lemma (seq_uint32_of_be (MB.length b / 4) (MB.as_seq h1 b) `Seq.equal` Seq.upd (seq_uint32_of_be (MB.length b / 4) (MB.as_seq h0 b)) (UInt32.v i) v) = let s0 = MB.as_seq h0 b in let s1 = MB.as_seq h1 b in let n = MB.length b / 4 in assert (4 `Prims.op_Multiply` n == MB.length b); let s0' = seq_uint32_of_be n s0 in let s1' = seq_uint32_of_be n s1 in let lo = UInt32.v i in let hi = lo + 1 in let s2' = Seq.upd s0' lo v in assert (Seq.length s1' == Seq.length s2'); let i' = UInt32.v i in let g (j' : nat) : Lemma (requires (j' < n)) (ensures (j' < n /\ Seq.index s1' j' == Seq.index s2' j')) = if j' = UInt32.v i then () else begin let u () : Lemma (Seq.slice s0 (4 * j') (4 * j' + 4) == Seq.slice s1 (4 * j') (4 * j' + 4)) = if j' < UInt32.v i then begin Seq.slice_slice s0 0 (4 * i') (4 * j') (4 * j' + 4); Seq.slice_slice s1 0 (4 * i') (4 * j') (4 * j' + 4) end else begin Seq.slice_slice s0 (4 * i' + 4) (MB.length b) (4 * (j' - i' - 1)) (4 * (j' - i')); Seq.slice_slice s1 (4 * i' + 4) (MB.length b) (4 * (j' - i' - 1)) (4 * (j' - i')) end in u () end in Classical.forall_intro (Classical.move_requires g) in f ()
{ "file_name": "ulib/LowStar.Endianness.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 8, "end_line": 551, "start_col": 0, "start_line": 493 }
module LowStar.Endianness /// Stateful operations between machine integers and buffers of uint8s. Most of /// these operations are implemented natively using the target's system endianness /// headers, relying on macros or static inline declarations. /// /// .. note:: /// /// This module supersedes ``C.Endianness``. module MB = LowStar.Monotonic.Buffer module B = LowStar.Buffer open FStar.HyperStack.ST open FStar.Endianness open LowStar.BufferOps module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module U128 = FStar.UInt128 module HS = FStar.HyperStack inline_for_extraction type u8 = U8.t inline_for_extraction type u16 = U16.t inline_for_extraction type u32 = U32.t inline_for_extraction type u64 = U64.t inline_for_extraction type u128 = U128.t /// Byte-swapping operations /// ------------------------ /// /// TODO these are totally unspecified assume val htole16: u16 -> u16 assume val le16toh: u16 -> u16 assume val htole32: u32 -> u32 assume val le32toh: u32 -> u32 assume val htole64: u64 -> u64 assume val le64toh: u64 -> u64 assume val htobe16: u16 -> u16 assume val be16toh: u16 -> u16 assume val htobe32: u32 -> u32 assume val be32toh: u32 -> u32 assume val htobe64: u64 -> u64 assume val be64toh: u64 -> u64 /// Precondition for store functions /// /// Parametrized by the predicate that different store functions can pass accordingly /// /// Typically saying sequence contents are le_to_n or be_to_n etc. unfold let store_pre (#a:Type) (#rrel #rel:MB.srel a) (b:MB.mbuffer a rrel rel) (i:nat) (j:nat{i + j <= MB.length b}) (predicate:Seq.seq a -> Type0) = fun (h:HS.mem) -> let sb = MB.as_seq h b in let len = MB.length b in MB.live h b /\ (forall (s:Seq.seq a). //monotonicity precondition that once the contents of the buffer //between [i, j) are replaced as per the predicate, the //preorder rel is satisfied (Seq.length s == len /\ Seq.equal (Seq.slice s 0 i) (Seq.slice sb 0 i) /\ Seq.equal (Seq.slice s (i + j) len) (Seq.slice sb (i + j) len) /\ predicate (Seq.slice s i (i + j))) ==> rel sb s) /// Common postcondition unfold let store_post (#a:Type) (#rrel #rel:MB.srel a) (b:MB.mbuffer a rrel rel) (i:nat) (j:nat{i + j <= MB.length b}) (predicate:Seq.seq a -> Type0) = fun (h0:HS.mem) (_:unit) (h1:HS.mem) -> MB.live h1 b /\ MB.(modifies (loc_buffer b) h0 h1) /\ (let s1 = MB.as_seq h0 b in let s2 = MB.as_seq h1 b in let len = MB.length b in //the buffer only changes in the interval [i, j) as per the predicate Seq.equal (Seq.slice s2 0 i) (Seq.slice s1 0 i) /\ Seq.equal (Seq.slice s2 (i + j) len) (Seq.slice s1 (i + j) len) /\ predicate (Seq.slice s2 i (i + j))) /// Loads and stores /// ---------------- /// /// These are primitive assume val store16_le_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 2 <= MB.length b}) (z:u16) : Stack unit (requires (store_pre b (U32.v i) 2 (fun s -> le_to_n s == U16.v z))) (ensures (store_post b (U32.v i) 2 (fun s -> le_to_n s == U16.v z))) assume val load16_le_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 2 <= MB.length b}) : Stack u16 (requires fun h -> MB.live h b) (ensures fun h0 z h1 -> h0 == h1 /\ MB.live h1 b /\ le_to_n (Seq.slice (MB.as_seq h1 b) (U32.v i) (U32.v i + 2)) == U16.v z) assume val store16_be_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 2 <= MB.length b}) (z:u16) : Stack unit (requires (store_pre b (U32.v i) 2 (fun s -> be_to_n s == U16.v z))) (ensures (store_post b (U32.v i) 2 (fun s -> be_to_n s == U16.v z))) assume val load16_be_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 2 <= MB.length b}) : Stack u16 (requires fun h -> MB.live h b) (ensures fun h0 z h1 -> h0 == h1 /\ MB.live h1 b /\ be_to_n (Seq.slice (MB.as_seq h1 b) (U32.v i) (U32.v i + 2)) == U16.v z) assume val store32_le_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 4 <= MB.length b}) (z:u32) : Stack unit (requires (store_pre b (U32.v i) 4 (fun s -> le_to_n s == U32.v z))) (ensures (store_post b (U32.v i) 4 (fun s -> le_to_n s == U32.v z))) assume val load32_le_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 4 <= MB.length b}) : Stack u32 (requires fun h -> MB.live h b) (ensures fun h0 z h1 -> h0 == h1 /\ MB.live h1 b /\ le_to_n (Seq.slice (MB.as_seq h1 b) (U32.v i) (U32.v i + 4)) == U32.v z) assume val store32_be_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 4 <= MB.length b}) (z:u32) : Stack unit (requires (store_pre b (U32.v i) 4 (fun s -> be_to_n s == U32.v z))) (ensures (store_post b (U32.v i) 4 (fun s -> be_to_n s == U32.v z))) assume val load32_be_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 4 <= MB.length b}) : Stack u32 (requires fun h -> MB.live h b) (ensures fun h0 z h1 -> h0 == h1 /\ MB.live h1 b /\ be_to_n (Seq.slice (MB.as_seq h1 b) (U32.v i) (U32.v i + 4)) == U32.v z) assume val store64_le_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 8 <= MB.length b}) (z:u64) : Stack unit (requires (store_pre b (U32.v i) 8 (fun s -> le_to_n s == U64.v z))) (ensures (store_post b (U32.v i) 8 (fun s -> le_to_n s == U64.v z))) assume val load64_le_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 8 <= MB.length b}) : Stack u64 (requires fun h -> MB.live h b) (ensures fun h0 z h1 -> h0 == h1 /\ MB.live h1 b /\ le_to_n (Seq.slice (MB.as_seq h1 b) (U32.v i) (U32.v i + 8)) == U64.v z) assume val store64_be_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 8 <= MB.length b}) (z:u64) : Stack unit (requires (store_pre b (U32.v i) 8 (fun s -> be_to_n s == U64.v z))) (ensures (store_post b (U32.v i) 8 (fun s -> be_to_n s == U64.v z))) assume val load64_be_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 8 <= MB.length b}) : Stack u64 (requires fun h -> MB.live h b) (ensures fun h0 z h1 -> h0 == h1 /\ MB.live h1 b /\ be_to_n (Seq.slice (MB.as_seq h1 b) (U32.v i) (U32.v i + 8)) == U64.v z) assume val store128_le_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 16 <= MB.length b}) (z:u128) : Stack unit (requires (store_pre b (U32.v i) 16 (fun s -> le_to_n s == U128.v z))) (ensures (store_post b (U32.v i) 16 (fun s -> le_to_n s == U128.v z))) assume val load128_le_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 16 <= MB.length b}) : Stack u128 (requires fun h -> MB.live h b) (ensures fun h0 z h1 -> h0 == h1 /\ MB.live h1 b /\ le_to_n (Seq.slice (MB.as_seq h1 b) (U32.v i) (U32.v i + 16)) == U128.v z) assume val store128_be_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 16 <= MB.length b}) (z:u128) : Stack unit (requires (store_pre b (U32.v i) 16 (fun s -> be_to_n s == U128.v z))) (ensures (store_post b (U32.v i) 16 (fun s -> be_to_n s == U128.v z))) assume val load128_be_i (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32{U32.v i + 16 <= MB.length b}) : Stack u128 (requires fun h -> MB.live h b) (ensures fun h0 z h1 -> h0 == h1 /\ MB.live h1 b /\ be_to_n (Seq.slice (MB.as_seq h1 b) (U32.v i) (U32.v i + 16)) == U128.v z) /// Loads and stores, on buffers of the right size. /// ----------------------------------------------- /// /// There is bunch of legacy code that wants these operators that operate on buffers of exactly the right size. This is actually more restrictive than the version above, which operates on monotonic buffers, so we offer specialized operators. let store16_le (b:B.buffer UInt8.t{B.length b == 2}) (z:UInt16.t): Stack unit (requires (fun h -> B.live h b)) (ensures (fun h0 _ h1 -> B.(modifies (loc_buffer b) h0 h1) /\ B.live h1 b /\ le_to_n (B.as_seq h1 b) == UInt16.v z)) = store16_le_i b 0ul z let load16_le (b:B.buffer UInt8.t{B.length b == 2}): Stack UInt16.t (requires (fun h -> B.live h b)) (ensures (fun h0 z h1 -> h0 == h1 /\ B.live h1 b /\ le_to_n (B.as_seq h1 b) == UInt16.v z)) = load16_le_i b 0ul let store16_be (b:B.buffer UInt8.t{B.length b == 2}) (z:UInt16.t): Stack unit (requires (fun h -> B.live h b)) (ensures (fun h0 _ h1 -> B.(modifies (loc_buffer b) h0 h1) /\ B.live h1 b /\ be_to_n (B.as_seq h1 b) == UInt16.v z)) = store16_be_i b 0ul z let load16_be (b:B.buffer UInt8.t{B.length b == 2}): Stack UInt16.t (requires (fun h -> B.live h b)) (ensures (fun h0 z h1 -> h0 == h1 /\ B.live h1 b /\ be_to_n (B.as_seq h1 b) == UInt16.v z)) = load16_be_i b 0ul let store32_le (b:B.buffer UInt8.t{B.length b == 4}) (z:UInt32.t): Stack unit (requires (fun h -> B.live h b)) (ensures (fun h0 _ h1 -> B.(modifies (loc_buffer b) h0 h1) /\ B.live h1 b /\ le_to_n (B.as_seq h1 b) == UInt32.v z)) = store32_le_i b 0ul z let load32_le (b:B.buffer UInt8.t{B.length b == 4}): Stack UInt32.t (requires (fun h -> B.live h b)) (ensures (fun h0 z h1 -> h0 == h1 /\ B.live h1 b /\ le_to_n (B.as_seq h1 b) == UInt32.v z)) = load32_le_i b 0ul let store32_be (b:B.buffer UInt8.t{B.length b == 4}) (z:UInt32.t): Stack unit (requires (fun h -> B.live h b)) (ensures (fun h0 _ h1 -> B.(modifies (loc_buffer b) h0 h1) /\ B.live h1 b /\ be_to_n (B.as_seq h1 b) == UInt32.v z)) = store32_be_i b 0ul z let load32_be (b:B.buffer UInt8.t{B.length b == 4}): Stack UInt32.t (requires (fun h -> B.live h b)) (ensures (fun h0 z h1 -> h0 == h1 /\ B.live h1 b /\ be_to_n (B.as_seq h1 b) == UInt32.v z)) = load32_be_i b 0ul let store64_le (b:B.buffer UInt8.t{B.length b == 8}) (z:UInt64.t): Stack unit (requires (fun h -> B.live h b)) (ensures (fun h0 _ h1 -> B.(modifies (loc_buffer b) h0 h1) /\ B.live h1 b /\ le_to_n (B.as_seq h1 b) == UInt64.v z)) = store64_le_i b 0ul z let load64_le (b:B.buffer UInt8.t{B.length b == 8}): Stack UInt64.t (requires (fun h -> B.live h b)) (ensures (fun h0 z h1 -> h0 == h1 /\ B.live h1 b /\ le_to_n (B.as_seq h1 b) == UInt64.v z)) = load64_le_i b 0ul let load64_be (b:B.buffer UInt8.t{B.length b == 8}): Stack UInt64.t (requires (fun h -> B.live h b)) (ensures (fun h0 z h1 -> h0 == h1 /\ B.live h1 b /\ be_to_n (B.as_seq h1 b) == UInt64.v z)) = load64_be_i b 0ul let store64_be (b:B.buffer UInt8.t{B.length b == 8}) (z:UInt64.t): Stack unit (requires (fun h -> B.live h b)) (ensures (fun h0 _ h1 -> B.(modifies (loc_buffer b) h0 h1) /\ B.live h1 b /\ be_to_n (B.as_seq h1 b) == UInt64.v z)) = store64_be_i b 0ul z let load128_le (b:B.buffer UInt8.t{B.length b == 16}): Stack UInt128.t (requires (fun h -> B.live h b)) (ensures (fun h0 z h1 -> h0 == h1 /\ B.live h1 b /\ le_to_n (B.as_seq h1 b) == UInt128.v z)) = load128_le_i b 0ul let store128_le (b:B.buffer UInt8.t{B.length b == 16}) (z:UInt128.t): Stack unit (requires (fun h -> B.live h b)) (ensures (fun h0 _ h1 -> B.(modifies (loc_buffer b) h0 h1) /\ B.live h1 b /\ le_to_n (B.as_seq h1 b) == UInt128.v z)) = store128_le_i b 0ul z let load128_be (b:B.buffer UInt8.t{B.length b == 16}): Stack UInt128.t (requires (fun h -> B.live h b)) (ensures (fun h0 z h1 -> h0 == h1 /\ B.live h1 b /\ be_to_n (B.as_seq h1 b) == UInt128.v z)) = load128_be_i b 0ul let store128_be (b:B.buffer UInt8.t{B.length b = 16}) (z:UInt128.t): Stack unit (requires (fun h -> B.live h b)) (ensures (fun h0 _ h1 -> B.(modifies (loc_buffer b) h0 h1) /\ B.live h1 b /\ be_to_n (B.as_seq h1 b) == UInt128.v z)) = store128_be_i b 0ul z /// Index and update /// ---------------- /// /// These are more sophisticated than load/store above, because they reason /// over the underlying sequence of bytes interpreted as a sequence of (little|big)-endian /// integers. #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" inline_for_extraction let index_32_be (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32) : Stack u32 (requires fun h -> MB.live h b /\ MB.length b % 4 = 0 /\ U32.v i < MB.length b / 4) (ensures fun h0 r h1 -> h0 == h1 /\ r = Seq.index (seq_uint32_of_be (MB.length b / 4) (MB.as_seq h0 b)) (U32.v i)) = load32_be_i b FStar.UInt32.(4ul *^ i) inline_for_extraction let index_32_le (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32) : Stack u32 (requires fun h -> MB.live h b /\ MB.length b % 4 = 0 /\ U32.v i < MB.length b / 4) (ensures fun h0 r h1 -> h0 == h1 /\ r = Seq.index (seq_uint32_of_le (MB.length b / 4) (MB.as_seq h0 b)) (U32.v i)) = load32_le_i b FStar.UInt32.(4ul *^ i) inline_for_extraction let index_64_be (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32) : Stack u64 (requires fun h -> MB.live h b /\ MB.length b % 8 = 0 /\ U32.v i < MB.length b / 8) (ensures fun h0 r h1 -> h0 == h1 /\ r = Seq.index (seq_uint64_of_be (MB.length b / 8) (MB.as_seq h0 b)) (UInt32.v i)) = load64_be_i b FStar.UInt32.(8ul *^ i) inline_for_extraction let index_64_le (#rrel #rel:MB.srel u8) (b:MB.mbuffer u8 rrel rel) (i:u32) : Stack u64 (requires fun h -> MB.live h b /\ MB.length b % 8 = 0 /\ U32.v i < MB.length b / 8) (ensures fun h0 r h1 -> h0 == h1 /\ r = Seq.index (seq_uint64_of_le (MB.length b / 8) (MB.as_seq h0 b)) (UInt32.v i)) = load64_le_i b FStar.UInt32.(8ul *^ i) #reset-options "--using_facts_from 'Prims'" let interval_4_disjoint (i j: nat) : Lemma (requires (i <> j)) (ensures (let open FStar.Mul in 4 * i + 4 <= 4 * j \/ 4 * j + 4 <= 4 * i)) = () #reset-options "--z3rlimit 16 --max_fuel 0 --max_ifuel 0" open FStar.Mul
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt128.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Endianness.fsti.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "LowStar.Endianness.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.UInt128", "short_module": "U128" }, { "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": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "LowStar.BufferOps", "short_module": null }, { "abbrev": false, "full_module": "FStar.Endianness", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "LowStar.Monotonic.Buffer", "short_module": "MB" }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: LowStar.Monotonic.Buffer.mbuffer LowStar.Endianness.u8 rrel rel -> i: LowStar.Endianness.u32 -> v: LowStar.Endianness.u32 -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "LowStar.Monotonic.Buffer.srel", "LowStar.Endianness.u8", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Endianness.u32", "Prims.unit", "Prims.l_True", "Prims.squash", "FStar.Seq.Base.equal", "FStar.UInt32.t", "FStar.Endianness.seq_uint32_of_be", "Prims.op_Division", "LowStar.Monotonic.Buffer.length", "LowStar.Monotonic.Buffer.as_seq", "FStar.Seq.Base.upd", "FStar.UInt32.v", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Classical.forall_intro", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.index", "FStar.Classical.move_requires", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt32.n", "Prims.bool", "FStar.Seq.Base.seq", "FStar.Seq.Base.slice", "Prims.op_Multiply", "Prims.op_Addition", "FStar.Seq.Properties.slice_slice", "FStar.Mul.op_Star", "Prims.op_Subtraction", "FStar.UInt.uint_t", "Prims._assert", "FStar.Seq.Base.length", "FStar.UInt32.op_Star_Hat", "FStar.UInt32.__uint_to_t", "FStar.Endianness.be_to_n", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.Endianness.store32_be_i", "Prims.op_Modulus", "LowStar.Endianness.store_pre", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_buffer" ]
[]
false
true
false
false
false
let upd_32_be (#rrel #rel: MB.srel u8) (b: MB.mbuffer u8 rrel rel) (i v: u32) : Stack unit (requires fun h -> MB.length b % 4 = 0 /\ U32.v i < MB.length b / 4 /\ store_pre b (let open U32 in v (4ul *^ i)) 4 (fun s -> be_to_n s == U32.v v) h) (ensures fun h0 _ h1 -> MB.(modifies (loc_buffer b) h0 h1) /\ (seq_uint32_of_be (MB.length b / 4) (MB.as_seq h1 b)) `Seq.equal` (Seq.upd (seq_uint32_of_be (MB.length b / 4) (MB.as_seq h0 b)) (U32.v i) v)) =
let h0 = get () in store32_be_i b U32.(4ul *^ i) v; let h1 = get () in assert (be_to_n (Seq.slice (MB.as_seq h1 b) (let open U32 in v (4ul *^ i)) (let open U32 in v (4ul *^ i) + 4)) == U32.v v); assert (Seq.equal (Seq.slice (MB.as_seq h0 b) 0 (let open U32 in v (4ul *^ i))) (Seq.slice (MB.as_seq h1 b) 0 (let open U32 in v (4ul *^ i)))); assert (Seq.equal (Seq.slice (MB.as_seq h0 b) (let open U32 in v (4ul *^ i) + 4) (MB.length b)) (Seq.slice (MB.as_seq h1 b) (let open U32 in v (4ul *^ i) + 4) (MB.length b))); let f () : Lemma ((seq_uint32_of_be (MB.length b / 4) (MB.as_seq h1 b)) `Seq.equal` (Seq.upd (seq_uint32_of_be (MB.length b / 4) (MB.as_seq h0 b)) (UInt32.v i) v)) = let s0 = MB.as_seq h0 b in let s1 = MB.as_seq h1 b in let n = MB.length b / 4 in assert (4 `Prims.op_Multiply` n == MB.length b); let s0' = seq_uint32_of_be n s0 in let s1' = seq_uint32_of_be n s1 in let lo = UInt32.v i in let hi = lo + 1 in let s2' = Seq.upd s0' lo v in assert (Seq.length s1' == Seq.length s2'); let i' = UInt32.v i in let g (j': nat) : Lemma (requires (j' < n)) (ensures (j' < n /\ Seq.index s1' j' == Seq.index s2' j')) = if j' = UInt32.v i then () else let u () : Lemma (Seq.slice s0 (4 * j') (4 * j' + 4) == Seq.slice s1 (4 * j') (4 * j' + 4)) = if j' < UInt32.v i then (Seq.slice_slice s0 0 (4 * i') (4 * j') (4 * j' + 4); Seq.slice_slice s1 0 (4 * i') (4 * j') (4 * j' + 4)) else (Seq.slice_slice s0 (4 * i' + 4) (MB.length b) (4 * (j' - i' - 1)) (4 * (j' - i')); Seq.slice_slice s1 (4 * i' + 4) (MB.length b) (4 * (j' - i' - 1)) (4 * (j' - i'))) in u () in Classical.forall_intro (Classical.move_requires g) in f ()
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.seq_of_bytes'
val seq_of_bytes' (x: bytes32) (accu: Seq.seq byte) : Tot (y: Seq.seq byte {y `Seq.equal` (accu `Seq.append` (B32.reveal x))}) (decreases (B32.length x))
val seq_of_bytes' (x: bytes32) (accu: Seq.seq byte) : Tot (y: Seq.seq byte {y `Seq.equal` (accu `Seq.append` (B32.reveal x))}) (decreases (B32.length x))
let rec seq_of_bytes' (x: bytes32) (accu: Seq.seq byte) : Tot (y: Seq.seq byte { y `Seq.equal` (accu `Seq.append` B32.reveal x) }) (decreases (B32.length x)) = if B32.len x = 0ul then accu else (seq_of_bytes' (B32.slice x 1ul (B32.len x)) (Seq.append accu (Seq.create 1 (B32.index x 0))) <: Seq.seq byte)
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 117, "end_line": 444, "start_col": 0, "start_line": 437 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2)) let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2)) let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures ( k.parser_kind_low <= U32.v consumed /\ ( Some? k.parser_kind_high ==> ( let (Some hi) = k.parser_kind_high in U32.v consumed <= hi )))) = parser_kind_prop_equiv k p let parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires ( k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input )) (ensures ( Some? (p32 input) )) = parser_kind_prop_equiv k p inline_for_extraction let u32_max : (y: U32.t { forall (x: U32.t) . {:pattern (U32.v x)} U32.v x <= U32.v y } ) = 4294967295ul inline_for_extraction let add_overflow (x y: U32.t) : Pure U32.t (requires True) (ensures (fun z -> if U32.v x + U32.v y > U32.v u32_max then z == u32_max else U32.v z == U32.v x + U32.v y )) = if U32.lt (U32.sub u32_max y) x then u32_max else U32.add x y let size32_postcond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (x: t) (y: U32.t) : GTot Type0 = let sz = Seq.length (serialize s x) in if sz > U32.v u32_max then y == u32_max else U32.v y == sz [@unifier_hint_injective] inline_for_extraction let size32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (x: t) -> Tot (y: U32.t { size32_postcond s x y }) let size32_constant_precond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) : GTot Type0 = k.parser_kind_high == Some k.parser_kind_low /\ U32.v len32 == k.parser_kind_low inline_for_extraction let size32_constant (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) (u: unit { size32_constant_precond s len32 } ) : Tot (size32 s) = fun x -> [@inline_let] let (z: U32.t { size32_postcond s x z } ) = len32 in z inline_for_extraction let size32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': size32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (size32 (serialize_ext p1 s1 p2)) = fun input -> s1' input (* Total parsers for sequences *) [@"opaque_to_smt"] irreducible let rec bytes_of_seq' (x: Seq.seq byte) (accu: bytes32 { B32.length accu + Seq.length x < 4294967296 }) : Tot (y: bytes32 { B32.reveal y `Seq.equal` (B32.reveal accu `Seq.append` x) }) (decreases (Seq.length x)) = if Seq.length x = 0 then accu else bytes_of_seq' (Seq.tail x) (B32.append accu (B32.create 1ul (Seq.head x))) [@"opaque_to_smt"] inline_for_extraction let bytes_of_seq (x: Seq.seq byte { Seq.length x < 4294967296 }) : Tot (y: bytes32 { B32.reveal y `Seq.equal` x }) = bytes_of_seq' x B32.empty_bytes inline_for_extraction let parse_tot_seq_of_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p { k.parser_kind_subkind == Some ParserStrong /\ begin match k.parser_kind_high with | None -> False | Some max -> max < 4294967296 end }) (x: Seq.seq byte) : Tot (y: _ { y == parse p x }) = match k.parser_kind_high with | Some max -> if Seq.length x < max then match p32 (bytes_of_seq x) with | None -> None | Some (x, consumed) -> Some (x, U32.v consumed) else begin [@inline_let] let max32 = U32.uint_to_t max in let res = p32 (bytes_of_seq (Seq.slice x 0 max)) in Classical.move_requires (parse_strong_prefix p x) (Seq.slice x 0 max); Classical.move_requires (parse_strong_prefix p (Seq.slice x 0 max)) x; parser_kind_prop_equiv k p; match res with | None -> None | Some (x, consumed) -> Some (x, U32.v consumed) end [@"opaque_to_smt"]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: LowParse.SLow.Base.bytes32 -> accu: FStar.Seq.Base.seq LowParse.Bytes.byte -> Prims.Tot (y: FStar.Seq.Base.seq LowParse.Bytes.byte {FStar.Seq.Base.equal y (FStar.Seq.Base.append accu (FStar.Bytes.reveal x))})
Prims.Tot
[ "total", "" ]
[]
[ "LowParse.SLow.Base.bytes32", "FStar.Seq.Base.seq", "LowParse.Bytes.byte", "Prims.op_Equality", "FStar.UInt32.t", "FStar.Bytes.len", "FStar.UInt32.__uint_to_t", "Prims.bool", "LowParse.SLow.Base.seq_of_bytes'", "FStar.Bytes.slice", "FStar.Seq.Base.append", "FStar.Seq.Base.create", "FStar.Bytes.index", "FStar.Seq.Base.equal", "FStar.Bytes.reveal" ]
[ "recursion" ]
false
false
false
false
false
let rec seq_of_bytes' (x: bytes32) (accu: Seq.seq byte) : Tot (y: Seq.seq byte {y `Seq.equal` (accu `Seq.append` (B32.reveal x))}) (decreases (B32.length x)) =
if B32.len x = 0ul then accu else (seq_of_bytes' (B32.slice x 1ul (B32.len x)) (Seq.append accu (Seq.create 1 (B32.index x 0))) <: Seq.seq byte)
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.parser32_injective
val parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires (let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ (let Some (v1, _) = p1 in let Some (v2, _) = p2 in v1 == v2))) (ensures (let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ (let Some (v1, consumed1) = p1 in let Some (v2, consumed2) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2)))
val parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires (let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ (let Some (v1, _) = p1 in let Some (v2, _) = p2 in v1 == v2))) (ensures (let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ (let Some (v1, consumed1) = p1 in let Some (v2, consumed2) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2)))
let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2))
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 71, "end_line": 251, "start_col": 0, "start_line": 220 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
p32: LowParse.SLow.Base.parser32 p -> input1: LowParse.SLow.Base.bytes32 -> input2: LowParse.SLow.Base.bytes32 -> FStar.Pervasives.Lemma (requires (let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ (let _ = p1 in (let FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ v1 _) = _ in let _ = p2 in (let FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ v2 _) = _ in v1 == v2) <: Prims.logical) <: Prims.logical))) (ensures (let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ (let _ = p1 in (let FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ v1 consumed1) = _ in let _ = p2 in (let FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ v2 consumed2) = _ in v1 == v2 /\ consumed1 == consumed2 /\ FStar.UInt32.v consumed1 <= FStar.Bytes.length input1 /\ FStar.UInt32.v consumed2 <= FStar.Bytes.length input2 /\ LowParse.Bytes32.b32slice input1 0ul consumed1 == LowParse.Bytes32.b32slice input2 0ul consumed2) <: Prims.logical) <: Prims.logical)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "LowParse.SLow.Base.bytes32", "Prims._assert", "LowParse.Spec.Base.injective_postcond", "FStar.Bytes.reveal", "Prims.unit", "LowParse.Spec.Base.injective_precond", "LowParse.Spec.Base.parser_kind_prop_equiv", "Prims.l_and", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.tuple2", "FStar.UInt32.t", "Prims.eq2", "Prims.logical", "FStar.Pervasives.Native.option", "LowParse.SLow.Base.parser32_correct", "Prims.squash", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "FStar.Bytes.length", "FStar.Bytes.bytes", "LowParse.Bytes32.b32slice", "FStar.UInt32.__uint_to_t", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires (let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ (let Some (v1, _) = p1 in let Some (v2, _) = p2 in v1 == v2))) (ensures (let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ (let Some (v1, consumed1) = p1 in let Some (v2, consumed2) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2))) =
parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2))
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.pfelem_add_cm
val pfelem_add_cm:cm pfelem
val pfelem_add_cm:cm pfelem
let pfelem_add_cm : cm pfelem = CM zero ( +% ) add_identity add_associativity add_commutativity
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 65, "end_line": 79, "start_col": 0, "start_line": 78 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime val add_identity: a:pfelem -> Lemma (zero +% a == a) let add_identity a = normalize_term_spec prime val mul_identity: a:pfelem -> Lemma (one *% a == a) let mul_identity a = normalize_term_spec prime val add_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a +% b +% c == a +% (b +% c)) let add_associativity a b c = normalize_term_spec prime; calc (==) { a +% b +% c; == { } ((a + b) % prime + c) % prime; == { Math.Lemmas.lemma_mod_plus_distr_l (a + b) c prime } ((a + b) + c) % prime; == { } (a + (b + c)) % prime; == { Math.Lemmas.lemma_mod_plus_distr_r a (b + c) prime } a +% (b +% c); } val add_commutativity: a:pfelem -> b:pfelem -> Lemma (a +% b == b +% a) let add_commutativity a b = () val mul_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a *% b *% c == a *% (b *% c)) let mul_associativity a b c = calc (==) { a *% b *% c; == { } (((a * b) % prime) * c) % prime; == { Math.Lemmas.lemma_mod_mul_distr_l (a * b) c prime } ((a * b) * c) % prime; == { Math.Lemmas.paren_mul_right a b c } (a * (b * c)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b * c) prime } (a * ((b * c) % prime)) % prime; == { } a *% (b *% c); } val mul_commutativity: a:pfelem -> b:pfelem -> Lemma (a *% b == b *% a) let mul_commutativity a b = ()
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Algebra.CommMonoid.cm Hacl.Spec.Poly1305.Lemmas.pfelem
Prims.Tot
[ "total" ]
[]
[ "FStar.Algebra.CommMonoid.CM", "Hacl.Spec.Poly1305.Lemmas.pfelem", "Hacl.Spec.Poly1305.Lemmas.zero", "Hacl.Spec.Poly1305.Lemmas.op_Plus_Percent", "Hacl.Spec.Poly1305.Lemmas.add_identity", "Hacl.Spec.Poly1305.Lemmas.add_associativity", "Hacl.Spec.Poly1305.Lemmas.add_commutativity" ]
[]
false
false
false
true
false
let pfelem_add_cm:cm pfelem =
CM zero ( +% ) add_identity add_associativity add_commutativity
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.poly_semiring
val poly_semiring: Prims.unit -> Tac unit
val poly_semiring: Prims.unit -> Tac unit
let poly_semiring () : Tac unit = canon_semiring pfelem_cr; trefl()
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 67, "end_line": 124, "start_col": 0, "start_line": 124 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime val add_identity: a:pfelem -> Lemma (zero +% a == a) let add_identity a = normalize_term_spec prime val mul_identity: a:pfelem -> Lemma (one *% a == a) let mul_identity a = normalize_term_spec prime val add_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a +% b +% c == a +% (b +% c)) let add_associativity a b c = normalize_term_spec prime; calc (==) { a +% b +% c; == { } ((a + b) % prime + c) % prime; == { Math.Lemmas.lemma_mod_plus_distr_l (a + b) c prime } ((a + b) + c) % prime; == { } (a + (b + c)) % prime; == { Math.Lemmas.lemma_mod_plus_distr_r a (b + c) prime } a +% (b +% c); } val add_commutativity: a:pfelem -> b:pfelem -> Lemma (a +% b == b +% a) let add_commutativity a b = () val mul_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a *% b *% c == a *% (b *% c)) let mul_associativity a b c = calc (==) { a *% b *% c; == { } (((a * b) % prime) * c) % prime; == { Math.Lemmas.lemma_mod_mul_distr_l (a * b) c prime } ((a * b) * c) % prime; == { Math.Lemmas.paren_mul_right a b c } (a * (b * c)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b * c) prime } (a * ((b * c) % prime)) % prime; == { } a *% (b *% c); } val mul_commutativity: a:pfelem -> b:pfelem -> Lemma (a *% b == b *% a) let mul_commutativity a b = () [@canon_attr] let pfelem_add_cm : cm pfelem = CM zero ( +% ) add_identity add_associativity add_commutativity [@canon_attr] let pfelem_mul_cm : cm pfelem = CM one ( *% ) mul_identity mul_associativity mul_commutativity val mul_add_distr: distribute_left_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_add_distr a b c = normalize_term_spec prime; calc (==) { a *% (b +% c); == { } (a * (b +% c)) % prime; == { Math.Lemmas.lemma_mod_add_distr a (b + c) prime } (a * ((b + c) % prime)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b + c) prime } (a * (b + c)) % prime; == { Math.Lemmas.distributivity_add_right a b c } (a * b + a * c) % prime; == { Math.Lemmas.lemma_mod_add_distr (a * b) (a * c) prime } (a * b + a *% c) % prime; == { } (a *% c + a * b) % prime; == { Math.Lemmas.lemma_mod_add_distr (a *% c) (a * b) prime } (a *% c + a *% b) % prime; == { } (a *% b + a *% c) % prime; == { } a *% b +% a *% c; } val mul_zero_l: mult_zero_l_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_zero_l a = assert_norm (forall x. zero *% x == zero) val add_opp (a:pfelem) : Lemma (a +% ~%a == zero) let add_opp a = FStar.Math.Lemmas.lemma_mod_add_distr a (-a) prime; FStar.Math.Lemmas.small_mod 0 prime [@canon_attr] let pfelem_cr : cr pfelem = CR pfelem_add_cm pfelem_mul_cm ( ~% ) add_opp mul_add_distr mul_zero_l open FStar.Tactics
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.trefl", "FStar.Tactics.CanonCommSemiring.canon_semiring", "Hacl.Spec.Poly1305.Lemmas.pfelem", "Hacl.Spec.Poly1305.Lemmas.pfelem_cr" ]
[]
false
true
false
false
false
let poly_semiring () : Tac unit =
canon_semiring pfelem_cr; trefl ()
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.pfelem_mul_cm
val pfelem_mul_cm:cm pfelem
val pfelem_mul_cm:cm pfelem
let pfelem_mul_cm : cm pfelem = CM one ( *% ) mul_identity mul_associativity mul_commutativity
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 64, "end_line": 83, "start_col": 0, "start_line": 82 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime val add_identity: a:pfelem -> Lemma (zero +% a == a) let add_identity a = normalize_term_spec prime val mul_identity: a:pfelem -> Lemma (one *% a == a) let mul_identity a = normalize_term_spec prime val add_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a +% b +% c == a +% (b +% c)) let add_associativity a b c = normalize_term_spec prime; calc (==) { a +% b +% c; == { } ((a + b) % prime + c) % prime; == { Math.Lemmas.lemma_mod_plus_distr_l (a + b) c prime } ((a + b) + c) % prime; == { } (a + (b + c)) % prime; == { Math.Lemmas.lemma_mod_plus_distr_r a (b + c) prime } a +% (b +% c); } val add_commutativity: a:pfelem -> b:pfelem -> Lemma (a +% b == b +% a) let add_commutativity a b = () val mul_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a *% b *% c == a *% (b *% c)) let mul_associativity a b c = calc (==) { a *% b *% c; == { } (((a * b) % prime) * c) % prime; == { Math.Lemmas.lemma_mod_mul_distr_l (a * b) c prime } ((a * b) * c) % prime; == { Math.Lemmas.paren_mul_right a b c } (a * (b * c)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b * c) prime } (a * ((b * c) % prime)) % prime; == { } a *% (b *% c); } val mul_commutativity: a:pfelem -> b:pfelem -> Lemma (a *% b == b *% a) let mul_commutativity a b = () [@canon_attr] let pfelem_add_cm : cm pfelem = CM zero ( +% ) add_identity add_associativity add_commutativity
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Algebra.CommMonoid.cm Hacl.Spec.Poly1305.Lemmas.pfelem
Prims.Tot
[ "total" ]
[]
[ "FStar.Algebra.CommMonoid.CM", "Hacl.Spec.Poly1305.Lemmas.pfelem", "Hacl.Spec.Poly1305.Lemmas.one", "Hacl.Spec.Poly1305.Lemmas.op_Star_Percent", "Hacl.Spec.Poly1305.Lemmas.mul_identity", "Hacl.Spec.Poly1305.Lemmas.mul_associativity", "Hacl.Spec.Poly1305.Lemmas.mul_commutativity" ]
[]
false
false
false
true
false
let pfelem_mul_cm:cm pfelem =
CM one ( *% ) mul_identity mul_associativity mul_commutativity
false
ImmutableBuffer.fst
ImmutableBuffer.l
val l:list int
val l:list int
let l :list int = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10]
{ "file_name": "examples/low-mitls-experiments/ImmutableBuffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 49, "end_line": 31, "start_col": 0, "start_line": 31 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module ImmutableBuffer module B = LowStar.Buffer module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module Seq = FStar.Seq module U32 = FStar.UInt32 module IB = LowStar.ImmutableBuffer (* * Testing normalization of lists in the buffer library *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.UninitializedBuffer.fst.checked", "LowStar.PrefixFreezableBuffer.fsti.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.ImmutableBuffer.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "ImmutableBuffer.fst" }
[ { "abbrev": true, "full_module": "LowStar.ImmutableBuffer", "short_module": "IB" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": 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
Prims.list Prims.int
Prims.Tot
[ "total" ]
[]
[ "Prims.Cons", "Prims.int", "Prims.Nil" ]
[]
false
false
false
true
false
let l:list int =
[1; 2; 3; 4; 5; 6; 7; 8; 9; 10]
false
LowParse.SLow.Base.fst
LowParse.SLow.Base.parse_tot_seq_of_parser32
val parse_tot_seq_of_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p { k.parser_kind_subkind == Some ParserStrong /\ (match k.parser_kind_high with | None -> False | Some max -> max < 4294967296) }) (x: Seq.seq byte) : Tot (y: _{y == parse p x})
val parse_tot_seq_of_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p { k.parser_kind_subkind == Some ParserStrong /\ (match k.parser_kind_high with | None -> False | Some max -> max < 4294967296) }) (x: Seq.seq byte) : Tot (y: _{y == parse p x})
let parse_tot_seq_of_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p { k.parser_kind_subkind == Some ParserStrong /\ begin match k.parser_kind_high with | None -> False | Some max -> max < 4294967296 end }) (x: Seq.seq byte) : Tot (y: _ { y == parse p x }) = match k.parser_kind_high with | Some max -> if Seq.length x < max then match p32 (bytes_of_seq x) with | None -> None | Some (x, consumed) -> Some (x, U32.v consumed) else begin [@inline_let] let max32 = U32.uint_to_t max in let res = p32 (bytes_of_seq (Seq.slice x 0 max)) in Classical.move_requires (parse_strong_prefix p x) (Seq.slice x 0 max); Classical.move_requires (parse_strong_prefix p (Seq.slice x 0 max)) x; parser_kind_prop_equiv k p; match res with | None -> None | Some (x, consumed) -> Some (x, U32.v consumed) end
{ "file_name": "src/lowparse/LowParse.SLow.Base.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 7, "end_line": 433, "start_col": 0, "start_line": 403 }
module LowParse.SLow.Base include LowParse.Spec.Base module B32 = LowParse.Bytes32 module U32 = FStar.UInt32 let bytes32 = B32.bytes let parser32_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option (t * U32.t)) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (hres, consumed) -> Some? gp /\ ( let (Some (hres' , consumed')) = gp in hres == hres' /\ U32.v consumed == (consumed' <: nat) ) [@unifier_hint_injective] inline_for_extraction let parser32 (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option (t * U32.t) { parser32_correct p input res } ) let parser32_consumes (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (Some? (p32 input) ==> (let (Some (_, consumed)) = p32 input in U32.v consumed <= B32.length input)) = () let parser32_consumes' (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (match p32 input with | Some (_, consumed) -> U32.v consumed <= B32.length input | _ -> True) = () inline_for_extraction let make_parser32 (#k: parser_kind) (#t: Type) (p: parser k t) (p32: (input: bytes32) -> Pure (option (t * U32.t)) (requires True) (ensures (fun res -> parser32_correct p input res))) : Tot (parser32 p) = (fun (input: bytes32) -> (p32 input <: (res: option (t * U32.t) { parser32_correct p input res } ))) inline_for_extraction let coerce_parser32 (t2: Type) (#k: parser_kind) (#t1: Type) (#p: parser k t1) (p32: parser32 p) (u: unit { t2 == t1 } ) : Tot (parser32 (coerce_parser t2 p)) = p32 let validator_correct (#k: parser_kind) (#t: Type) (p: parser k t) (input: bytes32) (res: option U32.t) : GTot Type0 = let gp = parse p (B32.reveal input) in match res with | None -> gp == None | Some (consumed) -> Some? gp /\ ( let (Some (_ , consumed')) = gp in U32.v consumed == (consumed' <: nat) ) let validator (#k: parser_kind) (#t: Type) (p: parser k t) : Tot Type = (input: bytes32) -> Tot (res: option U32.t { validator_correct p input res } ) let serializer32_correct (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res == s input let serializer32_correct' (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : GTot Type0 = B32.reveal res `bytes_equal` s input [@unifier_hint_injective] inline_for_extraction let serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_correct_length (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (input: t) (res: bytes32) : Lemma (requires (serializer32_correct s input res)) (ensures ( let len = FStar.Bytes.length res in k.parser_kind_low <= len /\ ( match k.parser_kind_high with | Some max -> len <= max | _ -> True ))) [SMTPat (serializer32_correct s input res); SMTPat (FStar.Bytes.length res)] = serialize_length s input inline_for_extraction let serialize32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': serializer32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (serializer32 (serialize_ext p1 s1 p2)) = fun input -> s1' input inline_for_extraction let partial_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (input: t { Seq.length (s input) < 4294967296 } ) -> Tot (res: bytes32 { serializer32_correct s input res } ) let serializer32_then_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: t) : Lemma (p32 (s32 input) == Some (input, B32.len (s32 input))) = () let parser32_then_serializer32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) : Lemma (requires (Some? (p32 input))) (ensures ( let (Some (v, consumed)) = p32 input in U32.v consumed <= B32.length input /\ s32 v == B32.b32slice input 0ul consumed )) = serializer_correct_implies_complete p s let parser32_then_serializer32' (#k: parser_kind) (#t: Type) (#p: parser k t) (#s: serializer p) (p32: parser32 p) (s32: serializer32 s) (input: bytes32) (v: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (v, consumed))) (ensures ( B32.length (s32 v) == U32.v consumed /\ U32.v consumed <= B32.length input /\ B32.reveal (s32 v) == Seq.slice (B32.reveal input) 0 (U32.v consumed) )) = parser32_then_serializer32 s p32 s32 input let parser32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input1 input2: bytes32) : Lemma (requires ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, _)) = p1 in let (Some (v2, _)) = p2 in v1 == v2 ))) (ensures ( let p1 = p32 input1 in let p2 = p32 input2 in Some? p1 /\ Some? p2 /\ ( let (Some (v1, consumed1)) = p1 in let (Some (v2, consumed2)) = p2 in v1 == v2 /\ consumed1 == consumed2 /\ U32.v consumed1 <= B32.length input1 /\ U32.v consumed2 <= B32.length input2 /\ B32.b32slice input1 0ul consumed1 == B32.b32slice input2 0ul consumed2 ))) = parser_kind_prop_equiv k p; assert (injective_precond p (B32.reveal input1) (B32.reveal input2)); assert (injective_postcond p (B32.reveal input1) (B32.reveal input2)) let serializer32_injective (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (s32: serializer32 s) (input1 input2: t) : Lemma (requires (s32 input1 == s32 input2)) (ensures (input1 == input2)) = assert (parse p (serialize s input1) == parse p (serialize s input2)) let parse32_size (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) (data: t) (consumed: U32.t) : Lemma (requires (p32 input == Some (data, consumed))) (ensures ( k.parser_kind_low <= U32.v consumed /\ ( Some? k.parser_kind_high ==> ( let (Some hi) = k.parser_kind_high in U32.v consumed <= hi )))) = parser_kind_prop_equiv k p let parse32_total (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p) (input: bytes32) : Lemma (requires ( k.parser_kind_high == Some k.parser_kind_low /\ k.parser_kind_metadata == Some ParserKindMetadataTotal /\ k.parser_kind_low <= B32.length input )) (ensures ( Some? (p32 input) )) = parser_kind_prop_equiv k p inline_for_extraction let u32_max : (y: U32.t { forall (x: U32.t) . {:pattern (U32.v x)} U32.v x <= U32.v y } ) = 4294967295ul inline_for_extraction let add_overflow (x y: U32.t) : Pure U32.t (requires True) (ensures (fun z -> if U32.v x + U32.v y > U32.v u32_max then z == u32_max else U32.v z == U32.v x + U32.v y )) = if U32.lt (U32.sub u32_max y) x then u32_max else U32.add x y let size32_postcond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (x: t) (y: U32.t) : GTot Type0 = let sz = Seq.length (serialize s x) in if sz > U32.v u32_max then y == u32_max else U32.v y == sz [@unifier_hint_injective] inline_for_extraction let size32 (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) : Tot Type = (x: t) -> Tot (y: U32.t { size32_postcond s x y }) let size32_constant_precond (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) : GTot Type0 = k.parser_kind_high == Some k.parser_kind_low /\ U32.v len32 == k.parser_kind_low inline_for_extraction let size32_constant (#k: parser_kind) (#t: Type) (#p: parser k t) (s: serializer p) (len32: U32.t) (u: unit { size32_constant_precond s len32 } ) : Tot (size32 s) = fun x -> [@inline_let] let (z: U32.t { size32_postcond s x z } ) = len32 in z inline_for_extraction let size32_ext (#k1: parser_kind) (#t1: Type) (p1: parser k1 t1) (s1: serializer p1) (s1': size32 s1) (#k2: parser_kind) (#t2: Type) (p2: parser k2 t2) (u: squash (t1 == t2 /\ (forall (input: bytes) . parse p1 input == parse p2 input))) : Tot (size32 (serialize_ext p1 s1 p2)) = fun input -> s1' input (* Total parsers for sequences *) [@"opaque_to_smt"] irreducible let rec bytes_of_seq' (x: Seq.seq byte) (accu: bytes32 { B32.length accu + Seq.length x < 4294967296 }) : Tot (y: bytes32 { B32.reveal y `Seq.equal` (B32.reveal accu `Seq.append` x) }) (decreases (Seq.length x)) = if Seq.length x = 0 then accu else bytes_of_seq' (Seq.tail x) (B32.append accu (B32.create 1ul (Seq.head x))) [@"opaque_to_smt"] inline_for_extraction let bytes_of_seq (x: Seq.seq byte { Seq.length x < 4294967296 }) : Tot (y: bytes32 { B32.reveal y `Seq.equal` x }) = bytes_of_seq' x B32.empty_bytes
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Base.fsti.checked", "LowParse.Bytes32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.SLow.Base.fst" }
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowParse.Bytes32", "short_module": "B32" }, { "abbrev": false, "full_module": "LowParse.Spec.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
p32: LowParse.SLow.Base.parser32 p { Mkparser_kind'?.parser_kind_subkind k == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\ (match Mkparser_kind'?.parser_kind_high k with | FStar.Pervasives.Native.None #_ -> Prims.l_False | FStar.Pervasives.Native.Some #_ max -> max < 4294967296) } -> x: FStar.Seq.Base.seq LowParse.Bytes.byte -> y: FStar.Pervasives.Native.option (t * LowParse.Spec.Base.consumed_length x) {y == LowParse.Spec.Base.parse p x}
Prims.Tot
[ "total" ]
[]
[ "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.SLow.Base.parser32", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high", "Prims.l_False", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.logical", "FStar.Seq.Base.seq", "LowParse.Bytes.byte", "FStar.Seq.Base.length", "LowParse.SLow.Base.bytes_of_seq", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Base.consumed_length", "FStar.UInt32.t", "FStar.Pervasives.Native.Mktuple2", "FStar.UInt32.v", "LowParse.Spec.Base.parse", "Prims.bool", "Prims.unit", "LowParse.Spec.Base.parser_kind_prop_equiv", "FStar.Classical.move_requires", "LowParse.Bytes.bytes", "FStar.Seq.Base.slice", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.equal", "LowParse.Spec.Base.parse_strong_prefix", "LowParse.SLow.Base.parser32_correct", "FStar.UInt32.uint_to_t" ]
[]
false
false
false
false
false
let parse_tot_seq_of_parser32 (#k: parser_kind) (#t: Type) (#p: parser k t) (p32: parser32 p { k.parser_kind_subkind == Some ParserStrong /\ (match k.parser_kind_high with | None -> False | Some max -> max < 4294967296) }) (x: Seq.seq byte) : Tot (y: _{y == parse p x}) =
match k.parser_kind_high with | Some max -> if Seq.length x < max then match p32 (bytes_of_seq x) with | None -> None | Some (x, consumed) -> Some (x, U32.v consumed) else [@@ inline_let ]let max32 = U32.uint_to_t max in let res = p32 (bytes_of_seq (Seq.slice x 0 max)) in Classical.move_requires (parse_strong_prefix p x) (Seq.slice x 0 max); Classical.move_requires (parse_strong_prefix p (Seq.slice x 0 max)) x; parser_kind_prop_equiv k p; match res with | None -> None | Some (x, consumed) -> Some (x, U32.v consumed)
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.zero
val zero:pfelem
val zero:pfelem
let zero : pfelem = 0
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 18, "start_col": 0, "start_line": 18 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime}
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Spec.Poly1305.Lemmas.pfelem
Prims.Tot
[ "total" ]
[]
[]
[]
false
false
false
true
false
let zero:pfelem =
0
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.one
val one:pfelem
val one:pfelem
let one : pfelem = normalize_term_spec prime; 1
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 47, "end_line": 21, "start_col": 0, "start_line": 21 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Hacl.Spec.Poly1305.Lemmas.pfelem
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Pervasives.normalize_term_spec", "Prims.pos", "Hacl.Spec.Poly1305.Lemmas.prime" ]
[]
false
false
false
true
false
let one:pfelem =
normalize_term_spec prime; 1
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.pfelem
val pfelem:eqtype
val pfelem:eqtype
let pfelem : eqtype = a:nat{a < prime}
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 38, "end_line": 15, "start_col": 0, "start_line": 15 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Poly1305.Lemmas.prime" ]
[]
false
false
false
true
false
let pfelem:eqtype =
a: nat{a < prime}
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.mul_identity
val mul_identity: a:pfelem -> Lemma (one *% a == a)
val mul_identity: a:pfelem -> Lemma (one *% a == a)
let mul_identity a = normalize_term_spec prime
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 36, "start_col": 0, "start_line": 36 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime val add_identity: a:pfelem -> Lemma (zero +% a == a) let add_identity a = normalize_term_spec prime
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.Spec.Poly1305.Lemmas.pfelem -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Poly1305.Lemmas.one *% a == a)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Hacl.Spec.Poly1305.Lemmas.pfelem", "FStar.Pervasives.normalize_term_spec", "Prims.pos", "Hacl.Spec.Poly1305.Lemmas.prime", "Prims.unit" ]
[]
true
false
true
false
false
let mul_identity a =
normalize_term_spec prime
false
ImmutableBuffer.fst
ImmutableBuffer.test_ub
val test_ub: Prims.unit -> HST.St unit
val test_ub: Prims.unit -> HST.St unit
let test_ub () :HST.St unit = let b = UB.ugcmalloc #int HS.root 10ul in //allocate an uninitialized buffer, no initializer UB.uupd b 1ul 2; //update at index 1 with value 2 let j = UB.uindex b 1ul in //can now project index 1 assert (j == 2); //and check that the value is indeed 2 //let j = UB.uindex b 4ul in --> this fails since the index 4ul is not initialized let b1 = B.gcmalloc HS.root 0 10ul in //allocate a different regular buffer let h0 = HST.get () in UB.ublit b1 2ul b 2ul 3ul; //copy [2, 5) from regular buffer to [2, 5) of uninitialized buffer let h1 = HST.get () in let j = UB.uindex b 4ul in //now 4ul is indexable assert (j == 0); //and we can check its value is 0 (from the source buffer) let j = UB.uindex b 1ul in //1ul remains initialized and has the same value as before assert (Seq.index (UB.as_seq h0 b) 1 == Seq.index (Seq.slice (UB.as_seq h0 b) 0 2) 1); assert (j == 2)
{ "file_name": "examples/low-mitls-experiments/ImmutableBuffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 17, "end_line": 107, "start_col": 0, "start_line": 93 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module ImmutableBuffer module B = LowStar.Buffer module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module Seq = FStar.Seq module U32 = FStar.UInt32 module IB = LowStar.ImmutableBuffer (* * Testing normalization of lists in the buffer library *) [@@"opaque_to_smt"] let l :list int = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10] let test2 (lll:list int{List.Tot.length lll > 0 /\ List.Tot.length lll <= UInt.max_int 32}) :HST.ST unit (fun h0 -> HS.is_stack_region (HS.get_tip h0)) (fun _ _ _ -> True)= let b = B.gcmalloc_of_list HS.root l in assert (B.length b == 10); let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list l); assert (B.length b == List.Tot.length l); let ll = [1;2;3;4;5;6;7;8;9;10;11] in HST.push_frame (); let b = B.alloca_of_list ll in assert (B.length b == 11); let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list ll); assert (B.length b == List.Tot.length ll); let b = B.alloca_of_list lll in let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list lll); assert (B.length b == List.Tot.length lll); HST.pop_frame () assume val havoc (#a:Type0) (#rrel #rel:B.srel a) (b:B.mbuffer a rrel rel) :HST.St unit let test (l:list int{List.Tot.length l == 10}) :HST.St unit = let ls = Seq.seq_of_list l in let b = IB.igcmalloc_of_list HS.root l in assert (B.length b == 10); havoc b; IB.recall_contents b ls; let h = HST.get () in assert (B.as_seq h b == ls); assert (B.live h b); let sb = IB.isub b 0ul 2ul in IB.witness_contents sb (Seq.slice ls 0 2); havoc sb; IB.recall_contents sb (Seq.slice ls 0 2); IB.recall_contents b ls; let h = HST.get () in assert (B.as_seq h b == ls); assert (B.as_seq h sb = Seq.slice ls 0 2); //test partial API let b1 = IB.igcmalloc_of_list_partial HS.root l in if B.is_null b1 then () else begin assert (B.length b1 == 10); IB.recall_contents b1 ls; let h = HST.get () in assert (B.as_seq h b1 == ls) end (***** Tests for uninitialized buffers *****) module UB = LowStar.UninitializedBuffer [@@expect_failure] let test_index_ub (b:UB.ubuffer int) :HST.ST unit (requires (fun h0 -> UB.live h0 b /\ UB.length b == 10)) (ensures (fun _ _ _ -> True)) = ignore (UB.uindex b 0)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.UninitializedBuffer.fst.checked", "LowStar.PrefixFreezableBuffer.fsti.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.ImmutableBuffer.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "ImmutableBuffer.fst" }
[ { "abbrev": true, "full_module": "LowStar.UninitializedBuffer", "short_module": "UB" }, { "abbrev": true, "full_module": "LowStar.ImmutableBuffer", "short_module": "IB" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": 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
_: Prims.unit -> FStar.HyperStack.ST.St Prims.unit
FStar.HyperStack.ST.St
[]
[]
[ "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.int", "FStar.Pervasives.Native.option", "FStar.Seq.Base.index", "LowStar.Monotonic.Buffer.as_seq", "LowStar.UninitializedBuffer.initialization_preorder", "FStar.Seq.Base.slice", "LowStar.UninitializedBuffer.uindex", "FStar.UInt32.__uint_to_t", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.UninitializedBuffer.ublit", "LowStar.Buffer.trivial_preorder", "LowStar.Monotonic.Buffer.mbuffer", "Prims.l_and", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.UInt32.v", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "FStar.Monotonic.HyperHeap.root", "LowStar.Monotonic.Buffer.recallable", "LowStar.Buffer.gcmalloc", "LowStar.UninitializedBuffer.uupd", "LowStar.UninitializedBuffer.ubuffer", "LowStar.UninitializedBuffer.ugcmalloc", "LowStar.UninitializedBuffer.lubuffer" ]
[]
false
true
false
false
false
let test_ub () : HST.St unit =
let b = UB.ugcmalloc #int HS.root 10ul in UB.uupd b 1ul 2; let j = UB.uindex b 1ul in assert (j == 2); let b1 = B.gcmalloc HS.root 0 10ul in let h0 = HST.get () in UB.ublit b1 2ul b 2ul 3ul; let h1 = HST.get () in let j = UB.uindex b 4ul in assert (j == 0); let j = UB.uindex b 1ul in assert (Seq.index (UB.as_seq h0 b) 1 == Seq.index (Seq.slice (UB.as_seq h0 b) 0 2) 1); assert (j == 2)
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.add_identity
val add_identity: a:pfelem -> Lemma (zero +% a == a)
val add_identity: a:pfelem -> Lemma (zero +% a == a)
let add_identity a = normalize_term_spec prime
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 33, "start_col": 0, "start_line": 33 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.Spec.Poly1305.Lemmas.pfelem -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Poly1305.Lemmas.zero +% a == a)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Hacl.Spec.Poly1305.Lemmas.pfelem", "FStar.Pervasives.normalize_term_spec", "Prims.pos", "Hacl.Spec.Poly1305.Lemmas.prime", "Prims.unit" ]
[]
true
false
true
false
false
let add_identity a =
normalize_term_spec prime
false
ImmutableBuffer.fst
ImmutableBuffer.test_witnessed_functoriality
val test_witnessed_functoriality : _: Prims.unit -> Prims.unit
let test_witnessed_functoriality () = assert (LowStar.Monotonic.Buffer.rrel_rel_always_compatible (B.trivial_preorder int) (B.trivial_preorder int)); assert (LowStar.Monotonic.Buffer.rrel_rel_always_compatible (IB.immutable_preorder int) (IB.immutable_preorder int))
{ "file_name": "examples/low-mitls-experiments/ImmutableBuffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 118, "end_line": 166, "start_col": 0, "start_line": 164 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module ImmutableBuffer module B = LowStar.Buffer module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module Seq = FStar.Seq module U32 = FStar.UInt32 module IB = LowStar.ImmutableBuffer (* * Testing normalization of lists in the buffer library *) [@@"opaque_to_smt"] let l :list int = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10] let test2 (lll:list int{List.Tot.length lll > 0 /\ List.Tot.length lll <= UInt.max_int 32}) :HST.ST unit (fun h0 -> HS.is_stack_region (HS.get_tip h0)) (fun _ _ _ -> True)= let b = B.gcmalloc_of_list HS.root l in assert (B.length b == 10); let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list l); assert (B.length b == List.Tot.length l); let ll = [1;2;3;4;5;6;7;8;9;10;11] in HST.push_frame (); let b = B.alloca_of_list ll in assert (B.length b == 11); let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list ll); assert (B.length b == List.Tot.length ll); let b = B.alloca_of_list lll in let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list lll); assert (B.length b == List.Tot.length lll); HST.pop_frame () assume val havoc (#a:Type0) (#rrel #rel:B.srel a) (b:B.mbuffer a rrel rel) :HST.St unit let test (l:list int{List.Tot.length l == 10}) :HST.St unit = let ls = Seq.seq_of_list l in let b = IB.igcmalloc_of_list HS.root l in assert (B.length b == 10); havoc b; IB.recall_contents b ls; let h = HST.get () in assert (B.as_seq h b == ls); assert (B.live h b); let sb = IB.isub b 0ul 2ul in IB.witness_contents sb (Seq.slice ls 0 2); havoc sb; IB.recall_contents sb (Seq.slice ls 0 2); IB.recall_contents b ls; let h = HST.get () in assert (B.as_seq h b == ls); assert (B.as_seq h sb = Seq.slice ls 0 2); //test partial API let b1 = IB.igcmalloc_of_list_partial HS.root l in if B.is_null b1 then () else begin assert (B.length b1 == 10); IB.recall_contents b1 ls; let h = HST.get () in assert (B.as_seq h b1 == ls) end (***** Tests for uninitialized buffers *****) module UB = LowStar.UninitializedBuffer [@@expect_failure] let test_index_ub (b:UB.ubuffer int) :HST.ST unit (requires (fun h0 -> UB.live h0 b /\ UB.length b == 10)) (ensures (fun _ _ _ -> True)) = ignore (UB.uindex b 0) let test_ub () :HST.St unit = let b = UB.ugcmalloc #int HS.root 10ul in //allocate an uninitialized buffer, no initializer UB.uupd b 1ul 2; //update at index 1 with value 2 let j = UB.uindex b 1ul in //can now project index 1 assert (j == 2); //and check that the value is indeed 2 //let j = UB.uindex b 4ul in --> this fails since the index 4ul is not initialized let b1 = B.gcmalloc HS.root 0 10ul in //allocate a different regular buffer let h0 = HST.get () in UB.ublit b1 2ul b 2ul 3ul; //copy [2, 5) from regular buffer to [2, 5) of uninitialized buffer let h1 = HST.get () in let j = UB.uindex b 4ul in //now 4ul is indexable assert (j == 0); //and we can check its value is 0 (from the source buffer) let j = UB.uindex b 1ul in //1ul remains initialized and has the same value as before assert (Seq.index (UB.as_seq h0 b) 1 == Seq.index (Seq.slice (UB.as_seq h0 b) 0 2) 1); assert (j == 2) (***** Tests for bigops in the buffer library *****) #push-options "--max_fuel 0 --max_ifuel 0" let test_bigops (b1:UB.ubuffer int) (b2:IB.ibuffer int) (b3:B.buffer int) (h h0 h1:HS.mem) : unit = let open LowStar.Buffer in let l1, l2, l3 = loc_buffer b1, loc_buffer b2, loc_buffer b3 in assume (live h b1 /\ live h b2 /\ live h b3); assume (loc_disjoint l1 l2 /\ loc_disjoint l2 l3 /\ loc_disjoint l3 l1); assume (modifies (loc_union l1 (loc_union l2 l3)) h0 h1); assert (all_disjoint [l1; l2; l3]); assert (all_live h [buf b1; buf b2; buf b3]); assert (modifies (loc_union_l [l1; l2; l3]) h0 h1) #pop-options (***** Tests for freezable buffers *****) module PF = LowStar.PrefixFreezableBuffer #push-options "--max_fuel 0 --max_ifuel 0" assume val havoc_pf (b:PF.buffer) : HST.ST unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> PF.frozen_until (PF.as_seq h0 b) == PF.frozen_until (PF.as_seq h1 b))) let test_pf () : HST.St unit = let open LowStar.PrefixFreezableBuffer in let b = gcmalloc HS.root 5ul in upd b 4ul 1uy; upd b 5ul 2uy; upd b 6ul 3uy; upd b 7ul 4uy; upd b 8ul 5uy; freeze b 5ul; upd b 5ul 2uy; upd b 6ul 3uy; upd b 7ul 4uy; upd b 8ul 5uy; let snap = Ghost.hide (Seq.create 1 1uy) in witness_slice b 4ul 5ul snap; havoc_pf b; recall_slice b 4ul 5ul snap; let h = HST.get () in assert (Seq.equal (Seq.slice (as_seq h b) 4 5) (Ghost.reveal snap)); ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.UninitializedBuffer.fst.checked", "LowStar.PrefixFreezableBuffer.fsti.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.ImmutableBuffer.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "ImmutableBuffer.fst" }
[ { "abbrev": true, "full_module": "LowStar.PrefixFreezableBuffer", "short_module": "PF" }, { "abbrev": true, "full_module": "LowStar.UninitializedBuffer", "short_module": "UB" }, { "abbrev": true, "full_module": "LowStar.ImmutableBuffer", "short_module": "IB" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> Prims.unit
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "Prims._assert", "LowStar.Monotonic.Buffer.rrel_rel_always_compatible", "Prims.int", "LowStar.ImmutableBuffer.immutable_preorder", "LowStar.Buffer.trivial_preorder" ]
[]
false
false
false
true
false
let test_witnessed_functoriality () =
assert (LowStar.Monotonic.Buffer.rrel_rel_always_compatible (B.trivial_preorder int) (B.trivial_preorder int)); assert (LowStar.Monotonic.Buffer.rrel_rel_always_compatible (IB.immutable_preorder int) (IB.immutable_preorder int))
false
ImmutableBuffer.fst
ImmutableBuffer.test2
val test2 (lll: list int {List.Tot.length lll > 0 /\ List.Tot.length lll <= UInt.max_int 32}) : HST.ST unit (fun h0 -> HS.is_stack_region (HS.get_tip h0)) (fun _ _ _ -> True)
val test2 (lll: list int {List.Tot.length lll > 0 /\ List.Tot.length lll <= UInt.max_int 32}) : HST.ST unit (fun h0 -> HS.is_stack_region (HS.get_tip h0)) (fun _ _ _ -> True)
let test2 (lll:list int{List.Tot.length lll > 0 /\ List.Tot.length lll <= UInt.max_int 32}) :HST.ST unit (fun h0 -> HS.is_stack_region (HS.get_tip h0)) (fun _ _ _ -> True)= let b = B.gcmalloc_of_list HS.root l in assert (B.length b == 10); let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list l); assert (B.length b == List.Tot.length l); let ll = [1;2;3;4;5;6;7;8;9;10;11] in HST.push_frame (); let b = B.alloca_of_list ll in assert (B.length b == 11); let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list ll); assert (B.length b == List.Tot.length ll); let b = B.alloca_of_list lll in let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list lll); assert (B.length b == List.Tot.length lll); HST.pop_frame ()
{ "file_name": "examples/low-mitls-experiments/ImmutableBuffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 52, "start_col": 0, "start_line": 33 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module ImmutableBuffer module B = LowStar.Buffer module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module Seq = FStar.Seq module U32 = FStar.UInt32 module IB = LowStar.ImmutableBuffer (* * Testing normalization of lists in the buffer library *) [@@"opaque_to_smt"] let l :list int = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10]
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.UninitializedBuffer.fst.checked", "LowStar.PrefixFreezableBuffer.fsti.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.ImmutableBuffer.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "ImmutableBuffer.fst" }
[ { "abbrev": true, "full_module": "LowStar.ImmutableBuffer", "short_module": "IB" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": 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
lll: Prims.list Prims.int { FStar.List.Tot.Base.length lll > 0 /\ FStar.List.Tot.Base.length lll <= FStar.UInt.max_int 32 } -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "Prims.list", "Prims.int", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "FStar.List.Tot.Base.length", "Prims.op_LessThanOrEqual", "FStar.UInt.max_int", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "LowStar.Buffer.trivial_preorder", "FStar.Seq.Base.seq", "LowStar.Monotonic.Buffer.as_seq", "FStar.Seq.Base.seq_of_list", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.Monotonic.Buffer.mbuffer", "FStar.Pervasives.normalize_term", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Buffer.alloca_of_list", "FStar.HyperStack.ST.push_frame", "Prims.Cons", "Prims.Nil", "ImmutableBuffer.l", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "FStar.Monotonic.HyperHeap.root", "LowStar.Monotonic.Buffer.recallable", "LowStar.Buffer.gcmalloc_of_list", "FStar.Monotonic.HyperStack.is_stack_region", "FStar.Monotonic.HyperStack.get_tip", "Prims.l_True" ]
[]
false
true
false
false
false
let test2 (lll: list int {List.Tot.length lll > 0 /\ List.Tot.length lll <= UInt.max_int 32}) : HST.ST unit (fun h0 -> HS.is_stack_region (HS.get_tip h0)) (fun _ _ _ -> True) =
let b = B.gcmalloc_of_list HS.root l in assert (B.length b == 10); let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list l); assert (B.length b == List.Tot.length l); let ll = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11] in HST.push_frame (); let b = B.alloca_of_list ll in assert (B.length b == 11); let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list ll); assert (B.length b == List.Tot.length ll); let b = B.alloca_of_list lll in let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list lll); assert (B.length b == List.Tot.length lll); HST.pop_frame ()
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.add_opp
val add_opp (a:pfelem) : Lemma (a +% ~%a == zero)
val add_opp (a:pfelem) : Lemma (a +% ~%a == zero)
let add_opp a = FStar.Math.Lemmas.lemma_mod_add_distr a (-a) prime; FStar.Math.Lemmas.small_mod 0 prime
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 37, "end_line": 116, "start_col": 0, "start_line": 114 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime val add_identity: a:pfelem -> Lemma (zero +% a == a) let add_identity a = normalize_term_spec prime val mul_identity: a:pfelem -> Lemma (one *% a == a) let mul_identity a = normalize_term_spec prime val add_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a +% b +% c == a +% (b +% c)) let add_associativity a b c = normalize_term_spec prime; calc (==) { a +% b +% c; == { } ((a + b) % prime + c) % prime; == { Math.Lemmas.lemma_mod_plus_distr_l (a + b) c prime } ((a + b) + c) % prime; == { } (a + (b + c)) % prime; == { Math.Lemmas.lemma_mod_plus_distr_r a (b + c) prime } a +% (b +% c); } val add_commutativity: a:pfelem -> b:pfelem -> Lemma (a +% b == b +% a) let add_commutativity a b = () val mul_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a *% b *% c == a *% (b *% c)) let mul_associativity a b c = calc (==) { a *% b *% c; == { } (((a * b) % prime) * c) % prime; == { Math.Lemmas.lemma_mod_mul_distr_l (a * b) c prime } ((a * b) * c) % prime; == { Math.Lemmas.paren_mul_right a b c } (a * (b * c)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b * c) prime } (a * ((b * c) % prime)) % prime; == { } a *% (b *% c); } val mul_commutativity: a:pfelem -> b:pfelem -> Lemma (a *% b == b *% a) let mul_commutativity a b = () [@canon_attr] let pfelem_add_cm : cm pfelem = CM zero ( +% ) add_identity add_associativity add_commutativity [@canon_attr] let pfelem_mul_cm : cm pfelem = CM one ( *% ) mul_identity mul_associativity mul_commutativity val mul_add_distr: distribute_left_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_add_distr a b c = normalize_term_spec prime; calc (==) { a *% (b +% c); == { } (a * (b +% c)) % prime; == { Math.Lemmas.lemma_mod_add_distr a (b + c) prime } (a * ((b + c) % prime)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b + c) prime } (a * (b + c)) % prime; == { Math.Lemmas.distributivity_add_right a b c } (a * b + a * c) % prime; == { Math.Lemmas.lemma_mod_add_distr (a * b) (a * c) prime } (a * b + a *% c) % prime; == { } (a *% c + a * b) % prime; == { Math.Lemmas.lemma_mod_add_distr (a *% c) (a * b) prime } (a *% c + a *% b) % prime; == { } (a *% b + a *% c) % prime; == { } a *% b +% a *% c; } val mul_zero_l: mult_zero_l_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_zero_l a = assert_norm (forall x. zero *% x == zero)
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.Spec.Poly1305.Lemmas.pfelem -> FStar.Pervasives.Lemma (ensures a +% ~%a == Hacl.Spec.Poly1305.Lemmas.zero)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Hacl.Spec.Poly1305.Lemmas.pfelem", "FStar.Math.Lemmas.small_mod", "Hacl.Spec.Poly1305.Lemmas.prime", "Prims.unit", "FStar.Math.Lemmas.lemma_mod_add_distr", "Prims.op_Minus" ]
[]
true
false
true
false
false
let add_opp a =
FStar.Math.Lemmas.lemma_mod_add_distr a (- a) prime; FStar.Math.Lemmas.small_mod 0 prime
false
ImmutableBuffer.fst
ImmutableBuffer.test
val test (l: list int {List.Tot.length l == 10}) : HST.St unit
val test (l: list int {List.Tot.length l == 10}) : HST.St unit
let test (l:list int{List.Tot.length l == 10}) :HST.St unit = let ls = Seq.seq_of_list l in let b = IB.igcmalloc_of_list HS.root l in assert (B.length b == 10); havoc b; IB.recall_contents b ls; let h = HST.get () in assert (B.as_seq h b == ls); assert (B.live h b); let sb = IB.isub b 0ul 2ul in IB.witness_contents sb (Seq.slice ls 0 2); havoc sb; IB.recall_contents sb (Seq.slice ls 0 2); IB.recall_contents b ls; let h = HST.get () in assert (B.as_seq h b == ls); assert (B.as_seq h sb = Seq.slice ls 0 2); //test partial API let b1 = IB.igcmalloc_of_list_partial HS.root l in if B.is_null b1 then () else begin assert (B.length b1 == 10); IB.recall_contents b1 ls; let h = HST.get () in assert (B.as_seq h b1 == ls) end
{ "file_name": "examples/low-mitls-experiments/ImmutableBuffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 83, "start_col": 0, "start_line": 56 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module ImmutableBuffer module B = LowStar.Buffer module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module Seq = FStar.Seq module U32 = FStar.UInt32 module IB = LowStar.ImmutableBuffer (* * Testing normalization of lists in the buffer library *) [@@"opaque_to_smt"] let l :list int = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10] let test2 (lll:list int{List.Tot.length lll > 0 /\ List.Tot.length lll <= UInt.max_int 32}) :HST.ST unit (fun h0 -> HS.is_stack_region (HS.get_tip h0)) (fun _ _ _ -> True)= let b = B.gcmalloc_of_list HS.root l in assert (B.length b == 10); let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list l); assert (B.length b == List.Tot.length l); let ll = [1;2;3;4;5;6;7;8;9;10;11] in HST.push_frame (); let b = B.alloca_of_list ll in assert (B.length b == 11); let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list ll); assert (B.length b == List.Tot.length ll); let b = B.alloca_of_list lll in let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list lll); assert (B.length b == List.Tot.length lll); HST.pop_frame () assume val havoc (#a:Type0) (#rrel #rel:B.srel a) (b:B.mbuffer a rrel rel) :HST.St unit
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.UninitializedBuffer.fst.checked", "LowStar.PrefixFreezableBuffer.fsti.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.ImmutableBuffer.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "ImmutableBuffer.fst" }
[ { "abbrev": true, "full_module": "LowStar.ImmutableBuffer", "short_module": "IB" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": 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
l: Prims.list Prims.int {FStar.List.Tot.Base.length l == 10} -> FStar.HyperStack.ST.St Prims.unit
FStar.HyperStack.ST.St
[]
[]
[ "Prims.list", "Prims.int", "Prims.eq2", "FStar.List.Tot.Base.length", "Prims.unit", "Prims.bool", "Prims._assert", "FStar.Seq.Base.seq", "LowStar.Monotonic.Buffer.as_seq", "LowStar.ImmutableBuffer.immutable_preorder", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.ImmutableBuffer.recall_contents", "LowStar.Monotonic.Buffer.length", "LowStar.Monotonic.Buffer.is_null", "LowStar.Monotonic.Buffer.mbuffer", "Prims.l_imp", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "Prims.l_and", "Prims.nat", "FStar.Pervasives.normalize_term", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "FStar.Monotonic.HyperHeap.root", "LowStar.Monotonic.Buffer.witnessed", "LowStar.ImmutableBuffer.cpred", "FStar.Seq.Base.seq_of_list", "LowStar.Monotonic.Buffer.recallable", "LowStar.ImmutableBuffer.igcmalloc_of_list_partial", "LowStar.ImmutableBuffer.libuffer_or_null", "Prims.op_Equality", "FStar.Seq.Base.slice", "ImmutableBuffer.havoc", "LowStar.ImmutableBuffer.witness_contents", "LowStar.ImmutableBuffer.isub", "FStar.UInt32.__uint_to_t", "FStar.Ghost.hide", "FStar.UInt32.t", "LowStar.Monotonic.Buffer.live", "LowStar.ImmutableBuffer.igcmalloc_of_list", "LowStar.ImmutableBuffer.libuffer", "FStar.Seq.Base.length" ]
[]
false
true
false
false
false
let test (l: list int {List.Tot.length l == 10}) : HST.St unit =
let ls = Seq.seq_of_list l in let b = IB.igcmalloc_of_list HS.root l in assert (B.length b == 10); havoc b; IB.recall_contents b ls; let h = HST.get () in assert (B.as_seq h b == ls); assert (B.live h b); let sb = IB.isub b 0ul 2ul in IB.witness_contents sb (Seq.slice ls 0 2); havoc sb; IB.recall_contents sb (Seq.slice ls 0 2); IB.recall_contents b ls; let h = HST.get () in assert (B.as_seq h b == ls); assert (B.as_seq h sb = Seq.slice ls 0 2); let b1 = IB.igcmalloc_of_list_partial HS.root l in if B.is_null b1 then () else (assert (B.length b1 == 10); IB.recall_contents b1 ls; let h = HST.get () in assert (B.as_seq h b1 == ls))
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.pfelem_cr
val pfelem_cr:cr pfelem
val pfelem_cr:cr pfelem
let pfelem_cr : cr pfelem = CR pfelem_add_cm pfelem_mul_cm ( ~% ) add_opp mul_add_distr mul_zero_l
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 72, "end_line": 120, "start_col": 0, "start_line": 119 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime val add_identity: a:pfelem -> Lemma (zero +% a == a) let add_identity a = normalize_term_spec prime val mul_identity: a:pfelem -> Lemma (one *% a == a) let mul_identity a = normalize_term_spec prime val add_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a +% b +% c == a +% (b +% c)) let add_associativity a b c = normalize_term_spec prime; calc (==) { a +% b +% c; == { } ((a + b) % prime + c) % prime; == { Math.Lemmas.lemma_mod_plus_distr_l (a + b) c prime } ((a + b) + c) % prime; == { } (a + (b + c)) % prime; == { Math.Lemmas.lemma_mod_plus_distr_r a (b + c) prime } a +% (b +% c); } val add_commutativity: a:pfelem -> b:pfelem -> Lemma (a +% b == b +% a) let add_commutativity a b = () val mul_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a *% b *% c == a *% (b *% c)) let mul_associativity a b c = calc (==) { a *% b *% c; == { } (((a * b) % prime) * c) % prime; == { Math.Lemmas.lemma_mod_mul_distr_l (a * b) c prime } ((a * b) * c) % prime; == { Math.Lemmas.paren_mul_right a b c } (a * (b * c)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b * c) prime } (a * ((b * c) % prime)) % prime; == { } a *% (b *% c); } val mul_commutativity: a:pfelem -> b:pfelem -> Lemma (a *% b == b *% a) let mul_commutativity a b = () [@canon_attr] let pfelem_add_cm : cm pfelem = CM zero ( +% ) add_identity add_associativity add_commutativity [@canon_attr] let pfelem_mul_cm : cm pfelem = CM one ( *% ) mul_identity mul_associativity mul_commutativity val mul_add_distr: distribute_left_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_add_distr a b c = normalize_term_spec prime; calc (==) { a *% (b +% c); == { } (a * (b +% c)) % prime; == { Math.Lemmas.lemma_mod_add_distr a (b + c) prime } (a * ((b + c) % prime)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b + c) prime } (a * (b + c)) % prime; == { Math.Lemmas.distributivity_add_right a b c } (a * b + a * c) % prime; == { Math.Lemmas.lemma_mod_add_distr (a * b) (a * c) prime } (a * b + a *% c) % prime; == { } (a *% c + a * b) % prime; == { Math.Lemmas.lemma_mod_add_distr (a *% c) (a * b) prime } (a *% c + a *% b) % prime; == { } (a *% b + a *% c) % prime; == { } a *% b +% a *% c; } val mul_zero_l: mult_zero_l_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_zero_l a = assert_norm (forall x. zero *% x == zero) val add_opp (a:pfelem) : Lemma (a +% ~%a == zero) let add_opp a = FStar.Math.Lemmas.lemma_mod_add_distr a (-a) prime; FStar.Math.Lemmas.small_mod 0 prime
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Tactics.CanonCommSemiring.cr Hacl.Spec.Poly1305.Lemmas.pfelem
Prims.Tot
[ "total" ]
[]
[ "FStar.Tactics.CanonCommSemiring.CR", "Hacl.Spec.Poly1305.Lemmas.pfelem", "Hacl.Spec.Poly1305.Lemmas.pfelem_add_cm", "Hacl.Spec.Poly1305.Lemmas.pfelem_mul_cm", "Hacl.Spec.Poly1305.Lemmas.op_Tilde_Percent", "Hacl.Spec.Poly1305.Lemmas.add_opp", "Hacl.Spec.Poly1305.Lemmas.mul_add_distr", "Hacl.Spec.Poly1305.Lemmas.mul_zero_l" ]
[]
false
false
false
true
false
let pfelem_cr:cr pfelem =
CR pfelem_add_cm pfelem_mul_cm ( ~% ) add_opp mul_add_distr mul_zero_l
false
ImmutableBuffer.fst
ImmutableBuffer.test_pf
val test_pf: Prims.unit -> HST.St unit
val test_pf: Prims.unit -> HST.St unit
let test_pf () : HST.St unit = let open LowStar.PrefixFreezableBuffer in let b = gcmalloc HS.root 5ul in upd b 4ul 1uy; upd b 5ul 2uy; upd b 6ul 3uy; upd b 7ul 4uy; upd b 8ul 5uy; freeze b 5ul; upd b 5ul 2uy; upd b 6ul 3uy; upd b 7ul 4uy; upd b 8ul 5uy; let snap = Ghost.hide (Seq.create 1 1uy) in witness_slice b 4ul 5ul snap; havoc_pf b; recall_slice b 4ul 5ul snap; let h = HST.get () in assert (Seq.equal (Seq.slice (as_seq h b) 4 5) (Ghost.reveal snap)); ()
{ "file_name": "examples/low-mitls-experiments/ImmutableBuffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 4, "end_line": 162, "start_col": 0, "start_line": 135 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module ImmutableBuffer module B = LowStar.Buffer module HS = FStar.HyperStack module HST = FStar.HyperStack.ST module Seq = FStar.Seq module U32 = FStar.UInt32 module IB = LowStar.ImmutableBuffer (* * Testing normalization of lists in the buffer library *) [@@"opaque_to_smt"] let l :list int = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10] let test2 (lll:list int{List.Tot.length lll > 0 /\ List.Tot.length lll <= UInt.max_int 32}) :HST.ST unit (fun h0 -> HS.is_stack_region (HS.get_tip h0)) (fun _ _ _ -> True)= let b = B.gcmalloc_of_list HS.root l in assert (B.length b == 10); let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list l); assert (B.length b == List.Tot.length l); let ll = [1;2;3;4;5;6;7;8;9;10;11] in HST.push_frame (); let b = B.alloca_of_list ll in assert (B.length b == 11); let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list ll); assert (B.length b == List.Tot.length ll); let b = B.alloca_of_list lll in let h = HST.get () in assert (B.as_seq h b == Seq.seq_of_list lll); assert (B.length b == List.Tot.length lll); HST.pop_frame () assume val havoc (#a:Type0) (#rrel #rel:B.srel a) (b:B.mbuffer a rrel rel) :HST.St unit let test (l:list int{List.Tot.length l == 10}) :HST.St unit = let ls = Seq.seq_of_list l in let b = IB.igcmalloc_of_list HS.root l in assert (B.length b == 10); havoc b; IB.recall_contents b ls; let h = HST.get () in assert (B.as_seq h b == ls); assert (B.live h b); let sb = IB.isub b 0ul 2ul in IB.witness_contents sb (Seq.slice ls 0 2); havoc sb; IB.recall_contents sb (Seq.slice ls 0 2); IB.recall_contents b ls; let h = HST.get () in assert (B.as_seq h b == ls); assert (B.as_seq h sb = Seq.slice ls 0 2); //test partial API let b1 = IB.igcmalloc_of_list_partial HS.root l in if B.is_null b1 then () else begin assert (B.length b1 == 10); IB.recall_contents b1 ls; let h = HST.get () in assert (B.as_seq h b1 == ls) end (***** Tests for uninitialized buffers *****) module UB = LowStar.UninitializedBuffer [@@expect_failure] let test_index_ub (b:UB.ubuffer int) :HST.ST unit (requires (fun h0 -> UB.live h0 b /\ UB.length b == 10)) (ensures (fun _ _ _ -> True)) = ignore (UB.uindex b 0) let test_ub () :HST.St unit = let b = UB.ugcmalloc #int HS.root 10ul in //allocate an uninitialized buffer, no initializer UB.uupd b 1ul 2; //update at index 1 with value 2 let j = UB.uindex b 1ul in //can now project index 1 assert (j == 2); //and check that the value is indeed 2 //let j = UB.uindex b 4ul in --> this fails since the index 4ul is not initialized let b1 = B.gcmalloc HS.root 0 10ul in //allocate a different regular buffer let h0 = HST.get () in UB.ublit b1 2ul b 2ul 3ul; //copy [2, 5) from regular buffer to [2, 5) of uninitialized buffer let h1 = HST.get () in let j = UB.uindex b 4ul in //now 4ul is indexable assert (j == 0); //and we can check its value is 0 (from the source buffer) let j = UB.uindex b 1ul in //1ul remains initialized and has the same value as before assert (Seq.index (UB.as_seq h0 b) 1 == Seq.index (Seq.slice (UB.as_seq h0 b) 0 2) 1); assert (j == 2) (***** Tests for bigops in the buffer library *****) #push-options "--max_fuel 0 --max_ifuel 0" let test_bigops (b1:UB.ubuffer int) (b2:IB.ibuffer int) (b3:B.buffer int) (h h0 h1:HS.mem) : unit = let open LowStar.Buffer in let l1, l2, l3 = loc_buffer b1, loc_buffer b2, loc_buffer b3 in assume (live h b1 /\ live h b2 /\ live h b3); assume (loc_disjoint l1 l2 /\ loc_disjoint l2 l3 /\ loc_disjoint l3 l1); assume (modifies (loc_union l1 (loc_union l2 l3)) h0 h1); assert (all_disjoint [l1; l2; l3]); assert (all_live h [buf b1; buf b2; buf b3]); assert (modifies (loc_union_l [l1; l2; l3]) h0 h1) #pop-options (***** Tests for freezable buffers *****) module PF = LowStar.PrefixFreezableBuffer #push-options "--max_fuel 0 --max_ifuel 0" assume val havoc_pf (b:PF.buffer) : HST.ST unit (requires (fun _ -> True)) (ensures (fun h0 _ h1 -> PF.frozen_until (PF.as_seq h0 b) == PF.frozen_until (PF.as_seq h1 b)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.UninitializedBuffer.fst.checked", "LowStar.PrefixFreezableBuffer.fsti.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.ImmutableBuffer.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "ImmutableBuffer.fst" }
[ { "abbrev": true, "full_module": "LowStar.PrefixFreezableBuffer", "short_module": "PF" }, { "abbrev": true, "full_module": "LowStar.UninitializedBuffer", "short_module": "UB" }, { "abbrev": true, "full_module": "LowStar.ImmutableBuffer", "short_module": "IB" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.HyperStack.ST.St Prims.unit
FStar.HyperStack.ST.St
[]
[]
[ "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "LowStar.PrefixFreezableBuffer.u8", "FStar.Seq.Base.slice", "LowStar.Monotonic.Buffer.as_seq", "LowStar.PrefixFreezableBuffer.prefix_freezable_preorder", "FStar.Ghost.reveal", "FStar.Seq.Base.seq", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.PrefixFreezableBuffer.recall_slice", "FStar.UInt32.__uint_to_t", "ImmutableBuffer.havoc_pf", "LowStar.PrefixFreezableBuffer.witness_slice", "FStar.Ghost.erased", "FStar.Ghost.hide", "FStar.Seq.Base.create", "FStar.UInt8.__uint_to_t", "LowStar.PrefixFreezableBuffer.upd", "LowStar.PrefixFreezableBuffer.freeze", "LowStar.PrefixFreezableBuffer.buffer", "Prims.eq2", "Prims.int", "LowStar.Monotonic.Buffer.length", "Prims.op_Addition", "FStar.UInt32.v", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Prims.l_and", "FStar.Monotonic.HyperHeap.rid", "LowStar.Monotonic.Buffer.frameOf", "FStar.Monotonic.HyperHeap.root", "LowStar.Monotonic.Buffer.recallable", "LowStar.PrefixFreezableBuffer.gcmalloc", "LowStar.PrefixFreezableBuffer.lbuffer" ]
[]
false
true
false
false
false
let test_pf () : HST.St unit =
let open LowStar.PrefixFreezableBuffer in let b = gcmalloc HS.root 5ul in upd b 4ul 1uy; upd b 5ul 2uy; upd b 6ul 3uy; upd b 7ul 4uy; upd b 8ul 5uy; freeze b 5ul; upd b 5ul 2uy; upd b 6ul 3uy; upd b 7ul 4uy; upd b 8ul 5uy; let snap = Ghost.hide (Seq.create 1 1uy) in witness_slice b 4ul 5ul snap; havoc_pf b; recall_slice b 4ul 5ul snap; let h = HST.get () in assert (Seq.equal (Seq.slice (as_seq h b) 4 5) (Ghost.reveal snap)); ()
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.mul_zero_l
val mul_zero_l: mult_zero_l_lemma pfelem pfelem_add_cm pfelem_mul_cm
val mul_zero_l: mult_zero_l_lemma pfelem pfelem_add_cm pfelem_mul_cm
let mul_zero_l a = assert_norm (forall x. zero *% x == zero)
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 60, "end_line": 111, "start_col": 0, "start_line": 111 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime val add_identity: a:pfelem -> Lemma (zero +% a == a) let add_identity a = normalize_term_spec prime val mul_identity: a:pfelem -> Lemma (one *% a == a) let mul_identity a = normalize_term_spec prime val add_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a +% b +% c == a +% (b +% c)) let add_associativity a b c = normalize_term_spec prime; calc (==) { a +% b +% c; == { } ((a + b) % prime + c) % prime; == { Math.Lemmas.lemma_mod_plus_distr_l (a + b) c prime } ((a + b) + c) % prime; == { } (a + (b + c)) % prime; == { Math.Lemmas.lemma_mod_plus_distr_r a (b + c) prime } a +% (b +% c); } val add_commutativity: a:pfelem -> b:pfelem -> Lemma (a +% b == b +% a) let add_commutativity a b = () val mul_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a *% b *% c == a *% (b *% c)) let mul_associativity a b c = calc (==) { a *% b *% c; == { } (((a * b) % prime) * c) % prime; == { Math.Lemmas.lemma_mod_mul_distr_l (a * b) c prime } ((a * b) * c) % prime; == { Math.Lemmas.paren_mul_right a b c } (a * (b * c)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b * c) prime } (a * ((b * c) % prime)) % prime; == { } a *% (b *% c); } val mul_commutativity: a:pfelem -> b:pfelem -> Lemma (a *% b == b *% a) let mul_commutativity a b = () [@canon_attr] let pfelem_add_cm : cm pfelem = CM zero ( +% ) add_identity add_associativity add_commutativity [@canon_attr] let pfelem_mul_cm : cm pfelem = CM one ( *% ) mul_identity mul_associativity mul_commutativity val mul_add_distr: distribute_left_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_add_distr a b c = normalize_term_spec prime; calc (==) { a *% (b +% c); == { } (a * (b +% c)) % prime; == { Math.Lemmas.lemma_mod_add_distr a (b + c) prime } (a * ((b + c) % prime)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b + c) prime } (a * (b + c)) % prime; == { Math.Lemmas.distributivity_add_right a b c } (a * b + a * c) % prime; == { Math.Lemmas.lemma_mod_add_distr (a * b) (a * c) prime } (a * b + a *% c) % prime; == { } (a *% c + a * b) % prime; == { Math.Lemmas.lemma_mod_add_distr (a *% c) (a * b) prime } (a *% c + a *% b) % prime; == { } (a *% b + a *% c) % prime; == { } a *% b +% a *% c; }
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Tactics.CanonCommSemiring.mult_zero_l_lemma Hacl.Spec.Poly1305.Lemmas.pfelem Hacl.Spec.Poly1305.Lemmas.pfelem_add_cm Hacl.Spec.Poly1305.Lemmas.pfelem_mul_cm
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.Poly1305.Lemmas.pfelem", "FStar.Pervasives.assert_norm", "Prims.l_Forall", "Prims.eq2", "Hacl.Spec.Poly1305.Lemmas.op_Star_Percent", "Hacl.Spec.Poly1305.Lemmas.zero", "Prims.unit" ]
[]
false
false
false
true
false
let mul_zero_l a =
assert_norm (forall x. zero *% x == zero)
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.add_associativity
val add_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a +% b +% c == a +% (b +% c))
val add_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a +% b +% c == a +% (b +% c))
let add_associativity a b c = normalize_term_spec prime; calc (==) { a +% b +% c; == { } ((a + b) % prime + c) % prime; == { Math.Lemmas.lemma_mod_plus_distr_l (a + b) c prime } ((a + b) + c) % prime; == { } (a + (b + c)) % prime; == { Math.Lemmas.lemma_mod_plus_distr_r a (b + c) prime } a +% (b +% c); }
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 52, "start_col": 0, "start_line": 40 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime val add_identity: a:pfelem -> Lemma (zero +% a == a) let add_identity a = normalize_term_spec prime val mul_identity: a:pfelem -> Lemma (one *% a == a) let mul_identity a = normalize_term_spec prime val add_associativity: a:pfelem -> b:pfelem -> c:pfelem
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.Spec.Poly1305.Lemmas.pfelem -> b: Hacl.Spec.Poly1305.Lemmas.pfelem -> c: Hacl.Spec.Poly1305.Lemmas.pfelem -> FStar.Pervasives.Lemma (ensures a +% b +% c == a +% (b +% c))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Hacl.Spec.Poly1305.Lemmas.pfelem", "FStar.Calc.calc_finish", "Prims.eq2", "Hacl.Spec.Poly1305.Lemmas.op_Plus_Percent", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Prims.op_Modulus", "Prims.op_Addition", "Hacl.Spec.Poly1305.Lemmas.prime", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "FStar.Math.Lemmas.lemma_mod_plus_distr_l", "FStar.Math.Lemmas.lemma_mod_plus_distr_r", "FStar.Pervasives.normalize_term_spec", "Prims.pos" ]
[]
false
false
true
false
false
let add_associativity a b c =
normalize_term_spec prime; calc ( == ) { a +% b +% c; ( == ) { () } ((a + b) % prime + c) % prime; ( == ) { Math.Lemmas.lemma_mod_plus_distr_l (a + b) c prime } ((a + b) + c) % prime; ( == ) { () } (a + (b + c)) % prime; ( == ) { Math.Lemmas.lemma_mod_plus_distr_r a (b + c) prime } a +% (b +% c); }
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.poly_update_multi_lemma_load2_simplify
val poly_update_multi_lemma_load2_simplify: acc0:pfelem -> r:pfelem -> c0:pfelem -> c1:pfelem -> Lemma ( (((acc0 +% c0) *% r) +% c1) *% r == ((acc0 +% c0) *% (r *% r)) +% c1 *% r )
val poly_update_multi_lemma_load2_simplify: acc0:pfelem -> r:pfelem -> c0:pfelem -> c1:pfelem -> Lemma ( (((acc0 +% c0) *% r) +% c1) *% r == ((acc0 +% c0) *% (r *% r)) +% c1 *% r )
let poly_update_multi_lemma_load2_simplify acc0 r c0 c1 = assert ( (((acc0 +% c0) *% r) +% c1) *% r == ((acc0 +% c0) *% (r *% r)) +% c1 *% r ) by (poly_semiring ())
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 178, "start_col": 0, "start_line": 174 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime val add_identity: a:pfelem -> Lemma (zero +% a == a) let add_identity a = normalize_term_spec prime val mul_identity: a:pfelem -> Lemma (one *% a == a) let mul_identity a = normalize_term_spec prime val add_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a +% b +% c == a +% (b +% c)) let add_associativity a b c = normalize_term_spec prime; calc (==) { a +% b +% c; == { } ((a + b) % prime + c) % prime; == { Math.Lemmas.lemma_mod_plus_distr_l (a + b) c prime } ((a + b) + c) % prime; == { } (a + (b + c)) % prime; == { Math.Lemmas.lemma_mod_plus_distr_r a (b + c) prime } a +% (b +% c); } val add_commutativity: a:pfelem -> b:pfelem -> Lemma (a +% b == b +% a) let add_commutativity a b = () val mul_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a *% b *% c == a *% (b *% c)) let mul_associativity a b c = calc (==) { a *% b *% c; == { } (((a * b) % prime) * c) % prime; == { Math.Lemmas.lemma_mod_mul_distr_l (a * b) c prime } ((a * b) * c) % prime; == { Math.Lemmas.paren_mul_right a b c } (a * (b * c)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b * c) prime } (a * ((b * c) % prime)) % prime; == { } a *% (b *% c); } val mul_commutativity: a:pfelem -> b:pfelem -> Lemma (a *% b == b *% a) let mul_commutativity a b = () [@canon_attr] let pfelem_add_cm : cm pfelem = CM zero ( +% ) add_identity add_associativity add_commutativity [@canon_attr] let pfelem_mul_cm : cm pfelem = CM one ( *% ) mul_identity mul_associativity mul_commutativity val mul_add_distr: distribute_left_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_add_distr a b c = normalize_term_spec prime; calc (==) { a *% (b +% c); == { } (a * (b +% c)) % prime; == { Math.Lemmas.lemma_mod_add_distr a (b + c) prime } (a * ((b + c) % prime)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b + c) prime } (a * (b + c)) % prime; == { Math.Lemmas.distributivity_add_right a b c } (a * b + a * c) % prime; == { Math.Lemmas.lemma_mod_add_distr (a * b) (a * c) prime } (a * b + a *% c) % prime; == { } (a *% c + a * b) % prime; == { Math.Lemmas.lemma_mod_add_distr (a *% c) (a * b) prime } (a *% c + a *% b) % prime; == { } (a *% b + a *% c) % prime; == { } a *% b +% a *% c; } val mul_zero_l: mult_zero_l_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_zero_l a = assert_norm (forall x. zero *% x == zero) val add_opp (a:pfelem) : Lemma (a +% ~%a == zero) let add_opp a = FStar.Math.Lemmas.lemma_mod_add_distr a (-a) prime; FStar.Math.Lemmas.small_mod 0 prime [@canon_attr] let pfelem_cr : cr pfelem = CR pfelem_add_cm pfelem_mul_cm ( ~% ) add_opp mul_add_distr mul_zero_l open FStar.Tactics let poly_semiring () : Tac unit = canon_semiring pfelem_cr; trefl() /// Lemmas val poly_update_repeat_blocks_multi_lemma2_simplify: acc0:pfelem -> acc1:pfelem -> c0:pfelem -> c1:pfelem -> r:pfelem -> Lemma ( (acc0 *% (r *% r) +% c0) *% (r *% r) +% (acc1 *% (r *% r) +% c1) *% r == ((((acc0 *% (r *% r) +% acc1 *% r) +% c0) *% r) +% c1) *% r ) let poly_update_repeat_blocks_multi_lemma2_simplify acc0 acc1 c0 c1 r = assert ( (acc0 *% (r *% r) +% c0) *% (r *% r) +% (acc1 *% (r *% r) +% c1) *% r == ((((acc0 *% (r *% r) +% acc1 *% r) +% c0) *% r) +% c1) *% r ) by (poly_semiring ()) val poly_update_repeat_blocks_multi_lemma4_simplify: a0:pfelem -> a1:pfelem -> a2:pfelem -> a3:pfelem -> c0:pfelem -> c1:pfelem -> c2:pfelem -> c3:pfelem -> r:pfelem -> r2:pfelem{r2 == r *% r} -> r4:pfelem {r4 == r2 *% r2} -> Lemma (((a0 *% r4 +% c0) *% r4) +% ((a1 *% r4 +% c1) *% (r2 *% r)) +% ((a2 *% r4 +% c2) *% r2) +% ((a3 *% r4 +% c3) *% r) == (((((((((((a0 *% r4 +% (a1 *% (r2 *% r))) +% a2 *% r2) +% a3 *% r) +% c0) *% r) +% c1) *% r) +% c2) *% r) +% c3) *% r) ) let poly_update_repeat_blocks_multi_lemma4_simplify a0 a1 a2 a3 c0 c1 c2 c3 r r2 r4 = let r2 = r *% r in let r4 = r2 *% r2 in assert ( ((a0 *% r4 +% c0) *% r4) +% ((a1 *% r4 +% c1) *% (r2 *% r)) +% ((a2 *% r4 +% c2) *% r2) +% ((a3 *% r4 +% c3) *% r) == (((((((((((a0 *% r4 +% (a1 *% (r2 *% r))) +% a2 *% r2) +% a3 *% r) +% c0) *% r) +% c1) *% r) +% c2) *% r) +% c3) *% r) ) by (poly_semiring ()) val poly_update_multi_lemma_load2_simplify: acc0:pfelem -> r:pfelem -> c0:pfelem -> c1:pfelem -> Lemma ( (((acc0 +% c0) *% r) +% c1) *% r ==
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
acc0: Hacl.Spec.Poly1305.Lemmas.pfelem -> r: Hacl.Spec.Poly1305.Lemmas.pfelem -> c0: Hacl.Spec.Poly1305.Lemmas.pfelem -> c1: Hacl.Spec.Poly1305.Lemmas.pfelem -> FStar.Pervasives.Lemma (ensures ((acc0 +% c0) *% r +% c1) *% r == (acc0 +% c0) *% (r *% r) +% c1 *% r)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Hacl.Spec.Poly1305.Lemmas.pfelem", "FStar.Tactics.Effect.assert_by_tactic", "Prims.eq2", "Hacl.Spec.Poly1305.Lemmas.op_Star_Percent", "Hacl.Spec.Poly1305.Lemmas.op_Plus_Percent", "Prims.unit", "Hacl.Spec.Poly1305.Lemmas.poly_semiring" ]
[]
false
false
true
false
false
let poly_update_multi_lemma_load2_simplify acc0 r c0 c1 =
FStar.Tactics.Effect.assert_by_tactic ((((acc0 +% c0) *% r) +% c1) *% r == ((acc0 +% c0) *% (r *% r)) +% c1 *% r) (fun _ -> (); (poly_semiring ()))
false
Vale.AES.AES_helpers.fst
Vale.AES.AES_helpers.commute_sub_bytes_shift_rows_forall
val commute_sub_bytes_shift_rows_forall (_:unit) : Lemma (forall q.{:pattern sub_bytes (shift_rows_LE q) \/ shift_rows_LE (sub_bytes q)} sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
val commute_sub_bytes_shift_rows_forall (_:unit) : Lemma (forall q.{:pattern sub_bytes (shift_rows_LE q) \/ shift_rows_LE (sub_bytes q)} sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
let commute_sub_bytes_shift_rows_forall () = FStar.Classical.forall_intro commute_sub_bytes_shift_rows
{ "file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 59, "end_line": 57, "start_col": 0, "start_line": 56 }
module Vale.AES.AES_helpers open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open FStar.Mul #reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 0" let lemma_expand_key_128_0 (key:aes_key_LE AES_128) = expand_key_reveal () #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 10" let lemma_expand_key_128_i (key:aes_key_LE AES_128) (i:nat) = expand_key_reveal (); let n = 4 * i in // unfold expand_key 4 times (could use fuel, but that unfolds everything): let _ = expand_key AES_128 key (n + 1) in let _ = expand_key AES_128 key (n + 2) in let _ = expand_key AES_128 key (n + 3) in () #reset-options // expand_key for large 'size' argument agrees with expand_key for smaller 'size' argument let rec lemma_expand_append (key:aes_key_LE AES_128) (size1:nat) (size2:nat) = expand_key_reveal (); if size1 < size2 then lemma_expand_append key size1 (size2 - 1) #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 40 --using_facts_from '* -FStar.Seq.Properties'" #restart-solver // quad32 key expansion is equivalent to nat32 key expansion let rec lemma_expand_key_128 (key:seq nat32) (size:nat) = expand_key_128_reveal (); lemma_expand_append key (4 * size) 44; if size = 0 then () else ( let i = size - 1 in lemma_expand_append key (4 * i) 44; lemma_expand_key_128 key i; if i = 0 then lemma_expand_key_128_0 key else lemma_expand_key_128_i key i ) #reset-options // SIMD version of round_key_128 is equivalent to scalar round_key_128 #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_simd_round_key (prev:quad32) (rcon:nat32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); commute_rot_word_sub_word prev.hi3; Vale.Arch.Types.xor_lemmas () #pop-options
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "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.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.AES_helpers.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_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 forall (q: Vale.Def.Types_s.quad32). {:pattern Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE q)\/Vale.AES.AES_s.shift_rows_LE (Vale.AES.AES_common_s.sub_bytes q)} Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE q) == Vale.AES.AES_s.shift_rows_LE (Vale.AES.AES_common_s.sub_bytes q))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.unit", "FStar.Classical.forall_intro", "Vale.Def.Types_s.quad32", "Prims.eq2", "Vale.AES.AES_common_s.sub_bytes", "Vale.AES.AES_s.shift_rows_LE", "Vale.AES.AES_s.commute_sub_bytes_shift_rows" ]
[]
false
false
true
false
false
let commute_sub_bytes_shift_rows_forall () =
FStar.Classical.forall_intro commute_sub_bytes_shift_rows
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.mul_associativity
val mul_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a *% b *% c == a *% (b *% c))
val mul_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a *% b *% c == a *% (b *% c))
let mul_associativity a b c = calc (==) { a *% b *% c; == { } (((a * b) % prime) * c) % prime; == { Math.Lemmas.lemma_mod_mul_distr_l (a * b) c prime } ((a * b) * c) % prime; == { Math.Lemmas.paren_mul_right a b c } (a * (b * c)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b * c) prime } (a * ((b * c) % prime)) % prime; == { } a *% (b *% c); }
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 72, "start_col": 0, "start_line": 59 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime val add_identity: a:pfelem -> Lemma (zero +% a == a) let add_identity a = normalize_term_spec prime val mul_identity: a:pfelem -> Lemma (one *% a == a) let mul_identity a = normalize_term_spec prime val add_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a +% b +% c == a +% (b +% c)) let add_associativity a b c = normalize_term_spec prime; calc (==) { a +% b +% c; == { } ((a + b) % prime + c) % prime; == { Math.Lemmas.lemma_mod_plus_distr_l (a + b) c prime } ((a + b) + c) % prime; == { } (a + (b + c)) % prime; == { Math.Lemmas.lemma_mod_plus_distr_r a (b + c) prime } a +% (b +% c); } val add_commutativity: a:pfelem -> b:pfelem -> Lemma (a +% b == b +% a) let add_commutativity a b = () val mul_associativity: a:pfelem -> b:pfelem -> c:pfelem
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Hacl.Spec.Poly1305.Lemmas.pfelem -> b: Hacl.Spec.Poly1305.Lemmas.pfelem -> c: Hacl.Spec.Poly1305.Lemmas.pfelem -> FStar.Pervasives.Lemma (ensures a *% b *% c == a *% (b *% c))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Hacl.Spec.Poly1305.Lemmas.pfelem", "FStar.Calc.calc_finish", "Prims.eq2", "Hacl.Spec.Poly1305.Lemmas.op_Star_Percent", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Prims.op_Modulus", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Lemmas.prime", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "FStar.Math.Lemmas.lemma_mod_mul_distr_l", "FStar.Math.Lemmas.paren_mul_right", "FStar.Math.Lemmas.lemma_mod_mul_distr_r" ]
[]
false
false
true
false
false
let mul_associativity a b c =
calc ( == ) { a *% b *% c; ( == ) { () } (((a * b) % prime) * c) % prime; ( == ) { Math.Lemmas.lemma_mod_mul_distr_l (a * b) c prime } ((a * b) * c) % prime; ( == ) { Math.Lemmas.paren_mul_right a b c } (a * (b * c)) % prime; ( == ) { Math.Lemmas.lemma_mod_mul_distr_r a (b * c) prime } (a * ((b * c) % prime)) % prime; ( == ) { () } a *% (b *% c); }
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.poly_update_multi_lemma_load4_simplify
val poly_update_multi_lemma_load4_simplify: acc0:pfelem -> r:pfelem -> c0:pfelem -> c1:pfelem -> c2:pfelem -> c3:pfelem -> Lemma ( (((((((acc0 +% c0) *% r) +% c1) *% r) +% c2) *% r) +% c3) *% r == ((((acc0 +% c0) *% ((r *% r) *% (r *% r))) +% (c1 *% ((r *% r) *% r))) +% (c2 *% (r *% r))) +% c3 *% r )
val poly_update_multi_lemma_load4_simplify: acc0:pfelem -> r:pfelem -> c0:pfelem -> c1:pfelem -> c2:pfelem -> c3:pfelem -> Lemma ( (((((((acc0 +% c0) *% r) +% c1) *% r) +% c2) *% r) +% c3) *% r == ((((acc0 +% c0) *% ((r *% r) *% (r *% r))) +% (c1 *% ((r *% r) *% r))) +% (c2 *% (r *% r))) +% c3 *% r )
let poly_update_multi_lemma_load4_simplify acc0 r c0 c1 c2 c3 = assert ( (((((((acc0 +% c0) *% r) +% c1) *% r) +% c2) *% r) +% c3) *% r == ((((acc0 +% c0) *% ((r *% r) *% (r *% r))) +% (c1 *% ((r *% r) *% r))) +% (c2 *% (r *% r))) +% c3 *% r ) by (poly_semiring ())
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 191, "start_col": 0, "start_line": 186 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime val add_identity: a:pfelem -> Lemma (zero +% a == a) let add_identity a = normalize_term_spec prime val mul_identity: a:pfelem -> Lemma (one *% a == a) let mul_identity a = normalize_term_spec prime val add_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a +% b +% c == a +% (b +% c)) let add_associativity a b c = normalize_term_spec prime; calc (==) { a +% b +% c; == { } ((a + b) % prime + c) % prime; == { Math.Lemmas.lemma_mod_plus_distr_l (a + b) c prime } ((a + b) + c) % prime; == { } (a + (b + c)) % prime; == { Math.Lemmas.lemma_mod_plus_distr_r a (b + c) prime } a +% (b +% c); } val add_commutativity: a:pfelem -> b:pfelem -> Lemma (a +% b == b +% a) let add_commutativity a b = () val mul_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a *% b *% c == a *% (b *% c)) let mul_associativity a b c = calc (==) { a *% b *% c; == { } (((a * b) % prime) * c) % prime; == { Math.Lemmas.lemma_mod_mul_distr_l (a * b) c prime } ((a * b) * c) % prime; == { Math.Lemmas.paren_mul_right a b c } (a * (b * c)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b * c) prime } (a * ((b * c) % prime)) % prime; == { } a *% (b *% c); } val mul_commutativity: a:pfelem -> b:pfelem -> Lemma (a *% b == b *% a) let mul_commutativity a b = () [@canon_attr] let pfelem_add_cm : cm pfelem = CM zero ( +% ) add_identity add_associativity add_commutativity [@canon_attr] let pfelem_mul_cm : cm pfelem = CM one ( *% ) mul_identity mul_associativity mul_commutativity val mul_add_distr: distribute_left_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_add_distr a b c = normalize_term_spec prime; calc (==) { a *% (b +% c); == { } (a * (b +% c)) % prime; == { Math.Lemmas.lemma_mod_add_distr a (b + c) prime } (a * ((b + c) % prime)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b + c) prime } (a * (b + c)) % prime; == { Math.Lemmas.distributivity_add_right a b c } (a * b + a * c) % prime; == { Math.Lemmas.lemma_mod_add_distr (a * b) (a * c) prime } (a * b + a *% c) % prime; == { } (a *% c + a * b) % prime; == { Math.Lemmas.lemma_mod_add_distr (a *% c) (a * b) prime } (a *% c + a *% b) % prime; == { } (a *% b + a *% c) % prime; == { } a *% b +% a *% c; } val mul_zero_l: mult_zero_l_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_zero_l a = assert_norm (forall x. zero *% x == zero) val add_opp (a:pfelem) : Lemma (a +% ~%a == zero) let add_opp a = FStar.Math.Lemmas.lemma_mod_add_distr a (-a) prime; FStar.Math.Lemmas.small_mod 0 prime [@canon_attr] let pfelem_cr : cr pfelem = CR pfelem_add_cm pfelem_mul_cm ( ~% ) add_opp mul_add_distr mul_zero_l open FStar.Tactics let poly_semiring () : Tac unit = canon_semiring pfelem_cr; trefl() /// Lemmas val poly_update_repeat_blocks_multi_lemma2_simplify: acc0:pfelem -> acc1:pfelem -> c0:pfelem -> c1:pfelem -> r:pfelem -> Lemma ( (acc0 *% (r *% r) +% c0) *% (r *% r) +% (acc1 *% (r *% r) +% c1) *% r == ((((acc0 *% (r *% r) +% acc1 *% r) +% c0) *% r) +% c1) *% r ) let poly_update_repeat_blocks_multi_lemma2_simplify acc0 acc1 c0 c1 r = assert ( (acc0 *% (r *% r) +% c0) *% (r *% r) +% (acc1 *% (r *% r) +% c1) *% r == ((((acc0 *% (r *% r) +% acc1 *% r) +% c0) *% r) +% c1) *% r ) by (poly_semiring ()) val poly_update_repeat_blocks_multi_lemma4_simplify: a0:pfelem -> a1:pfelem -> a2:pfelem -> a3:pfelem -> c0:pfelem -> c1:pfelem -> c2:pfelem -> c3:pfelem -> r:pfelem -> r2:pfelem{r2 == r *% r} -> r4:pfelem {r4 == r2 *% r2} -> Lemma (((a0 *% r4 +% c0) *% r4) +% ((a1 *% r4 +% c1) *% (r2 *% r)) +% ((a2 *% r4 +% c2) *% r2) +% ((a3 *% r4 +% c3) *% r) == (((((((((((a0 *% r4 +% (a1 *% (r2 *% r))) +% a2 *% r2) +% a3 *% r) +% c0) *% r) +% c1) *% r) +% c2) *% r) +% c3) *% r) ) let poly_update_repeat_blocks_multi_lemma4_simplify a0 a1 a2 a3 c0 c1 c2 c3 r r2 r4 = let r2 = r *% r in let r4 = r2 *% r2 in assert ( ((a0 *% r4 +% c0) *% r4) +% ((a1 *% r4 +% c1) *% (r2 *% r)) +% ((a2 *% r4 +% c2) *% r2) +% ((a3 *% r4 +% c3) *% r) == (((((((((((a0 *% r4 +% (a1 *% (r2 *% r))) +% a2 *% r2) +% a3 *% r) +% c0) *% r) +% c1) *% r) +% c2) *% r) +% c3) *% r) ) by (poly_semiring ()) val poly_update_multi_lemma_load2_simplify: acc0:pfelem -> r:pfelem -> c0:pfelem -> c1:pfelem -> Lemma ( (((acc0 +% c0) *% r) +% c1) *% r == ((acc0 +% c0) *% (r *% r)) +% c1 *% r ) let poly_update_multi_lemma_load2_simplify acc0 r c0 c1 = assert ( (((acc0 +% c0) *% r) +% c1) *% r == ((acc0 +% c0) *% (r *% r)) +% c1 *% r ) by (poly_semiring ()) val poly_update_multi_lemma_load4_simplify: acc0:pfelem -> r:pfelem -> c0:pfelem -> c1:pfelem -> c2:pfelem -> c3:pfelem -> Lemma ( (((((((acc0 +% c0) *% r) +% c1) *% r) +% c2) *% r) +% c3) *% r == ((((acc0 +% c0) *% ((r *% r) *% (r *% r))) +%
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
acc0: Hacl.Spec.Poly1305.Lemmas.pfelem -> r: Hacl.Spec.Poly1305.Lemmas.pfelem -> c0: Hacl.Spec.Poly1305.Lemmas.pfelem -> c1: Hacl.Spec.Poly1305.Lemmas.pfelem -> c2: Hacl.Spec.Poly1305.Lemmas.pfelem -> c3: Hacl.Spec.Poly1305.Lemmas.pfelem -> FStar.Pervasives.Lemma (ensures ((((acc0 +% c0) *% r +% c1) *% r +% c2) *% r +% c3) *% r == (acc0 +% c0) *% (r *% r *% (r *% r)) +% c1 *% (r *% r *% r) +% c2 *% (r *% r) +% c3 *% r)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Hacl.Spec.Poly1305.Lemmas.pfelem", "FStar.Tactics.Effect.assert_by_tactic", "Prims.eq2", "Hacl.Spec.Poly1305.Lemmas.op_Star_Percent", "Hacl.Spec.Poly1305.Lemmas.op_Plus_Percent", "Prims.unit", "Hacl.Spec.Poly1305.Lemmas.poly_semiring" ]
[]
false
false
true
false
false
let poly_update_multi_lemma_load4_simplify acc0 r c0 c1 c2 c3 =
FStar.Tactics.Effect.assert_by_tactic ((((((((acc0 +% c0) *% r) +% c1) *% r) +% c2) *% r) +% c3) *% r == ((((acc0 +% c0) *% ((r *% r) *% (r *% r))) +% (c1 *% ((r *% r) *% r))) +% (c2 *% (r *% r))) +% c3 *% r) (fun _ -> (); (poly_semiring ()))
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.poly_update_repeat_blocks_multi_lemma2_simplify
val poly_update_repeat_blocks_multi_lemma2_simplify: acc0:pfelem -> acc1:pfelem -> c0:pfelem -> c1:pfelem -> r:pfelem -> Lemma ( (acc0 *% (r *% r) +% c0) *% (r *% r) +% (acc1 *% (r *% r) +% c1) *% r == ((((acc0 *% (r *% r) +% acc1 *% r) +% c0) *% r) +% c1) *% r )
val poly_update_repeat_blocks_multi_lemma2_simplify: acc0:pfelem -> acc1:pfelem -> c0:pfelem -> c1:pfelem -> r:pfelem -> Lemma ( (acc0 *% (r *% r) +% c0) *% (r *% r) +% (acc1 *% (r *% r) +% c1) *% r == ((((acc0 *% (r *% r) +% acc1 *% r) +% c0) *% r) +% c1) *% r )
let poly_update_repeat_blocks_multi_lemma2_simplify acc0 acc1 c0 c1 r = assert ( (acc0 *% (r *% r) +% c0) *% (r *% r) +% (acc1 *% (r *% r) +% c1) *% r == ((((acc0 *% (r *% r) +% acc1 *% r) +% c0) *% r) +% c1) *% r ) by (poly_semiring ())
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 138, "start_col": 0, "start_line": 134 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime val add_identity: a:pfelem -> Lemma (zero +% a == a) let add_identity a = normalize_term_spec prime val mul_identity: a:pfelem -> Lemma (one *% a == a) let mul_identity a = normalize_term_spec prime val add_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a +% b +% c == a +% (b +% c)) let add_associativity a b c = normalize_term_spec prime; calc (==) { a +% b +% c; == { } ((a + b) % prime + c) % prime; == { Math.Lemmas.lemma_mod_plus_distr_l (a + b) c prime } ((a + b) + c) % prime; == { } (a + (b + c)) % prime; == { Math.Lemmas.lemma_mod_plus_distr_r a (b + c) prime } a +% (b +% c); } val add_commutativity: a:pfelem -> b:pfelem -> Lemma (a +% b == b +% a) let add_commutativity a b = () val mul_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a *% b *% c == a *% (b *% c)) let mul_associativity a b c = calc (==) { a *% b *% c; == { } (((a * b) % prime) * c) % prime; == { Math.Lemmas.lemma_mod_mul_distr_l (a * b) c prime } ((a * b) * c) % prime; == { Math.Lemmas.paren_mul_right a b c } (a * (b * c)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b * c) prime } (a * ((b * c) % prime)) % prime; == { } a *% (b *% c); } val mul_commutativity: a:pfelem -> b:pfelem -> Lemma (a *% b == b *% a) let mul_commutativity a b = () [@canon_attr] let pfelem_add_cm : cm pfelem = CM zero ( +% ) add_identity add_associativity add_commutativity [@canon_attr] let pfelem_mul_cm : cm pfelem = CM one ( *% ) mul_identity mul_associativity mul_commutativity val mul_add_distr: distribute_left_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_add_distr a b c = normalize_term_spec prime; calc (==) { a *% (b +% c); == { } (a * (b +% c)) % prime; == { Math.Lemmas.lemma_mod_add_distr a (b + c) prime } (a * ((b + c) % prime)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b + c) prime } (a * (b + c)) % prime; == { Math.Lemmas.distributivity_add_right a b c } (a * b + a * c) % prime; == { Math.Lemmas.lemma_mod_add_distr (a * b) (a * c) prime } (a * b + a *% c) % prime; == { } (a *% c + a * b) % prime; == { Math.Lemmas.lemma_mod_add_distr (a *% c) (a * b) prime } (a *% c + a *% b) % prime; == { } (a *% b + a *% c) % prime; == { } a *% b +% a *% c; } val mul_zero_l: mult_zero_l_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_zero_l a = assert_norm (forall x. zero *% x == zero) val add_opp (a:pfelem) : Lemma (a +% ~%a == zero) let add_opp a = FStar.Math.Lemmas.lemma_mod_add_distr a (-a) prime; FStar.Math.Lemmas.small_mod 0 prime [@canon_attr] let pfelem_cr : cr pfelem = CR pfelem_add_cm pfelem_mul_cm ( ~% ) add_opp mul_add_distr mul_zero_l open FStar.Tactics let poly_semiring () : Tac unit = canon_semiring pfelem_cr; trefl() /// Lemmas val poly_update_repeat_blocks_multi_lemma2_simplify: acc0:pfelem -> acc1:pfelem -> c0:pfelem -> c1:pfelem -> r:pfelem -> Lemma ( (acc0 *% (r *% r) +% c0) *% (r *% r) +% (acc1 *% (r *% r) +% c1) *% r ==
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
acc0: Hacl.Spec.Poly1305.Lemmas.pfelem -> acc1: Hacl.Spec.Poly1305.Lemmas.pfelem -> c0: Hacl.Spec.Poly1305.Lemmas.pfelem -> c1: Hacl.Spec.Poly1305.Lemmas.pfelem -> r: Hacl.Spec.Poly1305.Lemmas.pfelem -> FStar.Pervasives.Lemma (ensures (acc0 *% (r *% r) +% c0) *% (r *% r) +% (acc1 *% (r *% r) +% c1) *% r == ((acc0 *% (r *% r) +% acc1 *% r +% c0) *% r +% c1) *% r)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Hacl.Spec.Poly1305.Lemmas.pfelem", "FStar.Tactics.Effect.assert_by_tactic", "Prims.eq2", "Hacl.Spec.Poly1305.Lemmas.op_Plus_Percent", "Hacl.Spec.Poly1305.Lemmas.op_Star_Percent", "Prims.unit", "Hacl.Spec.Poly1305.Lemmas.poly_semiring" ]
[]
false
false
true
false
false
let poly_update_repeat_blocks_multi_lemma2_simplify acc0 acc1 c0 c1 r =
FStar.Tactics.Effect.assert_by_tactic ((acc0 *% (r *% r) +% c0) *% (r *% r) +% (acc1 *% (r *% r) +% c1) *% r == ((((acc0 *% (r *% r) +% acc1 *% r) +% c0) *% r) +% c1) *% r) (fun _ -> (); (poly_semiring ()))
false
Vale.AES.AES_helpers.fst
Vale.AES.AES_helpers.lemma_expand_key_128_0
val lemma_expand_key_128_0 (key:aes_key_LE AES_128) : Lemma (equal key (expand_key AES_128 key 4))
val lemma_expand_key_128_0 (key:aes_key_LE AES_128) : Lemma (equal key (expand_key AES_128 key 4))
let lemma_expand_key_128_0 (key:aes_key_LE AES_128) = expand_key_reveal ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 12, "start_col": 0, "start_line": 11 }
module Vale.AES.AES_helpers open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open FStar.Mul
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "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.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.AES_helpers.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_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": 4, "initial_ifuel": 0, "max_fuel": 4, "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": 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
key: Vale.AES.AES_s.aes_key_LE Vale.AES.AES_common_s.AES_128 -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.equal key (Vale.AES.AES_s.expand_key Vale.AES.AES_common_s.AES_128 key 4))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.AES_s.aes_key_LE", "Vale.AES.AES_common_s.AES_128", "Vale.AES.AES_s.expand_key_reveal", "Prims.unit" ]
[]
true
false
true
false
false
let lemma_expand_key_128_0 (key: aes_key_LE AES_128) =
expand_key_reveal ()
false
Vale.AES.AES_helpers.fst
Vale.AES.AES_helpers.lemma_simd_round_key
val lemma_simd_round_key (prev:quad32) (rcon:nat32) : Lemma (simd_round_key_128 prev rcon == round_key_128_rcon prev rcon)
val lemma_simd_round_key (prev:quad32) (rcon:nat32) : Lemma (simd_round_key_128 prev rcon == round_key_128_rcon prev rcon)
let lemma_simd_round_key (prev:quad32) (rcon:nat32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); commute_rot_word_sub_word prev.hi3; Vale.Arch.Types.xor_lemmas ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 53, "start_col": 0, "start_line": 49 }
module Vale.AES.AES_helpers open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open FStar.Mul #reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 0" let lemma_expand_key_128_0 (key:aes_key_LE AES_128) = expand_key_reveal () #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 10" let lemma_expand_key_128_i (key:aes_key_LE AES_128) (i:nat) = expand_key_reveal (); let n = 4 * i in // unfold expand_key 4 times (could use fuel, but that unfolds everything): let _ = expand_key AES_128 key (n + 1) in let _ = expand_key AES_128 key (n + 2) in let _ = expand_key AES_128 key (n + 3) in () #reset-options // expand_key for large 'size' argument agrees with expand_key for smaller 'size' argument let rec lemma_expand_append (key:aes_key_LE AES_128) (size1:nat) (size2:nat) = expand_key_reveal (); if size1 < size2 then lemma_expand_append key size1 (size2 - 1) #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 40 --using_facts_from '* -FStar.Seq.Properties'" #restart-solver // quad32 key expansion is equivalent to nat32 key expansion let rec lemma_expand_key_128 (key:seq nat32) (size:nat) = expand_key_128_reveal (); lemma_expand_append key (4 * size) 44; if size = 0 then () else ( let i = size - 1 in lemma_expand_append key (4 * i) 44; lemma_expand_key_128 key i; if i = 0 then lemma_expand_key_128_0 key else lemma_expand_key_128_i key i ) #reset-options // SIMD version of round_key_128 is equivalent to scalar round_key_128
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "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.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.AES_helpers.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_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": 3, "initial_ifuel": 3, "max_fuel": 3, "max_ifuel": 3, "no_plugins": false, "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
prev: Vale.Def.Types_s.quad32 -> rcon: Vale.Def.Types_s.nat32 -> FStar.Pervasives.Lemma (ensures Vale.AES.AES_helpers.simd_round_key_128 prev rcon == Vale.AES.AES_helpers.round_key_128_rcon prev rcon)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.nat32", "Vale.Arch.Types.xor_lemmas", "Prims.unit", "Vale.AES.AES_s.commute_rot_word_sub_word", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Types_s.reverse_bytes_nat32_reveal", "Vale.Def.Types_s.quad32_xor_reveal" ]
[]
true
false
true
false
false
let lemma_simd_round_key (prev: quad32) (rcon: nat32) =
quad32_xor_reveal (); reverse_bytes_nat32_reveal (); commute_rot_word_sub_word prev.hi3; Vale.Arch.Types.xor_lemmas ()
false
Vale.AES.AES_helpers.fst
Vale.AES.AES_helpers.finish_cipher
val finish_cipher (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Lemma (length round_keys == (nr alg) + 1 ==> length round_keys > 0 /\ nr alg > 1 /\ // REVIEW: Why are these needed? (let state = quad32_xor input (index round_keys 0) in let state = eval_rounds state round_keys (nr alg - 1) in let state = shift_rows_LE state in let state = sub_bytes state in let state = quad32_xor state (index round_keys (nr alg)) in state == eval_cipher alg input round_keys))
val finish_cipher (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Lemma (length round_keys == (nr alg) + 1 ==> length round_keys > 0 /\ nr alg > 1 /\ // REVIEW: Why are these needed? (let state = quad32_xor input (index round_keys 0) in let state = eval_rounds state round_keys (nr alg - 1) in let state = shift_rows_LE state in let state = sub_bytes state in let state = quad32_xor state (index round_keys (nr alg)) in state == eval_cipher alg input round_keys))
let finish_cipher (alg:algorithm) (input:quad32) (round_keys:seq quad32) = eval_rounds_reveal (); eval_cipher_reveal (); commute_sub_bytes_shift_rows_forall()
{ "file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 66, "start_col": 0, "start_line": 63 }
module Vale.AES.AES_helpers open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open FStar.Mul #reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 0" let lemma_expand_key_128_0 (key:aes_key_LE AES_128) = expand_key_reveal () #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 10" let lemma_expand_key_128_i (key:aes_key_LE AES_128) (i:nat) = expand_key_reveal (); let n = 4 * i in // unfold expand_key 4 times (could use fuel, but that unfolds everything): let _ = expand_key AES_128 key (n + 1) in let _ = expand_key AES_128 key (n + 2) in let _ = expand_key AES_128 key (n + 3) in () #reset-options // expand_key for large 'size' argument agrees with expand_key for smaller 'size' argument let rec lemma_expand_append (key:aes_key_LE AES_128) (size1:nat) (size2:nat) = expand_key_reveal (); if size1 < size2 then lemma_expand_append key size1 (size2 - 1) #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 40 --using_facts_from '* -FStar.Seq.Properties'" #restart-solver // quad32 key expansion is equivalent to nat32 key expansion let rec lemma_expand_key_128 (key:seq nat32) (size:nat) = expand_key_128_reveal (); lemma_expand_append key (4 * size) 44; if size = 0 then () else ( let i = size - 1 in lemma_expand_append key (4 * i) 44; lemma_expand_key_128 key i; if i = 0 then lemma_expand_key_128_0 key else lemma_expand_key_128_i key i ) #reset-options // SIMD version of round_key_128 is equivalent to scalar round_key_128 #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_simd_round_key (prev:quad32) (rcon:nat32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); commute_rot_word_sub_word prev.hi3; Vale.Arch.Types.xor_lemmas () #pop-options let commute_sub_bytes_shift_rows_forall () = FStar.Classical.forall_intro commute_sub_bytes_shift_rows let init_rounds_opaque (init:quad32) (round_keys:seq quad32) = eval_rounds_reveal ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "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.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.AES_helpers.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_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": 2, "max_fuel": 1, "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": 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 -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.length round_keys == Vale.AES.AES_common_s.nr alg + 1 ==> FStar.Seq.Base.length round_keys > 0 /\ Vale.AES.AES_common_s.nr alg > 1 /\ (let state = Vale.Def.Types_s.quad32_xor input (FStar.Seq.Base.index round_keys 0) in let state = Vale.AES.AES_s.eval_rounds state round_keys (Vale.AES.AES_common_s.nr alg - 1) in let state = Vale.AES.AES_s.shift_rows_LE state in let state = Vale.AES.AES_common_s.sub_bytes state in let state = Vale.Def.Types_s.quad32_xor state (FStar.Seq.Base.index round_keys (Vale.AES.AES_common_s.nr alg)) in state == Vale.AES.AES_s.eval_cipher alg input round_keys))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Vale.AES.AES_helpers.commute_sub_bytes_shift_rows_forall", "Prims.unit", "Vale.AES.AES_s.eval_cipher_reveal", "Vale.AES.AES_s.eval_rounds_reveal" ]
[]
true
false
true
false
false
let finish_cipher (alg: algorithm) (input: quad32) (round_keys: seq quad32) =
eval_rounds_reveal (); eval_cipher_reveal (); commute_sub_bytes_shift_rows_forall ()
false
Vale.AES.AES_helpers.fst
Vale.AES.AES_helpers.lemma_expand_append
val lemma_expand_append (key:aes_key_LE AES_128) (size1:nat) (size2:nat) : Lemma (requires size1 <= size2 /\ size2 <= 44) (ensures equal (expand_key AES_128 key size1) (slice (expand_key AES_128 key size2) 0 size1)) (decreases size2)
val lemma_expand_append (key:aes_key_LE AES_128) (size1:nat) (size2:nat) : Lemma (requires size1 <= size2 /\ size2 <= 44) (ensures equal (expand_key AES_128 key size1) (slice (expand_key AES_128 key size2) 0 size1)) (decreases size2)
let rec lemma_expand_append (key:aes_key_LE AES_128) (size1:nat) (size2:nat) = expand_key_reveal (); if size1 < size2 then lemma_expand_append key size1 (size2 - 1)
{ "file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 65, "end_line": 28, "start_col": 0, "start_line": 26 }
module Vale.AES.AES_helpers open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open FStar.Mul #reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 0" let lemma_expand_key_128_0 (key:aes_key_LE AES_128) = expand_key_reveal () #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 10" let lemma_expand_key_128_i (key:aes_key_LE AES_128) (i:nat) = expand_key_reveal (); let n = 4 * i in // unfold expand_key 4 times (could use fuel, but that unfolds everything): let _ = expand_key AES_128 key (n + 1) in let _ = expand_key AES_128 key (n + 2) in let _ = expand_key AES_128 key (n + 3) in () #reset-options
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "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.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.AES_helpers.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_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
key: Vale.AES.AES_s.aes_key_LE Vale.AES.AES_common_s.AES_128 -> size1: Prims.nat -> size2: Prims.nat -> FStar.Pervasives.Lemma (requires size1 <= size2 /\ size2 <= 44) (ensures FStar.Seq.Base.equal (Vale.AES.AES_s.expand_key Vale.AES.AES_common_s.AES_128 key size1) (FStar.Seq.Base.slice (Vale.AES.AES_s.expand_key Vale.AES.AES_common_s.AES_128 key size2) 0 size1)) (decreases size2)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Vale.AES.AES_s.aes_key_LE", "Vale.AES.AES_common_s.AES_128", "Prims.nat", "Prims.op_LessThan", "Vale.AES.AES_helpers.lemma_expand_append", "Prims.op_Subtraction", "Prims.bool", "Prims.unit", "Vale.AES.AES_s.expand_key_reveal" ]
[ "recursion" ]
false
false
true
false
false
let rec lemma_expand_append (key: aes_key_LE AES_128) (size1 size2: nat) =
expand_key_reveal (); if size1 < size2 then lemma_expand_append key size1 (size2 - 1)
false
Vale.AES.AES_helpers.fst
Vale.AES.AES_helpers.init_rounds_opaque
val init_rounds_opaque (init:quad32) (round_keys:seq quad32) : Lemma (length round_keys > 0 ==> eval_rounds init round_keys 0 == init)
val init_rounds_opaque (init:quad32) (round_keys:seq quad32) : Lemma (length round_keys > 0 ==> eval_rounds init round_keys 0 == init)
let init_rounds_opaque (init:quad32) (round_keys:seq quad32) = eval_rounds_reveal ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 60, "start_col": 0, "start_line": 59 }
module Vale.AES.AES_helpers open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open FStar.Mul #reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 0" let lemma_expand_key_128_0 (key:aes_key_LE AES_128) = expand_key_reveal () #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 10" let lemma_expand_key_128_i (key:aes_key_LE AES_128) (i:nat) = expand_key_reveal (); let n = 4 * i in // unfold expand_key 4 times (could use fuel, but that unfolds everything): let _ = expand_key AES_128 key (n + 1) in let _ = expand_key AES_128 key (n + 2) in let _ = expand_key AES_128 key (n + 3) in () #reset-options // expand_key for large 'size' argument agrees with expand_key for smaller 'size' argument let rec lemma_expand_append (key:aes_key_LE AES_128) (size1:nat) (size2:nat) = expand_key_reveal (); if size1 < size2 then lemma_expand_append key size1 (size2 - 1) #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 40 --using_facts_from '* -FStar.Seq.Properties'" #restart-solver // quad32 key expansion is equivalent to nat32 key expansion let rec lemma_expand_key_128 (key:seq nat32) (size:nat) = expand_key_128_reveal (); lemma_expand_append key (4 * size) 44; if size = 0 then () else ( let i = size - 1 in lemma_expand_append key (4 * i) 44; lemma_expand_key_128 key i; if i = 0 then lemma_expand_key_128_0 key else lemma_expand_key_128_i key i ) #reset-options // SIMD version of round_key_128 is equivalent to scalar round_key_128 #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_simd_round_key (prev:quad32) (rcon:nat32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); commute_rot_word_sub_word prev.hi3; Vale.Arch.Types.xor_lemmas () #pop-options let commute_sub_bytes_shift_rows_forall () = FStar.Classical.forall_intro commute_sub_bytes_shift_rows
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "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.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.AES_helpers.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_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 -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.length round_keys > 0 ==> Vale.AES.AES_s.eval_rounds init round_keys 0 == init)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Vale.AES.AES_s.eval_rounds_reveal", "Prims.unit" ]
[]
true
false
true
false
false
let init_rounds_opaque (init: quad32) (round_keys: seq quad32) =
eval_rounds_reveal ()
false
Vale.AES.AES_helpers.fst
Vale.AES.AES_helpers.lemma_expand_key_128_i
val lemma_expand_key_128_i (key:aes_key_LE AES_128) (i:nat) : Lemma (requires 0 < i /\ i < 11 ) (ensures ( let m = 4 * (i - 1) in let n = 4 * i in let v = expand_key AES_128 key n in let w = expand_key AES_128 key (n + 4) in let prev = Mkfour v.[m + 0] v.[m + 1] v.[m + 2] v.[m + 3] in round_key_128 prev i == Mkfour w.[n + 0] w.[n + 1] w.[n + 2] w.[n + 3] ))
val lemma_expand_key_128_i (key:aes_key_LE AES_128) (i:nat) : Lemma (requires 0 < i /\ i < 11 ) (ensures ( let m = 4 * (i - 1) in let n = 4 * i in let v = expand_key AES_128 key n in let w = expand_key AES_128 key (n + 4) in let prev = Mkfour v.[m + 0] v.[m + 1] v.[m + 2] v.[m + 3] in round_key_128 prev i == Mkfour w.[n + 0] w.[n + 1] w.[n + 2] w.[n + 3] ))
let lemma_expand_key_128_i (key:aes_key_LE AES_128) (i:nat) = expand_key_reveal (); let n = 4 * i in // unfold expand_key 4 times (could use fuel, but that unfolds everything): let _ = expand_key AES_128 key (n + 1) in let _ = expand_key AES_128 key (n + 2) in let _ = expand_key AES_128 key (n + 3) in ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 22, "start_col": 0, "start_line": 15 }
module Vale.AES.AES_helpers open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open FStar.Mul #reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 0" let lemma_expand_key_128_0 (key:aes_key_LE AES_128) = expand_key_reveal ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "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.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.AES_helpers.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_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": 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": 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": 10, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
key: Vale.AES.AES_s.aes_key_LE Vale.AES.AES_common_s.AES_128 -> i: Prims.nat -> FStar.Pervasives.Lemma (requires 0 < i /\ i < 11) (ensures (let m = 4 * (i - 1) in let n = 4 * i in let v = Vale.AES.AES_s.expand_key Vale.AES.AES_common_s.AES_128 key n in let w = Vale.AES.AES_s.expand_key Vale.AES.AES_common_s.AES_128 key (n + 4) in let prev = Vale.Def.Words_s.Mkfour v.[ m + 0 ] v.[ m + 1 ] v.[ m + 2 ] v.[ m + 3 ] in Vale.AES.AES_helpers.round_key_128 prev i == Vale.Def.Words_s.Mkfour w.[ n + 0 ] w.[ n + 1 ] w.[ n + 2 ] w.[ n + 3 ]))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.AES_s.aes_key_LE", "Vale.AES.AES_common_s.AES_128", "Prims.nat", "FStar.Seq.Base.seq", "Vale.Def.Words_s.nat32", "Prims.eq2", "FStar.Seq.Base.length", "Prims.op_Addition", "Vale.AES.AES_s.expand_key", "Prims.int", "FStar.Mul.op_Star", "Prims.unit", "Vale.AES.AES_s.expand_key_reveal" ]
[]
true
false
true
false
false
let lemma_expand_key_128_i (key: aes_key_LE AES_128) (i: nat) =
expand_key_reveal (); let n = 4 * i in let _ = expand_key AES_128 key (n + 1) in let _ = expand_key AES_128 key (n + 2) in let _ = expand_key AES_128 key (n + 3) in ()
false
Vale.AES.AES_helpers.fst
Vale.AES.AES_helpers.lemma_incr_msb
val lemma_incr_msb (orig ctr ctr':quad32) (increment:nat) : Lemma (requires increment < 256 /\ ctr == reverse_bytes_quad32 orig /\ ctr' == Vale.Arch.Types.add_wrap_quad32 ctr (Mkfour 0 0 0 (increment * 0x1000000))) (ensures (orig.lo0 % 256) + increment < 256 ==> ctr' == reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 orig increment))
val lemma_incr_msb (orig ctr ctr':quad32) (increment:nat) : Lemma (requires increment < 256 /\ ctr == reverse_bytes_quad32 orig /\ ctr' == Vale.Arch.Types.add_wrap_quad32 ctr (Mkfour 0 0 0 (increment * 0x1000000))) (ensures (orig.lo0 % 256) + increment < 256 ==> ctr' == reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 orig increment))
let lemma_incr_msb (orig ctr ctr':quad32) (increment:nat) : Lemma (requires increment < 256 /\ ctr == reverse_bytes_quad32 orig /\ ctr' == Vale.Arch.Types.add_wrap_quad32 ctr (Mkfour 0 0 0 (increment * 0x1000000))) (ensures (orig.lo0 % 256) + increment < 256 ==> ctr' == reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 orig increment)) = let ctr_new = Vale.AES.GCTR_s.inc32 orig increment in reveal_reverse_bytes_quad32 orig; reveal_reverse_bytes_quad32 ctr_new; if (orig.lo0 % 256) + increment < 256 then ( lemma_add_0x1000000_reverse_mult orig.lo0 increment; () ) else (); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 151, "start_col": 0, "start_line": 138 }
module Vale.AES.AES_helpers open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open FStar.Mul #reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 0" let lemma_expand_key_128_0 (key:aes_key_LE AES_128) = expand_key_reveal () #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 10" let lemma_expand_key_128_i (key:aes_key_LE AES_128) (i:nat) = expand_key_reveal (); let n = 4 * i in // unfold expand_key 4 times (could use fuel, but that unfolds everything): let _ = expand_key AES_128 key (n + 1) in let _ = expand_key AES_128 key (n + 2) in let _ = expand_key AES_128 key (n + 3) in () #reset-options // expand_key for large 'size' argument agrees with expand_key for smaller 'size' argument let rec lemma_expand_append (key:aes_key_LE AES_128) (size1:nat) (size2:nat) = expand_key_reveal (); if size1 < size2 then lemma_expand_append key size1 (size2 - 1) #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 40 --using_facts_from '* -FStar.Seq.Properties'" #restart-solver // quad32 key expansion is equivalent to nat32 key expansion let rec lemma_expand_key_128 (key:seq nat32) (size:nat) = expand_key_128_reveal (); lemma_expand_append key (4 * size) 44; if size = 0 then () else ( let i = size - 1 in lemma_expand_append key (4 * i) 44; lemma_expand_key_128 key i; if i = 0 then lemma_expand_key_128_0 key else lemma_expand_key_128_i key i ) #reset-options // SIMD version of round_key_128 is equivalent to scalar round_key_128 #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_simd_round_key (prev:quad32) (rcon:nat32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); commute_rot_word_sub_word prev.hi3; Vale.Arch.Types.xor_lemmas () #pop-options let commute_sub_bytes_shift_rows_forall () = FStar.Classical.forall_intro commute_sub_bytes_shift_rows let init_rounds_opaque (init:quad32) (round_keys:seq quad32) = eval_rounds_reveal () #push-options "--max_ifuel 2 --initial_ifuel 2" // REVIEW: Why do we need this? Extra inversion to deal with opaque? let finish_cipher (alg:algorithm) (input:quad32) (round_keys:seq quad32) = eval_rounds_reveal (); eval_cipher_reveal (); commute_sub_bytes_shift_rows_forall() let finish_cipher_opt (alg:algorithm) (input plain t0 t1 out:quad32) (round_keys:seq quad32) : Lemma (requires length round_keys == (nr alg) + 1 /\ length round_keys > 0 /\ nr alg > 1 /\ // REVIEW: Why are these needed? t0 = quad32_xor input (index round_keys 0) /\ t1 = eval_rounds t0 round_keys (nr alg - 1) /\ out = quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor plain (index round_keys (nr alg)))) (ensures out == quad32_xor plain (eval_cipher alg input round_keys)) = calc (==) { out; == {} // From requires quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor plain (index round_keys (nr alg))); == { Vale.Arch.TypesNative.lemma_quad32_xor_commutes plain (index round_keys (nr alg)) } quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor (index round_keys (nr alg)) plain); == { Vale.Arch.TypesNative.lemma_quad32_xor_associates (sub_bytes (shift_rows_LE t1)) (index round_keys (nr alg)) plain } quad32_xor (quad32_xor (sub_bytes (shift_rows_LE t1)) (index round_keys (nr alg))) plain; == { eval_rounds_reveal (); eval_cipher_reveal (); commute_sub_bytes_shift_rows_forall(); quad32_xor_reveal () } quad32_xor (eval_cipher alg input round_keys) plain; == { Vale.Arch.TypesNative.lemma_quad32_xor_commutes plain (eval_cipher alg input round_keys) } quad32_xor plain (eval_cipher alg input round_keys); }; () #pop-options #reset-options "--z3rlimit 20" let lemma_add_0x1000000_reverse_mult (n:nat32) (increment:nat) : Lemma (requires (n % 256) + increment < 256) (ensures (let r = reverse_bytes_nat32 n in r + increment * 0x1000000 == reverse_bytes_nat32 (n + increment))) = let r = reverse_bytes_nat32 n in assert_norm (Vale.Def.Words.Four_s.nat_to_four 8 (n+increment) == Mkfour ((n+increment) % 0x100) (((n+increment) / 0x100) % 0x100) (((n+increment) / 0x10000) % 0x100) (((n+increment) / 0x1000000) % 0x100)); assert ((n+increment) / 0x1000000 == n / 0x1000000); assert ((n+increment) / 0x10000 == n / 0x10000); assert ((n+increment) / 0x100 == n / 0x100); assert (Vale.Def.Words.Four_s.nat_to_four 8 (n+increment) == Mkfour ((n+increment) % 0x100) ((n / 0x100) % 0x100) ((n / 0x10000) % 0x100) ((n / 0x1000000) % 0x100)); assert_norm (Vale.Def.Words.Four_s.nat_to_four 8 n == Mkfour (n % 0x100) ((n / 0x100) % 0x100) ((n / 0x10000) % 0x100) ((n / 0x1000000) % 0x100)); let s = Vale.Def.Words.Seq_s.four_to_seq_BE (Vale.Def.Words.Four_s.nat_to_four 8 n) in let r_s = Vale.Lib.Seqs_s.reverse_seq s in assert_norm (be_bytes_to_nat32 r_s == ((n / 0x1000000) % 0x100) + ((n / 0x10000) % 0x100) * 0x100 + ((n / 0x100) % 0x100) * 0x10000 + (n % 0x100) * 0x1000000); let s' = Vale.Def.Words.Seq_s.four_to_seq_BE (Vale.Def.Words.Four_s.nat_to_four 8 (n+increment)) in let r_s' = Vale.Lib.Seqs_s.reverse_seq s' in assert_norm (be_bytes_to_nat32 r_s' == (((n) / 0x1000000) % 0x100) + (((n) / 0x10000) % 0x100) * 0x100 + (((n) / 0x100) % 0x100) * 0x10000 + ((n+increment) % 0x100) * 0x1000000); assert (be_bytes_to_nat32 r_s + increment * 0x1000000 == be_bytes_to_nat32 r_s'); calc (==) { r; == { reverse_bytes_nat32_reveal () } be_bytes_to_nat32 r_s; }; calc (==) { reverse_bytes_nat32 (n+increment); == { reverse_bytes_nat32_reveal () } be_bytes_to_nat32 (Vale.Lib.Seqs_s.reverse_seq (nat32_to_be_bytes (n+increment))); }; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "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.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.AES_helpers.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_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
orig: Vale.Def.Types_s.quad32 -> ctr: Vale.Def.Types_s.quad32 -> ctr': Vale.Def.Types_s.quad32 -> increment: Prims.nat -> FStar.Pervasives.Lemma (requires increment < 256 /\ ctr == Vale.Def.Types_s.reverse_bytes_quad32 orig /\ ctr' == Vale.Arch.Types.add_wrap_quad32 ctr (Vale.Def.Words_s.Mkfour 0 0 0 (increment * 0x1000000))) (ensures Mkfour?.lo0 orig % 256 + increment < 256 ==> ctr' == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 orig increment))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.quad32", "Prims.nat", "Prims.unit", "Prims.op_LessThan", "Prims.op_Addition", "Prims.op_Modulus", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Types_s.nat32", "Vale.AES.AES_helpers.lemma_add_0x1000000_reverse_mult", "Prims.bool", "Vale.Def.Types_s.reveal_reverse_bytes_quad32", "Vale.AES.GCTR_s.inc32", "Prims.l_and", "Prims.b2t", "Prims.eq2", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.Arch.Types.add_wrap_quad32", "Vale.Def.Words_s.Mkfour", "FStar.Mul.op_Star", "Prims.squash", "Prims.l_imp", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let lemma_incr_msb (orig ctr ctr': quad32) (increment: nat) : Lemma (requires increment < 256 /\ ctr == reverse_bytes_quad32 orig /\ ctr' == Vale.Arch.Types.add_wrap_quad32 ctr (Mkfour 0 0 0 (increment * 0x1000000))) (ensures (orig.lo0 % 256) + increment < 256 ==> ctr' == reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 orig increment)) =
let ctr_new = Vale.AES.GCTR_s.inc32 orig increment in reveal_reverse_bytes_quad32 orig; reveal_reverse_bytes_quad32 ctr_new; if (orig.lo0 % 256) + increment < 256 then (lemma_add_0x1000000_reverse_mult orig.lo0 increment; ()); ()
false
Vale.AES.AES_helpers.fst
Vale.AES.AES_helpers.finish_cipher_opt
val finish_cipher_opt (alg:algorithm) (input plain t0 t1 out:quad32) (round_keys:seq quad32) : Lemma (requires length round_keys == (nr alg) + 1 /\ length round_keys > 0 /\ nr alg > 1 /\ // REVIEW: Why are these needed? t0 = quad32_xor input (index round_keys 0) /\ t1 = eval_rounds t0 round_keys (nr alg - 1) /\ out = quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor plain (index round_keys (nr alg)))) (ensures out == quad32_xor plain (eval_cipher alg input round_keys))
val finish_cipher_opt (alg:algorithm) (input plain t0 t1 out:quad32) (round_keys:seq quad32) : Lemma (requires length round_keys == (nr alg) + 1 /\ length round_keys > 0 /\ nr alg > 1 /\ // REVIEW: Why are these needed? t0 = quad32_xor input (index round_keys 0) /\ t1 = eval_rounds t0 round_keys (nr alg - 1) /\ out = quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor plain (index round_keys (nr alg)))) (ensures out == quad32_xor plain (eval_cipher alg input round_keys))
let finish_cipher_opt (alg:algorithm) (input plain t0 t1 out:quad32) (round_keys:seq quad32) : Lemma (requires length round_keys == (nr alg) + 1 /\ length round_keys > 0 /\ nr alg > 1 /\ // REVIEW: Why are these needed? t0 = quad32_xor input (index round_keys 0) /\ t1 = eval_rounds t0 round_keys (nr alg - 1) /\ out = quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor plain (index round_keys (nr alg)))) (ensures out == quad32_xor plain (eval_cipher alg input round_keys)) = calc (==) { out; == {} // From requires quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor plain (index round_keys (nr alg))); == { Vale.Arch.TypesNative.lemma_quad32_xor_commutes plain (index round_keys (nr alg)) } quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor (index round_keys (nr alg)) plain); == { Vale.Arch.TypesNative.lemma_quad32_xor_associates (sub_bytes (shift_rows_LE t1)) (index round_keys (nr alg)) plain } quad32_xor (quad32_xor (sub_bytes (shift_rows_LE t1)) (index round_keys (nr alg))) plain; == { eval_rounds_reveal (); eval_cipher_reveal (); commute_sub_bytes_shift_rows_forall(); quad32_xor_reveal () } quad32_xor (eval_cipher alg input round_keys) plain; == { Vale.Arch.TypesNative.lemma_quad32_xor_commutes plain (eval_cipher alg input round_keys) } quad32_xor plain (eval_cipher alg input round_keys); }; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 94, "start_col": 0, "start_line": 69 }
module Vale.AES.AES_helpers open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open FStar.Mul #reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 0" let lemma_expand_key_128_0 (key:aes_key_LE AES_128) = expand_key_reveal () #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 10" let lemma_expand_key_128_i (key:aes_key_LE AES_128) (i:nat) = expand_key_reveal (); let n = 4 * i in // unfold expand_key 4 times (could use fuel, but that unfolds everything): let _ = expand_key AES_128 key (n + 1) in let _ = expand_key AES_128 key (n + 2) in let _ = expand_key AES_128 key (n + 3) in () #reset-options // expand_key for large 'size' argument agrees with expand_key for smaller 'size' argument let rec lemma_expand_append (key:aes_key_LE AES_128) (size1:nat) (size2:nat) = expand_key_reveal (); if size1 < size2 then lemma_expand_append key size1 (size2 - 1) #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 40 --using_facts_from '* -FStar.Seq.Properties'" #restart-solver // quad32 key expansion is equivalent to nat32 key expansion let rec lemma_expand_key_128 (key:seq nat32) (size:nat) = expand_key_128_reveal (); lemma_expand_append key (4 * size) 44; if size = 0 then () else ( let i = size - 1 in lemma_expand_append key (4 * i) 44; lemma_expand_key_128 key i; if i = 0 then lemma_expand_key_128_0 key else lemma_expand_key_128_i key i ) #reset-options // SIMD version of round_key_128 is equivalent to scalar round_key_128 #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_simd_round_key (prev:quad32) (rcon:nat32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); commute_rot_word_sub_word prev.hi3; Vale.Arch.Types.xor_lemmas () #pop-options let commute_sub_bytes_shift_rows_forall () = FStar.Classical.forall_intro commute_sub_bytes_shift_rows let init_rounds_opaque (init:quad32) (round_keys:seq quad32) = eval_rounds_reveal () #push-options "--max_ifuel 2 --initial_ifuel 2" // REVIEW: Why do we need this? Extra inversion to deal with opaque? let finish_cipher (alg:algorithm) (input:quad32) (round_keys:seq quad32) = eval_rounds_reveal (); eval_cipher_reveal (); commute_sub_bytes_shift_rows_forall()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "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.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.AES_helpers.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_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": 2, "max_fuel": 1, "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": 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 -> plain: Vale.Def.Types_s.quad32 -> t0: Vale.Def.Types_s.quad32 -> t1: Vale.Def.Types_s.quad32 -> out: Vale.Def.Types_s.quad32 -> round_keys: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length round_keys == Vale.AES.AES_common_s.nr alg + 1 /\ FStar.Seq.Base.length round_keys > 0 /\ Vale.AES.AES_common_s.nr alg > 1 /\ t0 = Vale.Def.Types_s.quad32_xor input (FStar.Seq.Base.index round_keys 0) /\ t1 = Vale.AES.AES_s.eval_rounds t0 round_keys (Vale.AES.AES_common_s.nr alg - 1) /\ out = Vale.Def.Types_s.quad32_xor (Vale.AES.AES_common_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE t1 )) (Vale.Def.Types_s.quad32_xor plain (FStar.Seq.Base.index round_keys (Vale.AES.AES_common_s.nr alg)))) (ensures out == Vale.Def.Types_s.quad32_xor plain (Vale.AES.AES_s.eval_cipher alg input round_keys))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Prims.unit", "FStar.Calc.calc_finish", "Prims.eq2", "Vale.Def.Types_s.quad32_xor", "Vale.AES.AES_s.eval_cipher", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Vale.AES.AES_common_s.sub_bytes", "Vale.AES.AES_s.shift_rows_LE", "FStar.Seq.Base.index", "Vale.AES.AES_common_s.nr", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Vale.Arch.TypesNative.lemma_quad32_xor_commutes", "Vale.Arch.TypesNative.lemma_quad32_xor_associates", "Vale.Def.Types_s.quad32_xor_reveal", "Vale.AES.AES_helpers.commute_sub_bytes_shift_rows_forall", "Vale.AES.AES_s.eval_cipher_reveal", "Vale.AES.AES_s.eval_rounds_reveal", "Prims.l_and", "Prims.int", "FStar.Seq.Base.length", "Prims.op_Addition", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_Equality", "Vale.AES.AES_s.eval_rounds", "Prims.op_Subtraction", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let finish_cipher_opt (alg: algorithm) (input plain t0 t1 out: quad32) (round_keys: seq quad32) : Lemma (requires length round_keys == (nr alg) + 1 /\ length round_keys > 0 /\ nr alg > 1 /\ t0 = quad32_xor input (index round_keys 0) /\ t1 = eval_rounds t0 round_keys (nr alg - 1) /\ out = quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor plain (index round_keys (nr alg)))) (ensures out == quad32_xor plain (eval_cipher alg input round_keys)) =
calc ( == ) { out; ( == ) { () } quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor plain (index round_keys (nr alg))); ( == ) { Vale.Arch.TypesNative.lemma_quad32_xor_commutes plain (index round_keys (nr alg)) } quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor (index round_keys (nr alg)) plain); ( == ) { Vale.Arch.TypesNative.lemma_quad32_xor_associates (sub_bytes (shift_rows_LE t1)) (index round_keys (nr alg)) plain } quad32_xor (quad32_xor (sub_bytes (shift_rows_LE t1)) (index round_keys (nr alg))) plain; ( == ) { (eval_rounds_reveal (); eval_cipher_reveal (); commute_sub_bytes_shift_rows_forall (); quad32_xor_reveal ()) } quad32_xor (eval_cipher alg input round_keys) plain; ( == ) { Vale.Arch.TypesNative.lemma_quad32_xor_commutes plain (eval_cipher alg input round_keys) } quad32_xor plain (eval_cipher alg input round_keys); }; ()
false
Vale.AES.AES_helpers.fst
Vale.AES.AES_helpers.lemma_msb_in_bounds
val lemma_msb_in_bounds (ctr_BE inout5 t1':quad32) (counter:nat) : Lemma (requires inout5 == reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 ctr_BE 5) /\ counter == ctr_BE.lo0 % 256 /\ counter + 6 < 256 /\ t1' == Vale.Arch.Types.add_wrap_quad32 inout5 (Mkfour 0 0 0 0x1000000)) (ensures t1' == reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 ctr_BE 6))
val lemma_msb_in_bounds (ctr_BE inout5 t1':quad32) (counter:nat) : Lemma (requires inout5 == reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 ctr_BE 5) /\ counter == ctr_BE.lo0 % 256 /\ counter + 6 < 256 /\ t1' == Vale.Arch.Types.add_wrap_quad32 inout5 (Mkfour 0 0 0 0x1000000)) (ensures t1' == reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 ctr_BE 6))
let lemma_msb_in_bounds (ctr_BE inout5 t1':quad32) (counter:nat) : Lemma (requires inout5 == reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 ctr_BE 5) /\ counter == ctr_BE.lo0 % 256 /\ counter + 6 < 256 /\ t1' == Vale.Arch.Types.add_wrap_quad32 inout5 (Mkfour 0 0 0 0x1000000)) (ensures t1' == reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 ctr_BE 6)) = let ctr5 = Vale.AES.GCTR_s.inc32 ctr_BE 5 in let ctr6 = Vale.AES.GCTR_s.inc32 ctr_BE 6 in reveal_reverse_bytes_quad32 ctr5; reveal_reverse_bytes_quad32 ctr6; let r5 = reverse_bytes_quad32 ctr5 in let r6 = reverse_bytes_quad32 ctr6 in assert (ctr_BE.lo0 + 6 < pow2_32); assert (ctr6.lo0 == ctr5.lo0 + 1); calc (==) { r6; == {} Mkfour (reverse_bytes_nat32 ctr6.hi3) (reverse_bytes_nat32 ctr6.hi2) (reverse_bytes_nat32 ctr6.lo1) (reverse_bytes_nat32 ctr6.lo0); == {} Mkfour (reverse_bytes_nat32 ctr5.hi3) (reverse_bytes_nat32 ctr5.hi2) (reverse_bytes_nat32 ctr5.lo1) (reverse_bytes_nat32 ctr6.lo0); == {} Mkfour (reverse_bytes_nat32 ctr5.hi3) (reverse_bytes_nat32 ctr5.hi2) (reverse_bytes_nat32 ctr5.lo1) (reverse_bytes_nat32 (ctr5.lo0 + 1)); == {} Mkfour inout5.lo0 inout5.lo1 inout5.hi2 (reverse_bytes_nat32 (ctr5.lo0 + 1)); == { lemma_add_0x1000000_reverse_mult ctr5.lo0 1 } t1'; }; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 182, "start_col": 0, "start_line": 154 }
module Vale.AES.AES_helpers open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open FStar.Mul #reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 0" let lemma_expand_key_128_0 (key:aes_key_LE AES_128) = expand_key_reveal () #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 10" let lemma_expand_key_128_i (key:aes_key_LE AES_128) (i:nat) = expand_key_reveal (); let n = 4 * i in // unfold expand_key 4 times (could use fuel, but that unfolds everything): let _ = expand_key AES_128 key (n + 1) in let _ = expand_key AES_128 key (n + 2) in let _ = expand_key AES_128 key (n + 3) in () #reset-options // expand_key for large 'size' argument agrees with expand_key for smaller 'size' argument let rec lemma_expand_append (key:aes_key_LE AES_128) (size1:nat) (size2:nat) = expand_key_reveal (); if size1 < size2 then lemma_expand_append key size1 (size2 - 1) #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 40 --using_facts_from '* -FStar.Seq.Properties'" #restart-solver // quad32 key expansion is equivalent to nat32 key expansion let rec lemma_expand_key_128 (key:seq nat32) (size:nat) = expand_key_128_reveal (); lemma_expand_append key (4 * size) 44; if size = 0 then () else ( let i = size - 1 in lemma_expand_append key (4 * i) 44; lemma_expand_key_128 key i; if i = 0 then lemma_expand_key_128_0 key else lemma_expand_key_128_i key i ) #reset-options // SIMD version of round_key_128 is equivalent to scalar round_key_128 #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_simd_round_key (prev:quad32) (rcon:nat32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); commute_rot_word_sub_word prev.hi3; Vale.Arch.Types.xor_lemmas () #pop-options let commute_sub_bytes_shift_rows_forall () = FStar.Classical.forall_intro commute_sub_bytes_shift_rows let init_rounds_opaque (init:quad32) (round_keys:seq quad32) = eval_rounds_reveal () #push-options "--max_ifuel 2 --initial_ifuel 2" // REVIEW: Why do we need this? Extra inversion to deal with opaque? let finish_cipher (alg:algorithm) (input:quad32) (round_keys:seq quad32) = eval_rounds_reveal (); eval_cipher_reveal (); commute_sub_bytes_shift_rows_forall() let finish_cipher_opt (alg:algorithm) (input plain t0 t1 out:quad32) (round_keys:seq quad32) : Lemma (requires length round_keys == (nr alg) + 1 /\ length round_keys > 0 /\ nr alg > 1 /\ // REVIEW: Why are these needed? t0 = quad32_xor input (index round_keys 0) /\ t1 = eval_rounds t0 round_keys (nr alg - 1) /\ out = quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor plain (index round_keys (nr alg)))) (ensures out == quad32_xor plain (eval_cipher alg input round_keys)) = calc (==) { out; == {} // From requires quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor plain (index round_keys (nr alg))); == { Vale.Arch.TypesNative.lemma_quad32_xor_commutes plain (index round_keys (nr alg)) } quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor (index round_keys (nr alg)) plain); == { Vale.Arch.TypesNative.lemma_quad32_xor_associates (sub_bytes (shift_rows_LE t1)) (index round_keys (nr alg)) plain } quad32_xor (quad32_xor (sub_bytes (shift_rows_LE t1)) (index round_keys (nr alg))) plain; == { eval_rounds_reveal (); eval_cipher_reveal (); commute_sub_bytes_shift_rows_forall(); quad32_xor_reveal () } quad32_xor (eval_cipher alg input round_keys) plain; == { Vale.Arch.TypesNative.lemma_quad32_xor_commutes plain (eval_cipher alg input round_keys) } quad32_xor plain (eval_cipher alg input round_keys); }; () #pop-options #reset-options "--z3rlimit 20" let lemma_add_0x1000000_reverse_mult (n:nat32) (increment:nat) : Lemma (requires (n % 256) + increment < 256) (ensures (let r = reverse_bytes_nat32 n in r + increment * 0x1000000 == reverse_bytes_nat32 (n + increment))) = let r = reverse_bytes_nat32 n in assert_norm (Vale.Def.Words.Four_s.nat_to_four 8 (n+increment) == Mkfour ((n+increment) % 0x100) (((n+increment) / 0x100) % 0x100) (((n+increment) / 0x10000) % 0x100) (((n+increment) / 0x1000000) % 0x100)); assert ((n+increment) / 0x1000000 == n / 0x1000000); assert ((n+increment) / 0x10000 == n / 0x10000); assert ((n+increment) / 0x100 == n / 0x100); assert (Vale.Def.Words.Four_s.nat_to_four 8 (n+increment) == Mkfour ((n+increment) % 0x100) ((n / 0x100) % 0x100) ((n / 0x10000) % 0x100) ((n / 0x1000000) % 0x100)); assert_norm (Vale.Def.Words.Four_s.nat_to_four 8 n == Mkfour (n % 0x100) ((n / 0x100) % 0x100) ((n / 0x10000) % 0x100) ((n / 0x1000000) % 0x100)); let s = Vale.Def.Words.Seq_s.four_to_seq_BE (Vale.Def.Words.Four_s.nat_to_four 8 n) in let r_s = Vale.Lib.Seqs_s.reverse_seq s in assert_norm (be_bytes_to_nat32 r_s == ((n / 0x1000000) % 0x100) + ((n / 0x10000) % 0x100) * 0x100 + ((n / 0x100) % 0x100) * 0x10000 + (n % 0x100) * 0x1000000); let s' = Vale.Def.Words.Seq_s.four_to_seq_BE (Vale.Def.Words.Four_s.nat_to_four 8 (n+increment)) in let r_s' = Vale.Lib.Seqs_s.reverse_seq s' in assert_norm (be_bytes_to_nat32 r_s' == (((n) / 0x1000000) % 0x100) + (((n) / 0x10000) % 0x100) * 0x100 + (((n) / 0x100) % 0x100) * 0x10000 + ((n+increment) % 0x100) * 0x1000000); assert (be_bytes_to_nat32 r_s + increment * 0x1000000 == be_bytes_to_nat32 r_s'); calc (==) { r; == { reverse_bytes_nat32_reveal () } be_bytes_to_nat32 r_s; }; calc (==) { reverse_bytes_nat32 (n+increment); == { reverse_bytes_nat32_reveal () } be_bytes_to_nat32 (Vale.Lib.Seqs_s.reverse_seq (nat32_to_be_bytes (n+increment))); }; () #reset-options "" let lemma_incr_msb (orig ctr ctr':quad32) (increment:nat) : Lemma (requires increment < 256 /\ ctr == reverse_bytes_quad32 orig /\ ctr' == Vale.Arch.Types.add_wrap_quad32 ctr (Mkfour 0 0 0 (increment * 0x1000000))) (ensures (orig.lo0 % 256) + increment < 256 ==> ctr' == reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 orig increment)) = let ctr_new = Vale.AES.GCTR_s.inc32 orig increment in reveal_reverse_bytes_quad32 orig; reveal_reverse_bytes_quad32 ctr_new; if (orig.lo0 % 256) + increment < 256 then ( lemma_add_0x1000000_reverse_mult orig.lo0 increment; () ) else (); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "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.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.AES_helpers.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_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
ctr_BE: Vale.Def.Types_s.quad32 -> inout5: Vale.Def.Types_s.quad32 -> t1': Vale.Def.Types_s.quad32 -> counter: Prims.nat -> FStar.Pervasives.Lemma (requires inout5 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 ctr_BE 5) /\ counter == Mkfour?.lo0 ctr_BE % 256 /\ counter + 6 < 256 /\ t1' == Vale.Arch.Types.add_wrap_quad32 inout5 (Vale.Def.Words_s.Mkfour 0 0 0 0x1000000)) (ensures t1' == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 ctr_BE 6))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.quad32", "Prims.nat", "Prims.unit", "FStar.Calc.calc_finish", "Prims.eq2", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Types_s.reverse_bytes_nat32", "Prims.op_Addition", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Vale.AES.AES_helpers.lemma_add_0x1000000_reverse_mult", "Prims._assert", "Prims.int", "Prims.b2t", "Prims.op_LessThan", "Vale.Def.Words_s.pow2_32", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.Def.Types_s.reveal_reverse_bytes_quad32", "Vale.AES.GCTR_s.inc32", "Prims.l_and", "Prims.op_Modulus", "Vale.Arch.Types.add_wrap_quad32", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let lemma_msb_in_bounds (ctr_BE inout5 t1': quad32) (counter: nat) : Lemma (requires inout5 == reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 ctr_BE 5) /\ counter == ctr_BE.lo0 % 256 /\ counter + 6 < 256 /\ t1' == Vale.Arch.Types.add_wrap_quad32 inout5 (Mkfour 0 0 0 0x1000000)) (ensures t1' == reverse_bytes_quad32 (Vale.AES.GCTR_s.inc32 ctr_BE 6)) =
let ctr5 = Vale.AES.GCTR_s.inc32 ctr_BE 5 in let ctr6 = Vale.AES.GCTR_s.inc32 ctr_BE 6 in reveal_reverse_bytes_quad32 ctr5; reveal_reverse_bytes_quad32 ctr6; let r5 = reverse_bytes_quad32 ctr5 in let r6 = reverse_bytes_quad32 ctr6 in assert (ctr_BE.lo0 + 6 < pow2_32); assert (ctr6.lo0 == ctr5.lo0 + 1); calc ( == ) { r6; ( == ) { () } Mkfour (reverse_bytes_nat32 ctr6.hi3) (reverse_bytes_nat32 ctr6.hi2) (reverse_bytes_nat32 ctr6.lo1) (reverse_bytes_nat32 ctr6.lo0); ( == ) { () } Mkfour (reverse_bytes_nat32 ctr5.hi3) (reverse_bytes_nat32 ctr5.hi2) (reverse_bytes_nat32 ctr5.lo1) (reverse_bytes_nat32 ctr6.lo0); ( == ) { () } Mkfour (reverse_bytes_nat32 ctr5.hi3) (reverse_bytes_nat32 ctr5.hi2) (reverse_bytes_nat32 ctr5.lo1) (reverse_bytes_nat32 (ctr5.lo0 + 1)); ( == ) { () } Mkfour inout5.lo0 inout5.lo1 inout5.hi2 (reverse_bytes_nat32 (ctr5.lo0 + 1)); ( == ) { lemma_add_0x1000000_reverse_mult ctr5.lo0 1 } t1'; }; ()
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.mul_add_distr
val mul_add_distr: distribute_left_lemma pfelem pfelem_add_cm pfelem_mul_cm
val mul_add_distr: distribute_left_lemma pfelem pfelem_add_cm pfelem_mul_cm
let mul_add_distr a b c = normalize_term_spec prime; calc (==) { a *% (b +% c); == { } (a * (b +% c)) % prime; == { Math.Lemmas.lemma_mod_add_distr a (b + c) prime } (a * ((b + c) % prime)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b + c) prime } (a * (b + c)) % prime; == { Math.Lemmas.distributivity_add_right a b c } (a * b + a * c) % prime; == { Math.Lemmas.lemma_mod_add_distr (a * b) (a * c) prime } (a * b + a *% c) % prime; == { } (a *% c + a * b) % prime; == { Math.Lemmas.lemma_mod_add_distr (a *% c) (a * b) prime } (a *% c + a *% b) % prime; == { } (a *% b + a *% c) % prime; == { } a *% b +% a *% c; }
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 108, "start_col": 0, "start_line": 86 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime val add_identity: a:pfelem -> Lemma (zero +% a == a) let add_identity a = normalize_term_spec prime val mul_identity: a:pfelem -> Lemma (one *% a == a) let mul_identity a = normalize_term_spec prime val add_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a +% b +% c == a +% (b +% c)) let add_associativity a b c = normalize_term_spec prime; calc (==) { a +% b +% c; == { } ((a + b) % prime + c) % prime; == { Math.Lemmas.lemma_mod_plus_distr_l (a + b) c prime } ((a + b) + c) % prime; == { } (a + (b + c)) % prime; == { Math.Lemmas.lemma_mod_plus_distr_r a (b + c) prime } a +% (b +% c); } val add_commutativity: a:pfelem -> b:pfelem -> Lemma (a +% b == b +% a) let add_commutativity a b = () val mul_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a *% b *% c == a *% (b *% c)) let mul_associativity a b c = calc (==) { a *% b *% c; == { } (((a * b) % prime) * c) % prime; == { Math.Lemmas.lemma_mod_mul_distr_l (a * b) c prime } ((a * b) * c) % prime; == { Math.Lemmas.paren_mul_right a b c } (a * (b * c)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b * c) prime } (a * ((b * c) % prime)) % prime; == { } a *% (b *% c); } val mul_commutativity: a:pfelem -> b:pfelem -> Lemma (a *% b == b *% a) let mul_commutativity a b = () [@canon_attr] let pfelem_add_cm : cm pfelem = CM zero ( +% ) add_identity add_associativity add_commutativity [@canon_attr] let pfelem_mul_cm : cm pfelem = CM one ( *% ) mul_identity mul_associativity mul_commutativity
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Tactics.CanonCommSemiring.distribute_left_lemma Hacl.Spec.Poly1305.Lemmas.pfelem Hacl.Spec.Poly1305.Lemmas.pfelem_add_cm Hacl.Spec.Poly1305.Lemmas.pfelem_mul_cm
Prims.Tot
[ "total" ]
[]
[ "Hacl.Spec.Poly1305.Lemmas.pfelem", "FStar.Calc.calc_finish", "Prims.eq2", "Hacl.Spec.Poly1305.Lemmas.op_Star_Percent", "Hacl.Spec.Poly1305.Lemmas.op_Plus_Percent", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Prims.op_Modulus", "Prims.op_Addition", "Hacl.Spec.Poly1305.Lemmas.prime", "FStar.Mul.op_Star", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "FStar.Math.Lemmas.lemma_mod_add_distr", "FStar.Math.Lemmas.lemma_mod_mul_distr_r", "FStar.Math.Lemmas.distributivity_add_right", "FStar.Pervasives.normalize_term_spec", "Prims.pos" ]
[]
false
false
false
true
false
let mul_add_distr a b c =
normalize_term_spec prime; calc ( == ) { a *% (b +% c); ( == ) { () } (a * (b +% c)) % prime; ( == ) { Math.Lemmas.lemma_mod_add_distr a (b + c) prime } (a * ((b + c) % prime)) % prime; ( == ) { Math.Lemmas.lemma_mod_mul_distr_r a (b + c) prime } (a * (b + c)) % prime; ( == ) { Math.Lemmas.distributivity_add_right a b c } (a * b + a * c) % prime; ( == ) { Math.Lemmas.lemma_mod_add_distr (a * b) (a * c) prime } (a * b + a *% c) % prime; ( == ) { () } (a *% c + a * b) % prime; ( == ) { Math.Lemmas.lemma_mod_add_distr (a *% c) (a * b) prime } (a *% c + a *% b) % prime; ( == ) { () } (a *% b + a *% c) % prime; ( == ) { () } a *% b +% a *% c; }
false
Vale.AES.AES_helpers.fst
Vale.AES.AES_helpers.lemma_expand_key_128
val lemma_expand_key_128 (key:seq nat32) (size:nat) : Lemma (requires size <= 11 /\ is_aes_key_LE AES_128 key) (ensures ( let s = key_schedule_to_round_keys size (expand_key AES_128 key 44) in (forall (i:nat).{:pattern (expand_key_128 key i) \/ (expand_key_128_def key i)} i < size ==> expand_key_128 key i == s.[i]) ))
val lemma_expand_key_128 (key:seq nat32) (size:nat) : Lemma (requires size <= 11 /\ is_aes_key_LE AES_128 key) (ensures ( let s = key_schedule_to_round_keys size (expand_key AES_128 key 44) in (forall (i:nat).{:pattern (expand_key_128 key i) \/ (expand_key_128_def key i)} i < size ==> expand_key_128 key i == s.[i]) ))
let rec lemma_expand_key_128 (key:seq nat32) (size:nat) = expand_key_128_reveal (); lemma_expand_append key (4 * size) 44; if size = 0 then () else ( let i = size - 1 in lemma_expand_append key (4 * i) 44; lemma_expand_key_128 key i; if i = 0 then lemma_expand_key_128_0 key else lemma_expand_key_128_i key i )
{ "file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 44, "start_col": 0, "start_line": 33 }
module Vale.AES.AES_helpers open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open FStar.Mul #reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 0" let lemma_expand_key_128_0 (key:aes_key_LE AES_128) = expand_key_reveal () #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 10" let lemma_expand_key_128_i (key:aes_key_LE AES_128) (i:nat) = expand_key_reveal (); let n = 4 * i in // unfold expand_key 4 times (could use fuel, but that unfolds everything): let _ = expand_key AES_128 key (n + 1) in let _ = expand_key AES_128 key (n + 2) in let _ = expand_key AES_128 key (n + 3) in () #reset-options // expand_key for large 'size' argument agrees with expand_key for smaller 'size' argument let rec lemma_expand_append (key:aes_key_LE AES_128) (size1:nat) (size2:nat) = expand_key_reveal (); if size1 < size2 then lemma_expand_append key size1 (size2 - 1) #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 40 --using_facts_from '* -FStar.Seq.Properties'" #restart-solver
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "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.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.AES_helpers.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_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": 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": 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": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> size: Prims.nat -> FStar.Pervasives.Lemma (requires size <= 11 /\ Vale.AES.AES_s.is_aes_key_LE Vale.AES.AES_common_s.AES_128 key) (ensures (let s = Vale.AES.AES_s.key_schedule_to_round_keys size (Vale.AES.AES_s.expand_key Vale.AES.AES_common_s.AES_128 key 44) in forall (i: Prims.nat). {:pattern Vale.AES.AES_helpers.expand_key_128 key i\/Vale.AES.AES_helpers.expand_key_128_def key i} i < size ==> Vale.AES.AES_helpers.expand_key_128 key i == s.[ i ]))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Prims.nat", "Prims.op_Equality", "Prims.int", "Prims.bool", "Vale.AES.AES_helpers.lemma_expand_key_128_0", "Vale.AES.AES_helpers.lemma_expand_key_128_i", "Prims.unit", "Vale.AES.AES_helpers.lemma_expand_key_128", "Vale.AES.AES_helpers.lemma_expand_append", "FStar.Mul.op_Star", "Prims.op_Subtraction", "Vale.AES.AES_helpers.expand_key_128_reveal" ]
[ "recursion" ]
false
false
true
false
false
let rec lemma_expand_key_128 (key: seq nat32) (size: nat) =
expand_key_128_reveal (); lemma_expand_append key (4 * size) 44; if size = 0 then () else (let i = size - 1 in lemma_expand_append key (4 * i) 44; lemma_expand_key_128 key i; if i = 0 then lemma_expand_key_128_0 key else lemma_expand_key_128_i key i)
false
CQueue.fst
CQueue.elim_queue_tail
val elim_queue_tail (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) : SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened (queue_tail x l) (fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail) (fun h -> True) (fun _ tail h -> sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\ sel (cllist_tail x) h == Ghost.reveal tail /\ ccell_ptrvalue_is_null (h (vptr tail)) )
val elim_queue_tail (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) : SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened (queue_tail x l) (fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail) (fun h -> True) (fun _ tail h -> sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\ sel (cllist_tail x) h == Ghost.reveal tail /\ ccell_ptrvalue_is_null (h (vptr tail)) )
let elim_queue_tail #_ #a x l = let tail0 = elim_vdep (llist_fragment_tail l (cllist_head x)) (queue_tail_dep1 x l) in let tail : Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in change_equal_slprop (queue_tail_dep1 x l (Ghost.reveal tail0)) (vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail0); let tail2 = elim_vdep (vptr (cllist_tail x)) (queue_tail_dep2 x l tail0) in let tail3 : Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in change_equal_slprop (queue_tail_dep2 x l tail0 (Ghost.reveal tail2)) (vptr tail3 `vrefine` queue_tail_refine tail0 tail3); elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3); change_equal_slprop (vptr tail3) (vptr tail); tail
{ "file_name": "share/steel/examples/steel/CQueue.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 6, "end_line": 736, "start_col": 0, "start_line": 713 }
module CQueue open CQueue.LList #set-options "--ide_id_info_off" //Re-define squash, since this module explicitly //replies on proving equalities of the form `t_of v == squash p` //which are delicate in the presence of optimizations that //unfold `Prims.squash (p /\ q)`to _:unit{p /\ q} //See Issue #2496 let squash (p:Type u#a) : Type0 = squash p (* BEGIN library *) let intro_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: (t_of v) -> GTot t) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) = intro_vrewrite v f let elim_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v)) = elim_vrewrite v f let vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) = fun _ -> x [@@ __steel_reduce__] let vconst' (#a: Type) (x: a) : GTot vprop' = { hp = hp_of emp; t = a; sel = vconst_sel x; } [@@ __steel_reduce__] let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x) let intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x) = change_slprop_rel emp (vconst x) (fun _ y -> y == x) (fun _ -> ()) let elim_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened (vconst x) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> h (vconst x) == x) = change_slprop_rel (vconst x) emp (fun y _ -> y == x) (fun _ -> ()) let vpure_sel' (p: prop) : Tot (selector' (squash p) (Steel.Memory.pure p)) = fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m let vpure_sel (p: prop) : Tot (selector (squash p) (Steel.Memory.pure p)) = vpure_sel' p [@@ __steel_reduce__] let vpure' (p: prop) : GTot vprop' = { hp = Steel.Memory.pure p; t = squash p; sel = vpure_sel p; } [@@ __steel_reduce__] let vpure (p: prop) : Tot vprop = VUnit (vpure' p) let intro_vpure (#opened: _) (p: prop) : SteelGhost unit opened emp (fun _ -> vpure p) (fun _ -> p) (fun _ _ h' -> p) = change_slprop_rel emp (vpure p) (fun _ _ -> p) (fun m -> pure_interp p m) let elim_vpure (#opened: _) (p: prop) : SteelGhost unit opened (vpure p) (fun _ -> emp) (fun _ -> True) (fun _ _ _ -> p) = change_slprop_rel (vpure p) emp (fun _ _ -> p) (fun m -> pure_interp p m; reveal_emp (); intro_emp m) val intro_vdep2 (#opened:inames) (v: vprop) (q: vprop) (x: t_of v) (p: (t_of v -> Tot vprop)) : SteelGhost unit opened (v `star` q) (fun _ -> vdep v p) (requires (fun h -> q == p x /\ x == h v )) (ensures (fun h _ h' -> let x2 = h' (vdep v p) in q == p (h v) /\ dfst x2 == (h v) /\ dsnd x2 == (h q) )) let intro_vdep2 v q x p = intro_vdep v q p let vbind0_payload (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: t_of a) : Tot vprop = vpure (t == t_of (b x)) `star` b x let vbind0_rewrite (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: normal (t_of (vdep a (vbind0_payload a t b)))) : Tot t = snd (dsnd x) [@@__steel_reduce__; __reduce__] let vbind0 (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b let vbind_hp // necessary to hide the attribute on hp_of (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot (slprop u#1) = hp_of (vbind0 a t b) let vbind_sel // same for hp_sel (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot (selector t (vbind_hp a t b)) = sel_of (vbind0 a t b) [@@__steel_reduce__] let vbind' (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot vprop' = { hp = vbind_hp a t b; t = t; sel = vbind_sel a t b; } [@@__steel_reduce__] let vbind (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = VUnit (vbind' a t b) let intro_vbind (#opened: _) (a: vprop) (b' : vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost unit opened (a `star` b') (fun _ -> vbind a t b) (fun h -> t_of b' == t /\ b' == b (h a)) (fun h _ h' -> t_of b' == t /\ b' == b (h a) /\ h' (vbind a t b) == h b' ) = intro_vpure (t == t_of b'); intro_vdep a (vpure (t == t_of b') `star` b') (vbind0_payload a t b); intro_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); change_slprop_rel (vbind0 a t b) (vbind a t b) (fun x y -> x == y) (fun _ -> ()) let elim_vbind (#opened: _) (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost (Ghost.erased (t_of a)) opened (vbind a t b) (fun res -> a `star` b (Ghost.reveal res)) (fun h -> True) (fun h res h' -> h' a == Ghost.reveal res /\ t == t_of (b (Ghost.reveal res)) /\ h' (b (Ghost.reveal res)) == h (vbind a t b) ) = change_slprop_rel (vbind a t b) (vbind0 a t b) (fun x y -> x == y) (fun _ -> ()); elim_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); let res = elim_vdep a (vbind0_payload a t b) in change_equal_slprop (vbind0_payload a t b (Ghost.reveal res)) (vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res)); elim_vpure (t == t_of (b (Ghost.reveal res))); res let (==) (#a:_) (x y: a) : prop = x == y let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma (requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2])) (ensures (hd1 == hd2 /\ tl1 == tl2)) [SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])] = L.lemma_snoc_unsnoc (hd1, tl1); L.lemma_snoc_unsnoc (hd2, tl2) [@"opaque_to_smt"] let unsnoc (#a: Type) (l: list a) : Pure (list a & a) (requires (Cons? l)) (ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l)) = L.lemma_unsnoc_snoc l; L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)]; L.unsnoc l let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' < L.length l)) = fst (unsnoc l) let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l) [@@"opaque_to_smt"] let snoc (#a: Type) (l: list a) (x: a) : Pure (list a) (requires True) (ensures (fun l' -> Cons? l' /\ unsnoc_hd l' == l /\ unsnoc_tl l' == x )) = let l' = L.snoc (l, x) in L.append_length l [x]; snoc_inj l (unsnoc_hd l') x (unsnoc_tl l'); l' let snoc_unsnoc (#a: Type) (l: list a) : Lemma (requires (Cons? l)) (ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l)) = () unfold let coerce (#a: Type) (x: a) (b: Type) : Pure b (requires (a == b)) (ensures (fun y -> a == b /\ x == y)) = x (* END library *) let t a = cllist_lvalue a let v (a: Type0) = list a let datas (#a: Type0) (l: v a) : Tot (list a) = l (* view from the tail *) let llist_fragment_tail_cons_data_refine (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (d: a) : Tot prop = d == unsnoc_tl (Ghost.reveal l) [@@ __steel_reduce__] let llist_fragment_tail_cons_lvalue_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (c: ccell_lvalue a) : Tot vprop = vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l let ccell_is_lvalue_refine (a: Type) (c: ccell_ptrvalue a) : Tot prop = ccell_ptrvalue_is_null c == false [@@ __steel_reduce__ ] let llist_fragment_tail_cons_next_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (ptail: ref (ccell_ptrvalue a)) : Tot vprop = vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l [@@ __steel_reduce__ ] let llist_fragment_tail_cons_rewrite (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) }) (x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l)))) : Tot (ref (ccell_ptrvalue a)) = let (| _, (| c, _ |) |) = x in ccell_next c let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop (requires True) (ensures (fun v -> t_of v == ref (ccell_ptrvalue a))) (decreases (Ghost.reveal (L.length l))) = if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) let llist_fragment_tail_eq (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) = assert_norm (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) let llist_fragment_tail_eq_cons (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (requires (Cons? l)) (ensures (Cons? l /\ llist_fragment_tail l phead == ( llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) ))) = llist_fragment_tail_eq l phead unfold let sel_llist_fragment_tail (#a:Type) (#p:vprop) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) }) : GTot (ref (ccell_ptrvalue a)) = coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a)) val intro_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened emp (fun _ -> llist_fragment_tail l phead) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead) let intro_llist_fragment_tail_nil l phead = intro_vconst phead; change_equal_slprop (vconst phead) (llist_fragment_tail l phead) val elim_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_tail l phead) (fun _ -> emp) (fun _ -> Nil? l) (fun h _ _ -> sel_llist_fragment_tail l phead h == phead) let elim_llist_fragment_tail_nil l phead = change_equal_slprop (llist_fragment_tail l phead) (vconst phead); elim_vconst phead val intro_llist_fragment_tail_snoc (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (ptail: Ghost.erased (ref (ccell_ptrvalue a))) (tail: Ghost.erased (ccell_lvalue a)) : SteelGhost (Ghost.erased (list a)) opened (llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail)) (fun res -> llist_fragment_tail res phead) (fun h -> sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\ sel ptail h == Ghost.reveal tail ) (fun h res h' -> Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\ sel_llist_fragment_tail res phead h' == ccell_next tail ) #push-options "--z3rlimit 16" let intro_llist_fragment_tail_snoc #_ #a l phead ptail tail = let d = gget (vptr (ccell_data tail)) in let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l'); intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a); intro_vdep (vptr ptail `vrefine` ccell_is_lvalue_refine a) (vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l') (llist_fragment_tail_cons_lvalue_payload l'); change_equal_slprop (llist_fragment_tail l phead) (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead); intro_vdep (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead) (vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l') (llist_fragment_tail_cons_next_payload l'); intro_vrewrite_no_norm (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l') (llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)); llist_fragment_tail_eq_cons l' phead; change_equal_slprop (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)) (llist_fragment_tail l' phead); let g' = gget (llist_fragment_tail l' phead) in assert (Ghost.reveal g' == ccell_next tail); noop (); l' #pop-options [@@erasable] noeq type ll_unsnoc_t (a: Type) = { ll_unsnoc_l: list a; ll_unsnoc_ptail: ref (ccell_ptrvalue a); ll_unsnoc_tail: ccell_lvalue a; } val elim_llist_fragment_tail_snoc (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost (ll_unsnoc_t a) opened (llist_fragment_tail l phead) (fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail)) (fun _ -> Cons? l) (fun h res h' -> Cons? l /\ Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\ sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\ sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\ sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\ sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail) ) #push-options "--z3rlimit 32" #restart-solver let elim_llist_fragment_tail_snoc #_ #a l phead = let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in llist_fragment_tail_eq_cons l0 phead; change_equal_slprop (llist_fragment_tail l phead) (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)); elim_vrewrite_no_norm (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0) (llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)); let ptail = elim_vdep (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead) (llist_fragment_tail_cons_next_payload l0) in let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in change_equal_slprop (llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail)) (vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0); let tail = elim_vdep (vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a) (llist_fragment_tail_cons_lvalue_payload l0) in elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a); let res = { ll_unsnoc_l = unsnoc_hd l0; ll_unsnoc_ptail = Ghost.reveal ptail0; ll_unsnoc_tail = Ghost.reveal tail; } in change_equal_slprop (vptr (Ghost.reveal ptail0)) (vptr res.ll_unsnoc_ptail); change_equal_slprop (llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail)) (vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0); elim_vrefine (vptr (ccell_data res.ll_unsnoc_tail)) (llist_fragment_tail_cons_data_refine l0); change_equal_slprop (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead) (llist_fragment_tail res.ll_unsnoc_l phead); res #pop-options let rec llist_fragment_tail_append (#opened: _) (#a: Type) (phead0: ref (ccell_ptrvalue a)) (l1: Ghost.erased (list a)) (phead1: Ghost.erased (ref (ccell_ptrvalue a))) (l2: Ghost.erased (list a)) : SteelGhost (Ghost.erased (list a)) opened (llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1) (fun res -> llist_fragment_tail res phead0) (fun h -> Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h ) (fun h res h' -> Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\ (sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h ) (decreases (L.length (Ghost.reveal l2))) = let g1 = gget (llist_fragment_tail l1 phead0) in assert (Ghost.reveal phead1 == Ghost.reveal g1); if Nil? l2 then begin L.append_l_nil (Ghost.reveal l1); elim_llist_fragment_tail_nil l2 phead1; l1 end else begin let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d]; let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail end let queue_tail_refine (#a: Type) (tail1: ref (ccell_ptrvalue a)) (tail2: ref (ccell_ptrvalue a)) (tl: normal (t_of (vptr tail2))) : Tot prop = ccell_ptrvalue_is_null tl == true /\ tail1 == tail2 [@@__steel_reduce__] let queue_tail_dep2 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail1: t_of (llist_fragment_tail l (cllist_head x))) (tail2: ref (ccell_ptrvalue a)) : Tot vprop = vptr tail2 `vrefine` queue_tail_refine tail1 tail2 [@@__steel_reduce__] let queue_tail_dep1 (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail1: t_of (llist_fragment_tail l (cllist_head x))) : Tot vprop = vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail1 [@@__steel_reduce__; __reduce__] let queue_tail (#a: Type) (x: t a) (l: Ghost.erased (list a)) : Tot vprop = llist_fragment_tail l (cllist_head x) `vdep` queue_tail_dep1 x l val intro_queue_tail (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) (tail: ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail) (fun _ -> queue_tail x l) (fun h -> sel_llist_fragment_tail l (cllist_head x) h == tail /\ sel (cllist_tail x) h == tail /\ ccell_ptrvalue_is_null (sel tail h) ) (fun _ _ _ -> True) let intro_queue_tail x l tail = intro_vrefine (vptr tail) (queue_tail_refine tail tail); intro_vdep2 (vptr (cllist_tail x)) (vptr tail `vrefine` queue_tail_refine tail tail) tail (queue_tail_dep2 x l tail); intro_vdep2 (llist_fragment_tail l (cllist_head x)) (vptr (cllist_tail x) `vdep` queue_tail_dep2 x l tail) tail (queue_tail_dep1 x l) val elim_queue_tail (#opened: _) (#a: Type) (x: t a) (l: Ghost.erased (list a)) : SteelGhost (Ghost.erased (ref (ccell_ptrvalue a))) opened (queue_tail x l) (fun tail -> llist_fragment_tail l (cllist_head x) `star` vptr (cllist_tail x) `star` vptr tail) (fun h -> True) (fun _ tail h -> sel_llist_fragment_tail l (cllist_head x) h == Ghost.reveal tail /\ sel (cllist_tail x) h == Ghost.reveal tail /\ ccell_ptrvalue_is_null (h (vptr tail)) )
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "CQueue.LList.fsti.checked" ], "interface_file": true, "source_file": "CQueue.fst" }
[ { "abbrev": false, "full_module": "CQueue.LList", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "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.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: CQueue.t a -> l: FStar.Ghost.erased (Prims.list a) -> Steel.Effect.Atomic.SteelGhost (FStar.Ghost.erased (Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a)))
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "CQueue.t", "FStar.Ghost.erased", "Prims.list", "Steel.Reference.ref", "CQueue.Cell.ccell_ptrvalue", "Prims.unit", "Steel.Effect.Atomic.change_equal_slprop", "Steel.Reference.vptr", "FStar.Ghost.reveal", "Steel.Effect.Atomic.elim_vrefine", "CQueue.queue_tail_refine", "Steel.Effect.Common.t_of", "CQueue.llist_fragment_tail", "CQueue.LList.cllist_head", "CQueue.queue_tail_dep2", "CQueue.LList.cllist_tail", "Steel.Effect.Common.vrefine", "Steel.Effect.Common.VUnit", "Steel.Reference.vptr'", "Steel.FractionalPermission.full_perm", "Steel.Effect.Atomic.elim_vdep", "CQueue.queue_tail_dep1", "Steel.Effect.Common.vdep" ]
[]
false
true
false
false
false
let elim_queue_tail #_ #a x l =
let tail0 = elim_vdep (llist_fragment_tail l (cllist_head x)) (queue_tail_dep1 x l) in let tail:Ghost.erased (ref (ccell_ptrvalue a)) = tail0 in change_equal_slprop (queue_tail_dep1 x l (Ghost.reveal tail0)) ((vptr (cllist_tail x)) `vdep` (queue_tail_dep2 x l tail0)); let tail2 = elim_vdep (vptr (cllist_tail x)) (queue_tail_dep2 x l tail0) in let tail3:Ghost.erased (ref (ccell_ptrvalue a)) = tail2 in change_equal_slprop (queue_tail_dep2 x l tail0 (Ghost.reveal tail2)) ((vptr tail3) `vrefine` (queue_tail_refine tail0 tail3)); elim_vrefine (vptr tail3) (queue_tail_refine tail0 tail3); change_equal_slprop (vptr tail3) (vptr tail); tail
false
Vale.AES.AES_helpers.fst
Vale.AES.AES_helpers.lemma_add_0x1000000_reverse_mult
val lemma_add_0x1000000_reverse_mult (n: nat32) (increment: nat) : Lemma (requires (n % 256) + increment < 256) (ensures (let r = reverse_bytes_nat32 n in r + increment * 0x1000000 == reverse_bytes_nat32 (n + increment)))
val lemma_add_0x1000000_reverse_mult (n: nat32) (increment: nat) : Lemma (requires (n % 256) + increment < 256) (ensures (let r = reverse_bytes_nat32 n in r + increment * 0x1000000 == reverse_bytes_nat32 (n + increment)))
let lemma_add_0x1000000_reverse_mult (n:nat32) (increment:nat) : Lemma (requires (n % 256) + increment < 256) (ensures (let r = reverse_bytes_nat32 n in r + increment * 0x1000000 == reverse_bytes_nat32 (n + increment))) = let r = reverse_bytes_nat32 n in assert_norm (Vale.Def.Words.Four_s.nat_to_four 8 (n+increment) == Mkfour ((n+increment) % 0x100) (((n+increment) / 0x100) % 0x100) (((n+increment) / 0x10000) % 0x100) (((n+increment) / 0x1000000) % 0x100)); assert ((n+increment) / 0x1000000 == n / 0x1000000); assert ((n+increment) / 0x10000 == n / 0x10000); assert ((n+increment) / 0x100 == n / 0x100); assert (Vale.Def.Words.Four_s.nat_to_four 8 (n+increment) == Mkfour ((n+increment) % 0x100) ((n / 0x100) % 0x100) ((n / 0x10000) % 0x100) ((n / 0x1000000) % 0x100)); assert_norm (Vale.Def.Words.Four_s.nat_to_four 8 n == Mkfour (n % 0x100) ((n / 0x100) % 0x100) ((n / 0x10000) % 0x100) ((n / 0x1000000) % 0x100)); let s = Vale.Def.Words.Seq_s.four_to_seq_BE (Vale.Def.Words.Four_s.nat_to_four 8 n) in let r_s = Vale.Lib.Seqs_s.reverse_seq s in assert_norm (be_bytes_to_nat32 r_s == ((n / 0x1000000) % 0x100) + ((n / 0x10000) % 0x100) * 0x100 + ((n / 0x100) % 0x100) * 0x10000 + (n % 0x100) * 0x1000000); let s' = Vale.Def.Words.Seq_s.four_to_seq_BE (Vale.Def.Words.Four_s.nat_to_four 8 (n+increment)) in let r_s' = Vale.Lib.Seqs_s.reverse_seq s' in assert_norm (be_bytes_to_nat32 r_s' == (((n) / 0x1000000) % 0x100) + (((n) / 0x10000) % 0x100) * 0x100 + (((n) / 0x100) % 0x100) * 0x10000 + ((n+increment) % 0x100) * 0x1000000); assert (be_bytes_to_nat32 r_s + increment * 0x1000000 == be_bytes_to_nat32 r_s'); calc (==) { r; == { reverse_bytes_nat32_reveal () } be_bytes_to_nat32 r_s; }; calc (==) { reverse_bytes_nat32 (n+increment); == { reverse_bytes_nat32_reveal () } be_bytes_to_nat32 (Vale.Lib.Seqs_s.reverse_seq (nat32_to_be_bytes (n+increment))); }; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.AES_helpers.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 135, "start_col": 0, "start_line": 98 }
module Vale.AES.AES_helpers open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open FStar.Mul #reset-options "--initial_fuel 4 --max_fuel 4 --max_ifuel 0" let lemma_expand_key_128_0 (key:aes_key_LE AES_128) = expand_key_reveal () #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 10" let lemma_expand_key_128_i (key:aes_key_LE AES_128) (i:nat) = expand_key_reveal (); let n = 4 * i in // unfold expand_key 4 times (could use fuel, but that unfolds everything): let _ = expand_key AES_128 key (n + 1) in let _ = expand_key AES_128 key (n + 2) in let _ = expand_key AES_128 key (n + 3) in () #reset-options // expand_key for large 'size' argument agrees with expand_key for smaller 'size' argument let rec lemma_expand_append (key:aes_key_LE AES_128) (size1:nat) (size2:nat) = expand_key_reveal (); if size1 < size2 then lemma_expand_append key size1 (size2 - 1) #reset-options "--initial_fuel 1 --max_fuel 1 --max_ifuel 0 --z3rlimit 40 --using_facts_from '* -FStar.Seq.Properties'" #restart-solver // quad32 key expansion is equivalent to nat32 key expansion let rec lemma_expand_key_128 (key:seq nat32) (size:nat) = expand_key_128_reveal (); lemma_expand_append key (4 * size) 44; if size = 0 then () else ( let i = size - 1 in lemma_expand_append key (4 * i) 44; lemma_expand_key_128 key i; if i = 0 then lemma_expand_key_128_0 key else lemma_expand_key_128_i key i ) #reset-options // SIMD version of round_key_128 is equivalent to scalar round_key_128 #push-options "--max_fuel 3 --initial_fuel 3 --max_ifuel 3 --initial_ifuel 3" // REVIEW: Why do we need this? let lemma_simd_round_key (prev:quad32) (rcon:nat32) = quad32_xor_reveal (); reverse_bytes_nat32_reveal (); commute_rot_word_sub_word prev.hi3; Vale.Arch.Types.xor_lemmas () #pop-options let commute_sub_bytes_shift_rows_forall () = FStar.Classical.forall_intro commute_sub_bytes_shift_rows let init_rounds_opaque (init:quad32) (round_keys:seq quad32) = eval_rounds_reveal () #push-options "--max_ifuel 2 --initial_ifuel 2" // REVIEW: Why do we need this? Extra inversion to deal with opaque? let finish_cipher (alg:algorithm) (input:quad32) (round_keys:seq quad32) = eval_rounds_reveal (); eval_cipher_reveal (); commute_sub_bytes_shift_rows_forall() let finish_cipher_opt (alg:algorithm) (input plain t0 t1 out:quad32) (round_keys:seq quad32) : Lemma (requires length round_keys == (nr alg) + 1 /\ length round_keys > 0 /\ nr alg > 1 /\ // REVIEW: Why are these needed? t0 = quad32_xor input (index round_keys 0) /\ t1 = eval_rounds t0 round_keys (nr alg - 1) /\ out = quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor plain (index round_keys (nr alg)))) (ensures out == quad32_xor plain (eval_cipher alg input round_keys)) = calc (==) { out; == {} // From requires quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor plain (index round_keys (nr alg))); == { Vale.Arch.TypesNative.lemma_quad32_xor_commutes plain (index round_keys (nr alg)) } quad32_xor (sub_bytes (shift_rows_LE t1)) (quad32_xor (index round_keys (nr alg)) plain); == { Vale.Arch.TypesNative.lemma_quad32_xor_associates (sub_bytes (shift_rows_LE t1)) (index round_keys (nr alg)) plain } quad32_xor (quad32_xor (sub_bytes (shift_rows_LE t1)) (index round_keys (nr alg))) plain; == { eval_rounds_reveal (); eval_cipher_reveal (); commute_sub_bytes_shift_rows_forall(); quad32_xor_reveal () } quad32_xor (eval_cipher alg input round_keys) plain; == { Vale.Arch.TypesNative.lemma_quad32_xor_commutes plain (eval_cipher alg input round_keys) } quad32_xor plain (eval_cipher alg input round_keys); }; () #pop-options
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs_s.fst.checked", "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.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.AES_helpers.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "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_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_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": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Vale.Def.Types_s.nat32 -> increment: Prims.nat -> FStar.Pervasives.Lemma (requires n % 256 + increment < 256) (ensures (let r = Vale.Def.Types_s.reverse_bytes_nat32 n in r + increment * 0x1000000 == Vale.Def.Types_s.reverse_bytes_nat32 (n + increment)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.nat32", "Prims.nat", "Prims.unit", "FStar.Calc.calc_finish", "Prims.eq2", "Vale.Def.Types_s.reverse_bytes_nat32", "Prims.op_Addition", "Vale.Def.Types_s.be_bytes_to_nat32", "Vale.Lib.Seqs_s.reverse_seq", "Vale.Def.Types_s.nat8", "Vale.Def.Types_s.nat32_to_be_bytes", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Vale.Def.Types_s.reverse_bytes_nat32_reveal", "Prims.squash", "Prims._assert", "Prims.int", "FStar.Mul.op_Star", "FStar.Pervasives.assert_norm", "Prims.op_Modulus", "Prims.op_Division", "FStar.Seq.Base.seq", "Vale.Def.Words_s.natN", "Prims.pow2", "Vale.Def.Words.Seq_s.seq4", "Vale.Def.Words.Seq_s.four_to_seq_BE", "Vale.Def.Words.Four_s.nat_to_four", "Vale.Def.Words_s.four", "Vale.Def.Words_s.Mkfour", "Vale.Def.Words_s.nat32", "Prims.b2t", "Prims.op_LessThan", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let lemma_add_0x1000000_reverse_mult (n: nat32) (increment: nat) : Lemma (requires (n % 256) + increment < 256) (ensures (let r = reverse_bytes_nat32 n in r + increment * 0x1000000 == reverse_bytes_nat32 (n + increment))) =
let r = reverse_bytes_nat32 n in assert_norm (Vale.Def.Words.Four_s.nat_to_four 8 (n + increment) == Mkfour ((n + increment) % 0x100) (((n + increment) / 0x100) % 0x100) (((n + increment) / 0x10000) % 0x100) (((n + increment) / 0x1000000) % 0x100)); assert ((n + increment) / 0x1000000 == n / 0x1000000); assert ((n + increment) / 0x10000 == n / 0x10000); assert ((n + increment) / 0x100 == n / 0x100); assert (Vale.Def.Words.Four_s.nat_to_four 8 (n + increment) == Mkfour ((n + increment) % 0x100) ((n / 0x100) % 0x100) ((n / 0x10000) % 0x100) ((n / 0x1000000) % 0x100)); assert_norm (Vale.Def.Words.Four_s.nat_to_four 8 n == Mkfour (n % 0x100) ((n / 0x100) % 0x100) ((n / 0x10000) % 0x100) ((n / 0x1000000) % 0x100)); let s = Vale.Def.Words.Seq_s.four_to_seq_BE (Vale.Def.Words.Four_s.nat_to_four 8 n) in let r_s = Vale.Lib.Seqs_s.reverse_seq s in assert_norm (be_bytes_to_nat32 r_s == ((n / 0x1000000) % 0x100) + ((n / 0x10000) % 0x100) * 0x100 + ((n / 0x100) % 0x100) * 0x10000 + (n % 0x100) * 0x1000000); let s' = Vale.Def.Words.Seq_s.four_to_seq_BE (Vale.Def.Words.Four_s.nat_to_four 8 (n + increment)) in let r_s' = Vale.Lib.Seqs_s.reverse_seq s' in assert_norm (be_bytes_to_nat32 r_s' == (((n) / 0x1000000) % 0x100) + (((n) / 0x10000) % 0x100) * 0x100 + (((n) / 0x100) % 0x100) * 0x10000 + ((n + increment) % 0x100) * 0x1000000); assert (be_bytes_to_nat32 r_s + increment * 0x1000000 == be_bytes_to_nat32 r_s'); calc ( == ) { r; ( == ) { reverse_bytes_nat32_reveal () } be_bytes_to_nat32 r_s; }; calc ( == ) { reverse_bytes_nat32 (n + increment); ( == ) { reverse_bytes_nat32_reveal () } be_bytes_to_nat32 (Vale.Lib.Seqs_s.reverse_seq (nat32_to_be_bytes (n + increment))); }; ()
false
CQueue.fst
CQueue.llist_fragment_tail_append
val llist_fragment_tail_append (#opened: _) (#a: Type) (phead0: ref (ccell_ptrvalue a)) (l1: Ghost.erased (list a)) (phead1: Ghost.erased (ref (ccell_ptrvalue a))) (l2: Ghost.erased (list a)) : SteelGhost (Ghost.erased (list a)) opened ((llist_fragment_tail l1 phead0) `star` (llist_fragment_tail l2 phead1)) (fun res -> llist_fragment_tail res phead0) (fun h -> Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h) (fun h res h' -> Ghost.reveal res == (Ghost.reveal l1) `L.append` (Ghost.reveal l2) /\ (sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h) (decreases (L.length (Ghost.reveal l2)))
val llist_fragment_tail_append (#opened: _) (#a: Type) (phead0: ref (ccell_ptrvalue a)) (l1: Ghost.erased (list a)) (phead1: Ghost.erased (ref (ccell_ptrvalue a))) (l2: Ghost.erased (list a)) : SteelGhost (Ghost.erased (list a)) opened ((llist_fragment_tail l1 phead0) `star` (llist_fragment_tail l2 phead1)) (fun res -> llist_fragment_tail res phead0) (fun h -> Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h) (fun h res h' -> Ghost.reveal res == (Ghost.reveal l1) `L.append` (Ghost.reveal l2) /\ (sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h) (decreases (L.length (Ghost.reveal l2)))
let rec llist_fragment_tail_append (#opened: _) (#a: Type) (phead0: ref (ccell_ptrvalue a)) (l1: Ghost.erased (list a)) (phead1: Ghost.erased (ref (ccell_ptrvalue a))) (l2: Ghost.erased (list a)) : SteelGhost (Ghost.erased (list a)) opened (llist_fragment_tail l1 phead0 `star` llist_fragment_tail l2 phead1) (fun res -> llist_fragment_tail res phead0) (fun h -> Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h ) (fun h res h' -> Ghost.reveal res == Ghost.reveal l1 `L.append` Ghost.reveal l2 /\ (sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h ) (decreases (L.length (Ghost.reveal l2))) = let g1 = gget (llist_fragment_tail l1 phead0) in assert (Ghost.reveal phead1 == Ghost.reveal g1); if Nil? l2 then begin L.append_l_nil (Ghost.reveal l1); elim_llist_fragment_tail_nil l2 phead1; l1 end else begin let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d]; let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail end
{ "file_name": "share/steel/examples/steel/CQueue.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 5, "end_line": 629, "start_col": 0, "start_line": 597 }
module CQueue open CQueue.LList #set-options "--ide_id_info_off" //Re-define squash, since this module explicitly //replies on proving equalities of the form `t_of v == squash p` //which are delicate in the presence of optimizations that //unfold `Prims.squash (p /\ q)`to _:unit{p /\ q} //See Issue #2496 let squash (p:Type u#a) : Type0 = squash p (* BEGIN library *) let intro_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: (t_of v) -> GTot t) : SteelGhost unit opened v (fun _ -> vrewrite v f) (fun _ -> True) (fun h _ h' -> h' (vrewrite v f) == f (h v)) = intro_vrewrite v f let elim_vrewrite_no_norm (#opened:inames) (v: vprop) (#t: Type) (f: ((t_of v) -> GTot t)) : SteelGhost unit opened (vrewrite v f) (fun _ -> v) (fun _ -> True) (fun h _ h' -> h (vrewrite v f) == f (h' v)) = elim_vrewrite v f let vconst_sel (#a: Type) (x: a) : Tot (selector a (hp_of emp)) = fun _ -> x [@@ __steel_reduce__] let vconst' (#a: Type) (x: a) : GTot vprop' = { hp = hp_of emp; t = a; sel = vconst_sel x; } [@@ __steel_reduce__] let vconst (#a: Type) (x: a) : Tot vprop = VUnit (vconst' x) let intro_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened emp (fun _ -> vconst x) (fun _ -> True) (fun _ _ h' -> h' (vconst x) == x) = change_slprop_rel emp (vconst x) (fun _ y -> y == x) (fun _ -> ()) let elim_vconst (#opened: _) (#a: Type) (x: a) : SteelGhost unit opened (vconst x) (fun _ -> emp) (fun _ -> True) (fun h _ _ -> h (vconst x) == x) = change_slprop_rel (vconst x) emp (fun y _ -> y == x) (fun _ -> ()) let vpure_sel' (p: prop) : Tot (selector' (squash p) (Steel.Memory.pure p)) = fun (m: Steel.Memory.hmem (Steel.Memory.pure p)) -> pure_interp p m let vpure_sel (p: prop) : Tot (selector (squash p) (Steel.Memory.pure p)) = vpure_sel' p [@@ __steel_reduce__] let vpure' (p: prop) : GTot vprop' = { hp = Steel.Memory.pure p; t = squash p; sel = vpure_sel p; } [@@ __steel_reduce__] let vpure (p: prop) : Tot vprop = VUnit (vpure' p) let intro_vpure (#opened: _) (p: prop) : SteelGhost unit opened emp (fun _ -> vpure p) (fun _ -> p) (fun _ _ h' -> p) = change_slprop_rel emp (vpure p) (fun _ _ -> p) (fun m -> pure_interp p m) let elim_vpure (#opened: _) (p: prop) : SteelGhost unit opened (vpure p) (fun _ -> emp) (fun _ -> True) (fun _ _ _ -> p) = change_slprop_rel (vpure p) emp (fun _ _ -> p) (fun m -> pure_interp p m; reveal_emp (); intro_emp m) val intro_vdep2 (#opened:inames) (v: vprop) (q: vprop) (x: t_of v) (p: (t_of v -> Tot vprop)) : SteelGhost unit opened (v `star` q) (fun _ -> vdep v p) (requires (fun h -> q == p x /\ x == h v )) (ensures (fun h _ h' -> let x2 = h' (vdep v p) in q == p (h v) /\ dfst x2 == (h v) /\ dsnd x2 == (h q) )) let intro_vdep2 v q x p = intro_vdep v q p let vbind0_payload (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: t_of a) : Tot vprop = vpure (t == t_of (b x)) `star` b x let vbind0_rewrite (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) (x: normal (t_of (vdep a (vbind0_payload a t b)))) : Tot t = snd (dsnd x) [@@__steel_reduce__; __reduce__] let vbind0 (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = a `vdep` vbind0_payload a t b `vrewrite` vbind0_rewrite a t b let vbind_hp // necessary to hide the attribute on hp_of (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot (slprop u#1) = hp_of (vbind0 a t b) let vbind_sel // same for hp_sel (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot (selector t (vbind_hp a t b)) = sel_of (vbind0 a t b) [@@__steel_reduce__] let vbind' (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : GTot vprop' = { hp = vbind_hp a t b; t = t; sel = vbind_sel a t b; } [@@__steel_reduce__] let vbind (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : Tot vprop = VUnit (vbind' a t b) let intro_vbind (#opened: _) (a: vprop) (b' : vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost unit opened (a `star` b') (fun _ -> vbind a t b) (fun h -> t_of b' == t /\ b' == b (h a)) (fun h _ h' -> t_of b' == t /\ b' == b (h a) /\ h' (vbind a t b) == h b' ) = intro_vpure (t == t_of b'); intro_vdep a (vpure (t == t_of b') `star` b') (vbind0_payload a t b); intro_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); change_slprop_rel (vbind0 a t b) (vbind a t b) (fun x y -> x == y) (fun _ -> ()) let elim_vbind (#opened: _) (a: vprop) (t: Type0) (b: (t_of a -> Tot vprop)) : SteelGhost (Ghost.erased (t_of a)) opened (vbind a t b) (fun res -> a `star` b (Ghost.reveal res)) (fun h -> True) (fun h res h' -> h' a == Ghost.reveal res /\ t == t_of (b (Ghost.reveal res)) /\ h' (b (Ghost.reveal res)) == h (vbind a t b) ) = change_slprop_rel (vbind a t b) (vbind0 a t b) (fun x y -> x == y) (fun _ -> ()); elim_vrewrite (a `vdep` vbind0_payload a t b) (vbind0_rewrite a t b); let res = elim_vdep a (vbind0_payload a t b) in change_equal_slprop (vbind0_payload a t b (Ghost.reveal res)) (vpure (t == t_of (b (Ghost.reveal res))) `star` b (Ghost.reveal res)); elim_vpure (t == t_of (b (Ghost.reveal res))); res let (==) (#a:_) (x y: a) : prop = x == y let snoc_inj (#a: Type) (hd1 hd2: list a) (tl1 tl2: a) : Lemma (requires (hd1 `L.append` [tl1] == hd2 `L.append` [tl2])) (ensures (hd1 == hd2 /\ tl1 == tl2)) [SMTPat (hd1 `L.append` [tl1]); SMTPat (hd2 `L.append` [tl2])] = L.lemma_snoc_unsnoc (hd1, tl1); L.lemma_snoc_unsnoc (hd2, tl2) [@"opaque_to_smt"] let unsnoc (#a: Type) (l: list a) : Pure (list a & a) (requires (Cons? l)) (ensures (fun (hd, tl) -> l == hd `L.append` [tl] /\ L.length hd < L.length l)) = L.lemma_unsnoc_snoc l; L.append_length (fst (L.unsnoc l)) [snd (L.unsnoc l)]; L.unsnoc l let unsnoc_hd (#a: Type) (l: list a) : Pure (list a) (requires (Cons? l)) (ensures (fun l' -> L.length l' < L.length l)) = fst (unsnoc l) let unsnoc_tl (#a: Type) (l: list a) : Pure (a) (requires (Cons? l)) (ensures (fun _ -> True)) = snd (unsnoc l) [@@"opaque_to_smt"] let snoc (#a: Type) (l: list a) (x: a) : Pure (list a) (requires True) (ensures (fun l' -> Cons? l' /\ unsnoc_hd l' == l /\ unsnoc_tl l' == x )) = let l' = L.snoc (l, x) in L.append_length l [x]; snoc_inj l (unsnoc_hd l') x (unsnoc_tl l'); l' let snoc_unsnoc (#a: Type) (l: list a) : Lemma (requires (Cons? l)) (ensures (snoc (unsnoc_hd l) (unsnoc_tl l) == l)) = () unfold let coerce (#a: Type) (x: a) (b: Type) : Pure b (requires (a == b)) (ensures (fun y -> a == b /\ x == y)) = x (* END library *) let t a = cllist_lvalue a let v (a: Type0) = list a let datas (#a: Type0) (l: v a) : Tot (list a) = l (* view from the tail *) let llist_fragment_tail_cons_data_refine (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (d: a) : Tot prop = d == unsnoc_tl (Ghost.reveal l) [@@ __steel_reduce__] let llist_fragment_tail_cons_lvalue_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (c: ccell_lvalue a) : Tot vprop = vptr (ccell_data c) `vrefine` llist_fragment_tail_cons_data_refine l let ccell_is_lvalue_refine (a: Type) (c: ccell_ptrvalue a) : Tot prop = ccell_ptrvalue_is_null c == false [@@ __steel_reduce__ ] let llist_fragment_tail_cons_next_payload (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (ptail: ref (ccell_ptrvalue a)) : Tot vprop = vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l [@@ __steel_reduce__ ] let llist_fragment_tail_cons_rewrite (#a: Type) (l: Ghost.erased (list a) { Cons? (Ghost.reveal l) }) (llist_fragment_tail: vprop { t_of llist_fragment_tail == ref (ccell_ptrvalue a) }) (x: normal (t_of (llist_fragment_tail `vdep` (llist_fragment_tail_cons_next_payload l)))) : Tot (ref (ccell_ptrvalue a)) = let (| _, (| c, _ |) |) = x in ccell_next c let rec llist_fragment_tail (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Pure vprop (requires True) (ensures (fun v -> t_of v == ref (ccell_ptrvalue a))) (decreases (Ghost.reveal (L.length l))) = if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) let llist_fragment_tail_eq (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) = assert_norm (llist_fragment_tail l phead == ( if Nil? l then vconst phead else llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) )) let llist_fragment_tail_eq_cons (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : Lemma (requires (Cons? l)) (ensures (Cons? l /\ llist_fragment_tail l phead == ( llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead `vdep` llist_fragment_tail_cons_next_payload l `vrewrite` llist_fragment_tail_cons_rewrite l (llist_fragment_tail (Ghost.hide (unsnoc_hd (Ghost.reveal l))) phead) ))) = llist_fragment_tail_eq l phead unfold let sel_llist_fragment_tail (#a:Type) (#p:vprop) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (h: rmem p { FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist_fragment_tail l phead) /\ True) }) : GTot (ref (ccell_ptrvalue a)) = coerce (h (llist_fragment_tail l phead)) (ref (ccell_ptrvalue a)) val intro_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened emp (fun _ -> llist_fragment_tail l phead) (fun _ -> Nil? l) (fun _ _ h' -> sel_llist_fragment_tail l phead h' == phead) let intro_llist_fragment_tail_nil l phead = intro_vconst phead; change_equal_slprop (vconst phead) (llist_fragment_tail l phead) val elim_llist_fragment_tail_nil (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost unit opened (llist_fragment_tail l phead) (fun _ -> emp) (fun _ -> Nil? l) (fun h _ _ -> sel_llist_fragment_tail l phead h == phead) let elim_llist_fragment_tail_nil l phead = change_equal_slprop (llist_fragment_tail l phead) (vconst phead); elim_vconst phead val intro_llist_fragment_tail_snoc (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) (ptail: Ghost.erased (ref (ccell_ptrvalue a))) (tail: Ghost.erased (ccell_lvalue a)) : SteelGhost (Ghost.erased (list a)) opened (llist_fragment_tail l phead `star` vptr ptail `star` vptr (ccell_data tail)) (fun res -> llist_fragment_tail res phead) (fun h -> sel_llist_fragment_tail l phead h == Ghost.reveal ptail /\ sel ptail h == Ghost.reveal tail ) (fun h res h' -> Ghost.reveal res == snoc (Ghost.reveal l) (sel (ccell_data tail) h) /\ sel_llist_fragment_tail res phead h' == ccell_next tail ) #push-options "--z3rlimit 16" let intro_llist_fragment_tail_snoc #_ #a l phead ptail tail = let d = gget (vptr (ccell_data tail)) in let l' : (l' : Ghost.erased (list a) { Cons? (Ghost.reveal l') }) = Ghost.hide (snoc (Ghost.reveal l) (Ghost.reveal d)) in intro_vrefine (vptr (ccell_data tail)) (llist_fragment_tail_cons_data_refine l'); intro_vrefine (vptr ptail) (ccell_is_lvalue_refine a); intro_vdep (vptr ptail `vrefine` ccell_is_lvalue_refine a) (vptr (ccell_data tail) `vrefine` llist_fragment_tail_cons_data_refine l') (llist_fragment_tail_cons_lvalue_payload l'); change_equal_slprop (llist_fragment_tail l phead) (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead); intro_vdep (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead) (vptr ptail `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l') (llist_fragment_tail_cons_next_payload l'); intro_vrewrite_no_norm (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l') (llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)); llist_fragment_tail_eq_cons l' phead; change_equal_slprop (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead `vdep` llist_fragment_tail_cons_next_payload l' `vrewrite` llist_fragment_tail_cons_rewrite l' (llist_fragment_tail (Ghost.hide (unsnoc_hd l')) phead)) (llist_fragment_tail l' phead); let g' = gget (llist_fragment_tail l' phead) in assert (Ghost.reveal g' == ccell_next tail); noop (); l' #pop-options [@@erasable] noeq type ll_unsnoc_t (a: Type) = { ll_unsnoc_l: list a; ll_unsnoc_ptail: ref (ccell_ptrvalue a); ll_unsnoc_tail: ccell_lvalue a; } val elim_llist_fragment_tail_snoc (#opened: _) (#a: Type) (l: Ghost.erased (list a)) (phead: ref (ccell_ptrvalue a)) : SteelGhost (ll_unsnoc_t a) opened (llist_fragment_tail l phead) (fun res -> llist_fragment_tail res.ll_unsnoc_l phead `star` vptr res.ll_unsnoc_ptail `star` vptr (ccell_data res.ll_unsnoc_tail)) (fun _ -> Cons? l) (fun h res h' -> Cons? l /\ Ghost.reveal res.ll_unsnoc_l == unsnoc_hd l /\ sel res.ll_unsnoc_ptail h' == res.ll_unsnoc_tail /\ sel (ccell_data res.ll_unsnoc_tail) h'== unsnoc_tl l /\ sel_llist_fragment_tail res.ll_unsnoc_l phead h' == res.ll_unsnoc_ptail /\ sel_llist_fragment_tail l phead h == (ccell_next res.ll_unsnoc_tail) ) #push-options "--z3rlimit 32" #restart-solver let elim_llist_fragment_tail_snoc #_ #a l phead = let l0 : (l0: Ghost.erased (list a) { Cons? l0 }) = Ghost.hide (Ghost.reveal l) in llist_fragment_tail_eq_cons l0 phead; change_equal_slprop (llist_fragment_tail l phead) (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0 `vrewrite` llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)); elim_vrewrite_no_norm (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead `vdep` llist_fragment_tail_cons_next_payload l0) (llist_fragment_tail_cons_rewrite l0 (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead)); let ptail = elim_vdep (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead) (llist_fragment_tail_cons_next_payload l0) in let ptail0 : Ghost.erased (ref (ccell_ptrvalue a)) = ptail in change_equal_slprop (llist_fragment_tail_cons_next_payload l0 (Ghost.reveal ptail)) (vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a `vdep` llist_fragment_tail_cons_lvalue_payload l0); let tail = elim_vdep (vptr (Ghost.reveal ptail0) `vrefine` ccell_is_lvalue_refine a) (llist_fragment_tail_cons_lvalue_payload l0) in elim_vrefine (vptr (Ghost.reveal ptail0)) (ccell_is_lvalue_refine a); let res = { ll_unsnoc_l = unsnoc_hd l0; ll_unsnoc_ptail = Ghost.reveal ptail0; ll_unsnoc_tail = Ghost.reveal tail; } in change_equal_slprop (vptr (Ghost.reveal ptail0)) (vptr res.ll_unsnoc_ptail); change_equal_slprop (llist_fragment_tail_cons_lvalue_payload l0 (Ghost.reveal tail)) (vptr (ccell_data res.ll_unsnoc_tail) `vrefine` llist_fragment_tail_cons_data_refine l0); elim_vrefine (vptr (ccell_data res.ll_unsnoc_tail)) (llist_fragment_tail_cons_data_refine l0); change_equal_slprop (llist_fragment_tail (Ghost.hide (unsnoc_hd l0)) phead) (llist_fragment_tail res.ll_unsnoc_l phead); res #pop-options
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Ghost.fsti.checked", "CQueue.LList.fsti.checked" ], "interface_file": true, "source_file": "CQueue.fst" }
[ { "abbrev": false, "full_module": "CQueue.LList", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "short_module": null }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "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.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
phead0: Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a) -> l1: FStar.Ghost.erased (Prims.list a) -> phead1: FStar.Ghost.erased (Steel.Reference.ref (CQueue.Cell.ccell_ptrvalue a)) -> l2: FStar.Ghost.erased (Prims.list a) -> Steel.Effect.Atomic.SteelGhost (FStar.Ghost.erased (Prims.list a))
Steel.Effect.Atomic.SteelGhost
[ "" ]
[]
[ "Steel.Memory.inames", "Steel.Reference.ref", "CQueue.Cell.ccell_ptrvalue", "FStar.Ghost.erased", "Prims.list", "Prims.uu___is_Nil", "FStar.Ghost.reveal", "Prims.unit", "CQueue.elim_llist_fragment_tail_nil", "FStar.List.Tot.Properties.append_l_nil", "Prims.bool", "CQueue.intro_llist_fragment_tail_snoc", "FStar.Ghost.hide", "CQueue.__proj__Mkll_unsnoc_t__item__ll_unsnoc_ptail", "CQueue.Cell.ccell_lvalue", "CQueue.__proj__Mkll_unsnoc_t__item__ll_unsnoc_tail", "CQueue.llist_fragment_tail_append", "CQueue.__proj__Mkll_unsnoc_t__item__ll_unsnoc_l", "FStar.List.Tot.Properties.append_assoc", "Prims.Cons", "Steel.Effect.Common.t_of", "Steel.Reference.vptr", "CQueue.Cell.ccell_data", "Prims.Nil", "Steel.Effect.Common.VUnit", "Steel.Reference.vptr'", "Steel.FractionalPermission.full_perm", "Steel.Effect.Atomic.gget", "CQueue.ll_unsnoc_t", "CQueue.elim_llist_fragment_tail_snoc", "Prims._assert", "CQueue.op_Equals_Equals", "CQueue.llist_fragment_tail", "Steel.Effect.Common.star", "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "CQueue.sel_llist_fragment_tail", "Prims.l_and", "FStar.List.Tot.Base.append" ]
[ "recursion" ]
false
true
false
false
false
let rec llist_fragment_tail_append (#opened: _) (#a: Type) (phead0: ref (ccell_ptrvalue a)) (l1: Ghost.erased (list a)) (phead1: Ghost.erased (ref (ccell_ptrvalue a))) (l2: Ghost.erased (list a)) : SteelGhost (Ghost.erased (list a)) opened ((llist_fragment_tail l1 phead0) `star` (llist_fragment_tail l2 phead1)) (fun res -> llist_fragment_tail res phead0) (fun h -> Ghost.reveal phead1 == (sel_llist_fragment_tail l1 phead0) h) (fun h res h' -> Ghost.reveal res == (Ghost.reveal l1) `L.append` (Ghost.reveal l2) /\ (sel_llist_fragment_tail res phead0) h' == (sel_llist_fragment_tail l2 phead1) h) (decreases (L.length (Ghost.reveal l2))) =
let g1 = gget (llist_fragment_tail l1 phead0) in assert (Ghost.reveal phead1 == Ghost.reveal g1); if Nil? l2 then (L.append_l_nil (Ghost.reveal l1); elim_llist_fragment_tail_nil l2 phead1; l1) else let res = elim_llist_fragment_tail_snoc l2 (Ghost.reveal phead1) in let d = gget (vptr (ccell_data res.ll_unsnoc_tail)) in L.append_assoc (Ghost.reveal l1) (Ghost.reveal res.ll_unsnoc_l) [Ghost.reveal d]; let l3 = llist_fragment_tail_append phead0 l1 phead1 res.ll_unsnoc_l in intro_llist_fragment_tail_snoc l3 phead0 res.ll_unsnoc_ptail res.ll_unsnoc_tail
false
Hacl.Spec.Poly1305.Lemmas.fst
Hacl.Spec.Poly1305.Lemmas.poly_update_repeat_blocks_multi_lemma4_simplify
val poly_update_repeat_blocks_multi_lemma4_simplify: a0:pfelem -> a1:pfelem -> a2:pfelem -> a3:pfelem -> c0:pfelem -> c1:pfelem -> c2:pfelem -> c3:pfelem -> r:pfelem -> r2:pfelem{r2 == r *% r} -> r4:pfelem {r4 == r2 *% r2} -> Lemma (((a0 *% r4 +% c0) *% r4) +% ((a1 *% r4 +% c1) *% (r2 *% r)) +% ((a2 *% r4 +% c2) *% r2) +% ((a3 *% r4 +% c3) *% r) == (((((((((((a0 *% r4 +% (a1 *% (r2 *% r))) +% a2 *% r2) +% a3 *% r) +% c0) *% r) +% c1) *% r) +% c2) *% r) +% c3) *% r) )
val poly_update_repeat_blocks_multi_lemma4_simplify: a0:pfelem -> a1:pfelem -> a2:pfelem -> a3:pfelem -> c0:pfelem -> c1:pfelem -> c2:pfelem -> c3:pfelem -> r:pfelem -> r2:pfelem{r2 == r *% r} -> r4:pfelem {r4 == r2 *% r2} -> Lemma (((a0 *% r4 +% c0) *% r4) +% ((a1 *% r4 +% c1) *% (r2 *% r)) +% ((a2 *% r4 +% c2) *% r2) +% ((a3 *% r4 +% c3) *% r) == (((((((((((a0 *% r4 +% (a1 *% (r2 *% r))) +% a2 *% r2) +% a3 *% r) +% c0) *% r) +% c1) *% r) +% c2) *% r) +% c3) *% r) )
let poly_update_repeat_blocks_multi_lemma4_simplify a0 a1 a2 a3 c0 c1 c2 c3 r r2 r4 = let r2 = r *% r in let r4 = r2 *% r2 in assert ( ((a0 *% r4 +% c0) *% r4) +% ((a1 *% r4 +% c1) *% (r2 *% r)) +% ((a2 *% r4 +% c2) *% r2) +% ((a3 *% r4 +% c3) *% r) == (((((((((((a0 *% r4 +% (a1 *% (r2 *% r))) +% a2 *% r2) +% a3 *% r) +% c0) *% r) +% c1) *% r) +% c2) *% r) +% c3) *% r) ) by (poly_semiring ())
{ "file_name": "code/poly1305/Hacl.Spec.Poly1305.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 167, "start_col": 0, "start_line": 154 }
module Hacl.Spec.Poly1305.Lemmas open FStar.Mul module Scalar = Spec.Poly1305 open FStar.Algebra.CommMonoid open FStar.Tactics.CanonCommSemiring /// Semiring for Poly1305 #set-options "--z3rlimit 5 --max_fuel 0 --max_ifuel 0 --z3cliopt smt.arith.nl=false" let prime: pos = Scalar.prime let pfelem : eqtype = a:nat{a < prime} [@canon_attr] let zero : pfelem = 0 [@canon_attr] let one : pfelem = normalize_term_spec prime; 1 //[@(strict_on_arguments [0;1])] let ( +% ) (a b:pfelem) : pfelem = (a + b) % prime //[@(strict_on_arguments [0;1])] let ( *% ) (a b:pfelem) : pfelem = (a * b) % prime //[@(strict_on_arguments [0])] let ( ~% ) (a:pfelem) : pfelem = (-a) % prime val add_identity: a:pfelem -> Lemma (zero +% a == a) let add_identity a = normalize_term_spec prime val mul_identity: a:pfelem -> Lemma (one *% a == a) let mul_identity a = normalize_term_spec prime val add_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a +% b +% c == a +% (b +% c)) let add_associativity a b c = normalize_term_spec prime; calc (==) { a +% b +% c; == { } ((a + b) % prime + c) % prime; == { Math.Lemmas.lemma_mod_plus_distr_l (a + b) c prime } ((a + b) + c) % prime; == { } (a + (b + c)) % prime; == { Math.Lemmas.lemma_mod_plus_distr_r a (b + c) prime } a +% (b +% c); } val add_commutativity: a:pfelem -> b:pfelem -> Lemma (a +% b == b +% a) let add_commutativity a b = () val mul_associativity: a:pfelem -> b:pfelem -> c:pfelem -> Lemma (a *% b *% c == a *% (b *% c)) let mul_associativity a b c = calc (==) { a *% b *% c; == { } (((a * b) % prime) * c) % prime; == { Math.Lemmas.lemma_mod_mul_distr_l (a * b) c prime } ((a * b) * c) % prime; == { Math.Lemmas.paren_mul_right a b c } (a * (b * c)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b * c) prime } (a * ((b * c) % prime)) % prime; == { } a *% (b *% c); } val mul_commutativity: a:pfelem -> b:pfelem -> Lemma (a *% b == b *% a) let mul_commutativity a b = () [@canon_attr] let pfelem_add_cm : cm pfelem = CM zero ( +% ) add_identity add_associativity add_commutativity [@canon_attr] let pfelem_mul_cm : cm pfelem = CM one ( *% ) mul_identity mul_associativity mul_commutativity val mul_add_distr: distribute_left_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_add_distr a b c = normalize_term_spec prime; calc (==) { a *% (b +% c); == { } (a * (b +% c)) % prime; == { Math.Lemmas.lemma_mod_add_distr a (b + c) prime } (a * ((b + c) % prime)) % prime; == { Math.Lemmas.lemma_mod_mul_distr_r a (b + c) prime } (a * (b + c)) % prime; == { Math.Lemmas.distributivity_add_right a b c } (a * b + a * c) % prime; == { Math.Lemmas.lemma_mod_add_distr (a * b) (a * c) prime } (a * b + a *% c) % prime; == { } (a *% c + a * b) % prime; == { Math.Lemmas.lemma_mod_add_distr (a *% c) (a * b) prime } (a *% c + a *% b) % prime; == { } (a *% b + a *% c) % prime; == { } a *% b +% a *% c; } val mul_zero_l: mult_zero_l_lemma pfelem pfelem_add_cm pfelem_mul_cm let mul_zero_l a = assert_norm (forall x. zero *% x == zero) val add_opp (a:pfelem) : Lemma (a +% ~%a == zero) let add_opp a = FStar.Math.Lemmas.lemma_mod_add_distr a (-a) prime; FStar.Math.Lemmas.small_mod 0 prime [@canon_attr] let pfelem_cr : cr pfelem = CR pfelem_add_cm pfelem_mul_cm ( ~% ) add_opp mul_add_distr mul_zero_l open FStar.Tactics let poly_semiring () : Tac unit = canon_semiring pfelem_cr; trefl() /// Lemmas val poly_update_repeat_blocks_multi_lemma2_simplify: acc0:pfelem -> acc1:pfelem -> c0:pfelem -> c1:pfelem -> r:pfelem -> Lemma ( (acc0 *% (r *% r) +% c0) *% (r *% r) +% (acc1 *% (r *% r) +% c1) *% r == ((((acc0 *% (r *% r) +% acc1 *% r) +% c0) *% r) +% c1) *% r ) let poly_update_repeat_blocks_multi_lemma2_simplify acc0 acc1 c0 c1 r = assert ( (acc0 *% (r *% r) +% c0) *% (r *% r) +% (acc1 *% (r *% r) +% c1) *% r == ((((acc0 *% (r *% r) +% acc1 *% r) +% c0) *% r) +% c1) *% r ) by (poly_semiring ()) val poly_update_repeat_blocks_multi_lemma4_simplify: a0:pfelem -> a1:pfelem -> a2:pfelem -> a3:pfelem -> c0:pfelem -> c1:pfelem -> c2:pfelem -> c3:pfelem -> r:pfelem -> r2:pfelem{r2 == r *% r} -> r4:pfelem {r4 == r2 *% r2} -> Lemma (((a0 *% r4 +% c0) *% r4) +% ((a1 *% r4 +% c1) *% (r2 *% r)) +% ((a2 *% r4 +% c2) *% r2) +% ((a3 *% r4 +% c3) *% r) == (((((((((((a0 *% r4 +% (a1 *% (r2 *% r))) +% a2 *% r2) +%
{ "checked_file": "/", "dependencies": [ "Spec.Poly1305.fst.checked", "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked", "FStar.Algebra.CommMonoid.fst.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Poly1305.Lemmas.fst" }
[ { "abbrev": false, "full_module": "FStar.Tactics", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra.CommMonoid", "short_module": null }, { "abbrev": true, "full_module": "Spec.Poly1305", "short_module": "Scalar" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a0: Hacl.Spec.Poly1305.Lemmas.pfelem -> a1: Hacl.Spec.Poly1305.Lemmas.pfelem -> a2: Hacl.Spec.Poly1305.Lemmas.pfelem -> a3: Hacl.Spec.Poly1305.Lemmas.pfelem -> c0: Hacl.Spec.Poly1305.Lemmas.pfelem -> c1: Hacl.Spec.Poly1305.Lemmas.pfelem -> c2: Hacl.Spec.Poly1305.Lemmas.pfelem -> c3: Hacl.Spec.Poly1305.Lemmas.pfelem -> r: Hacl.Spec.Poly1305.Lemmas.pfelem -> r2: Hacl.Spec.Poly1305.Lemmas.pfelem{r2 == r *% r} -> r4: Hacl.Spec.Poly1305.Lemmas.pfelem{r4 == r2 *% r2} -> FStar.Pervasives.Lemma (ensures (a0 *% r4 +% c0) *% r4 +% (a1 *% r4 +% c1) *% (r2 *% r) +% (a2 *% r4 +% c2) *% r2 +% (a3 *% r4 +% c3) *% r == ((((a0 *% r4 +% a1 *% (r2 *% r) +% a2 *% r2 +% a3 *% r +% c0) *% r +% c1) *% r +% c2) *% r +% c3) *% r)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Hacl.Spec.Poly1305.Lemmas.pfelem", "Prims.eq2", "Hacl.Spec.Poly1305.Lemmas.op_Star_Percent", "FStar.Tactics.Effect.assert_by_tactic", "Hacl.Spec.Poly1305.Lemmas.op_Plus_Percent", "Prims.unit", "Hacl.Spec.Poly1305.Lemmas.poly_semiring" ]
[]
false
false
true
false
false
let poly_update_repeat_blocks_multi_lemma4_simplify a0 a1 a2 a3 c0 c1 c2 c3 r r2 r4 =
let r2 = r *% r in let r4 = r2 *% r2 in FStar.Tactics.Effect.assert_by_tactic (((a0 *% r4 +% c0) *% r4) +% ((a1 *% r4 +% c1) *% (r2 *% r)) +% ((a2 *% r4 +% c2) *% r2) +% ((a3 *% r4 +% c3) *% r) == (((((((((((a0 *% r4 +% (a1 *% (r2 *% r))) +% a2 *% r2) +% a3 *% r) +% c0) *% r) +% c1) *% r) +% c2) *% r) +% c3) *% r)) (fun _ -> (); (poly_semiring ()))
false
Hacl.Spec.K256.GLV.Lemmas.fst
Hacl.Spec.K256.GLV.Lemmas.lemma_aff_point_mul_split_lambda
val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point -> Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p == S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)))
val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point -> Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p == S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)))
let lemma_aff_point_mul_split_lambda k p = let r1, r2 = scalar_split_lambda k in calc (==) { aff_point_mul k p; (==) { lemma_scalar_split_lambda_eval k } aff_point_mul S.(r1 +^ r2 *^ lambda) p; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } aff_point_mul ((r1 + r2 * lambda) % S.q) p; (==) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p } aff_point_mul (r1 + r2 * lambda) p; (==) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p } S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p); (==) { lemma_glv_aff p } S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p); (==) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) } S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)); }
{ "file_name": "code/k256/Hacl.Spec.K256.GLV.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 103, "start_col": 0, "start_line": 87 }
module Hacl.Spec.K256.GLV.Lemmas open FStar.Mul module M = Lib.NatMod module LE = Lib.Exponentiation module SE = Spec.Exponentiation module S = Spec.K256 module LS = Spec.K256.Lemmas module SM = Hacl.Spec.K256.ECSM.Lemmas open Hacl.Spec.K256.GLV #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" // [lambda](px, py) = (beta * px, py) assume val lemma_glv_aff : p:S.aff_point -> Lemma (aff_point_mul lambda p == aff_point_mul_lambda p) val lemma_glv : p:S.proj_point -> Lemma (S.to_aff_point (point_mul_lambda p) == aff_point_mul lambda (S.to_aff_point p)) let lemma_glv p = let (pX, pY, pZ) = p in let (px, py) = S.to_aff_point p in assert (px = S.(pX /% pZ) /\ py = S.(pY /% pZ)); let (qx, qy) = aff_point_mul lambda (px, py) in lemma_glv_aff (px, py); assert (qx = S.(beta *% px) /\ qy = py); assert (qx = S.(beta *% (pX /% pZ)) /\ qy = S.(pY /% pZ)); let (rX, rY, rZ) = point_mul_lambda p in assert (rX = S.(beta *% pX) /\ rY = pY /\ rZ = pZ); let (rx, ry) = S.to_aff_point (rX, rY, rZ) in assert (rx = S.(rX /% rZ) /\ ry = S.(rY /% rZ)); assert (rx = S.(beta *% pX /% pZ) /\ ry = S.(pY /% pZ)); assert (qy = ry); // S.(beta *% pX /% rZ) = S.(beta *% (pX /% pZ)) assert (S.(beta *% pX /% pZ) = S.(beta *% pX *% S.finv pZ)); assert (S.(beta *% (pX /% pZ)) = S.(beta *% (pX *% S.finv pZ))); M.lemma_mul_mod_assoc #S.prime beta pX (S.finv pZ); assert (S.(beta *% pX *% S.finv pZ) = S.(beta *% (pX *% S.finv pZ))) //-------------------------------------------- val lemma_scalar_split_lambda_eval (k:S.qelem) : Lemma (let r1, r2 = scalar_split_lambda k in k == S.(r1 +^ r2 *^ lambda)) let lemma_scalar_split_lambda_eval k = assert_norm ((minus_lambda + lambda) % S.q = 0); let r1, r2 = scalar_split_lambda k in assert (r1 = S.(k +^ r2 *^ minus_lambda)); calc (==) { (r1 + (r2 * lambda % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } (r1 + r2 * lambda) % S.q; (==) { } ((k + (r2 * minus_lambda % S.q)) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * minus_lambda) S.q } ((k + r2 * minus_lambda) % S.q + r2 * lambda) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_l (k + r2 * minus_lambda) (r2 * lambda) S.q } (k + r2 * minus_lambda + r2 * lambda) % S.q; (==) { Math.Lemmas.distributivity_add_right r2 minus_lambda lambda } (k + r2 * (minus_lambda + lambda)) % S.q; (==) { Math.Lemmas.lemma_mod_plus_distr_r k (r2 * (minus_lambda + lambda)) S.q } (k + (r2 * (minus_lambda + lambda) % S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_mul_distr_r r2 (minus_lambda + lambda) S.q } (k + (r2 * ((minus_lambda + lambda) % S.q) % S.q)) % S.q; (==) { } k % S.q; (==) { Math.Lemmas.small_mod k S.q } k; } //-------------------------------------------- (** Fast computation of [k]P in affine coordinates *) val lemma_aff_point_mul_split_lambda: k:S.qelem -> p:S.aff_point -> Lemma (let r1, r2 = scalar_split_lambda k in aff_point_mul k p == S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)))
{ "checked_file": "/", "dependencies": [ "Spec.K256.Lemmas.fsti.checked", "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.K256.GLV.fst.checked", "Hacl.Spec.K256.ECSM.Lemmas.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.GLV.Lemmas.fst" }
[ { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Spec.K256.ECSM.Lemmas", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.K256.Lemmas", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256.GLV", "short_module": null }, { "abbrev": 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
k: Spec.K256.PointOps.qelem -> p: Spec.K256.PointOps.aff_point -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.K256.GLV.scalar_split_lambda k in (let FStar.Pervasives.Native.Mktuple2 #_ #_ r1 r2 = _ in Hacl.Spec.K256.GLV.aff_point_mul k p == Spec.K256.PointOps.aff_point_add (Hacl.Spec.K256.GLV.aff_point_mul r1 p) (Hacl.Spec.K256.GLV.aff_point_mul r2 (Hacl.Spec.K256.GLV.aff_point_mul_lambda p))) <: Type0))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Spec.K256.PointOps.qelem", "Spec.K256.PointOps.aff_point", "FStar.Calc.calc_finish", "Prims.eq2", "Hacl.Spec.K256.GLV.aff_point_mul", "Spec.K256.PointOps.aff_point_add", "Hacl.Spec.K256.GLV.aff_point_mul_lambda", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Hacl.Spec.K256.GLV.lambda", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.op_Modulus", "Spec.K256.PointOps.q", "Spec.K256.PointOps.op_Plus_Hat", "Spec.K256.PointOps.op_Star_Hat", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Hacl.Spec.K256.GLV.Lemmas.lemma_scalar_split_lambda_eval", "Prims.squash", "FStar.Math.Lemmas.lemma_mod_plus_distr_r", "Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg_modq", "Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg_mul_add", "Hacl.Spec.K256.GLV.Lemmas.lemma_glv_aff", "Spec.K256.Lemmas.aff_point_add_comm_lemma", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.K256.GLV.scalar_split_lambda" ]
[]
false
false
true
false
false
let lemma_aff_point_mul_split_lambda k p =
let r1, r2 = scalar_split_lambda k in calc ( == ) { aff_point_mul k p; ( == ) { lemma_scalar_split_lambda_eval k } aff_point_mul S.(r1 +^ r2 *^ lambda) p; ( == ) { Math.Lemmas.lemma_mod_plus_distr_r r1 (r2 * lambda) S.q } aff_point_mul ((r1 + r2 * lambda) % S.q) p; ( == ) { SM.lemma_aff_point_mul_neg_modq (r1 + r2 * lambda) p } aff_point_mul (r1 + r2 * lambda) p; ( == ) { SM.lemma_aff_point_mul_neg_mul_add lambda r2 r1 p } S.aff_point_add (aff_point_mul r2 (aff_point_mul lambda p)) (aff_point_mul r1 p); ( == ) { lemma_glv_aff p } S.aff_point_add (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p); ( == ) { LS.aff_point_add_comm_lemma (aff_point_mul r2 (aff_point_mul_lambda p)) (aff_point_mul r1 p) } S.aff_point_add (aff_point_mul r1 p) (aff_point_mul r2 (aff_point_mul_lambda p)); }
false
LList2.fst
LList2.elim_llist_cons
val elim_llist_cons (#opened: _) (p1: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) : STGhostT (p2: Ghost.erased (ptr cell) {~(p1 == null _)}) opened (llist p1 (a :: q)) (fun p2 -> ((pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar (Ghost.reveal p2) })) `star` (llist p2 q)) `star` (freeable p1))
val elim_llist_cons (#opened: _) (p1: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) : STGhostT (p2: Ghost.erased (ptr cell) {~(p1 == null _)}) opened (llist p1 (a :: q)) (fun p2 -> ((pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar (Ghost.reveal p2) })) `star` (llist p2 q)) `star` (freeable p1))
let elim_llist_cons (#opened: _) (p1: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) : STGhostT (p2: Ghost.erased (ptr cell) { ~ (p1 == null _) }) opened (llist p1 (a :: q)) (fun p2 -> pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar (Ghost.reveal p2) }) `star` llist p2 q `star` freeable p1 ) = rewrite_with_tactic (llist p1 (a :: q)) (llist_cons p1 a q llist); let _ = gen_elim () in let p2' = vpattern_erased (fun x -> llist x q) in let p2 : (p2: Ghost.erased (ptr cell) { ~ (p1 == null _) }) = p2' in vpattern_rewrite (fun x -> llist x q) p2; rewrite (pts_to _ _) (pts_to _ _); rewrite (freeable _) (freeable _); _
{ "file_name": "share/steel/examples/steelc/LList2.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 3, "end_line": 88, "start_col": 0, "start_line": 71 }
module LList2 open Steel.ST.GenElim open Steel.ST.C.Types open Steel.ST.C.Types.Struct.Aux open Steel.ST.C.Types.UserStruct // hides Struct module U32 = FStar.UInt32 noeq type cell_t = { hd: scalar_t U32.t; tl: scalar_t (ptr_gen cell_t); } noextract inline_for_extraction [@@ norm_field_attr] let cell_struct_def : struct_def cell_t = let fields = FStar.Set.add "hd" (FStar.Set.singleton "tl") in let field_desc : field_description_gen_t (field_t fields) = { fd_nonempty = nonempty_set_nonempty_type "hd" fields; fd_type = (fun (n: field_t fields) -> match n with "hd" -> scalar_t U32.t | "tl" -> scalar_t (ptr_gen cell_t)); fd_typedef = (fun (n: field_t fields) -> match n with "hd" -> scalar U32.t | "tl" -> scalar (ptr_gen cell_t)); } in { fields = fields; field_desc = field_desc; mk = (fun f -> Mkcell_t (f "hd") (f "tl")); get = (fun x (f: field_t fields) -> match f with "hd" -> x.hd | "tl" -> x.tl); get_mk = (fun _ _ -> ()); extensionality = (fun s1 s2 phi -> phi "hd"; phi "tl"); } noextract inline_for_extraction [@@ norm_field_attr] let cell = struct_typedef cell_struct_def [@@__reduce__] let llist_nil (p: ptr cell) : Tot vprop = pure (p == null _) [@@__reduce__] let llist_cons (p: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) (llist: (ptr cell -> (l: Ghost.erased (list U32.t) { List.Tot.length l < List.Tot.length (a :: q) }) -> Tot vprop)) : Tot vprop = exists_ (fun (p1: ref cell) -> exists_ (fun (p2: ptr cell) -> pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar p2 }) `star` llist p2 q `star` freeable p1 `star` pure (p == p1) )) let rec llist (p: ptr cell) (l: Ghost.erased (list U32.t)) : Tot vprop (decreases (List.Tot.length l)) = match Ghost.reveal l with | [] -> llist_nil p | a :: q -> llist_cons p a q llist let intro_llist_cons (#opened: _) (p1: ref cell) (#v1: Ghost.erased (typeof cell)) (p2: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) : STGhost unit opened (pts_to p1 v1 `star` llist p2 q `star` freeable p1 ) (fun _ -> llist p1 (a :: q)) (Ghost.reveal v1 == ({ hd = mk_scalar a; tl = mk_scalar p2 })) (fun _ -> True) = noop (); rewrite_with_tactic (llist_cons p1 a q llist) (llist p1 (a :: q))
{ "checked_file": "/", "dependencies": [ "Steel.ST.GenElim.fsti.checked", "Steel.ST.C.Types.UserStruct.fsti.checked", "Steel.ST.C.Types.Struct.Aux.fsti.checked", "Steel.ST.C.Types.fst.checked", "prims.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LList2.fst" }
[ { "abbrev": false, "full_module": "Steel.ST.C.Types.UserStruct // hides Struct", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "Steel.ST.C.Types.UserStruct", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types.Struct.Aux", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.C.Types", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": 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
p1: Steel.ST.C.Types.Base.ptr LList2.cell -> a: FStar.UInt32.t -> q: FStar.Ghost.erased (Prims.list FStar.UInt32.t) -> Steel.ST.Effect.Ghost.STGhostT (p2: FStar.Ghost.erased (Steel.ST.C.Types.Base.ptr LList2.cell) {~(p1 == Steel.ST.C.Types.Base.null LList2.cell)})
Steel.ST.Effect.Ghost.STGhostT
[]
[]
[ "Steel.Memory.inames", "Steel.ST.C.Types.Base.ptr", "LList2.cell_t", "LList2.cell", "FStar.UInt32.t", "FStar.Ghost.erased", "Prims.list", "Prims.l_not", "Prims.eq2", "Steel.ST.C.Types.Base.null", "Prims.unit", "Steel.ST.Util.rewrite", "Steel.ST.C.Types.Base.freeable", "Steel.ST.GenElim.Base.fstp", "Steel.ST.C.Types.Base.ref", "FStar.Ghost.reveal", "FStar.Pervasives.Native.tuple2", "Steel.ST.C.Types.Base.pts_to", "FStar.Ghost.hide", "LList2.Mkcell_t", "Steel.ST.C.Types.Scalar.mk_scalar", "Steel.ST.C.Types.Base.ptr_gen", "Steel.ST.GenElim.Base.sndp", "Steel.ST.Util.vpattern_rewrite", "LList2.llist", "Steel.Effect.Common.vprop", "Steel.ST.Util.vpattern_erased", "Steel.ST.GenElim.gen_elim", "Steel.ST.Util.exists_", "Steel.Effect.Common.VStar", "Steel.ST.Util.pure", "Steel.Effect.Common.star", "Steel.Effect.Common.emp", "Prims.l_and", "Prims.l_True", "Prims.prop", "Steel.ST.Util.rewrite_with_tactic", "Prims.Cons", "LList2.llist_cons" ]
[]
false
true
false
false
false
let elim_llist_cons (#opened: _) (p1: ptr cell) (a: U32.t) (q: Ghost.erased (list U32.t)) : STGhostT (p2: Ghost.erased (ptr cell) {~(p1 == null _)}) opened (llist p1 (a :: q)) (fun p2 -> ((pts_to p1 ({ hd = mk_scalar a; tl = mk_scalar (Ghost.reveal p2) })) `star` (llist p2 q)) `star` (freeable p1)) =
rewrite_with_tactic (llist p1 (a :: q)) (llist_cons p1 a q llist); let _ = gen_elim () in let p2' = vpattern_erased (fun x -> llist x q) in let p2:(p2: Ghost.erased (ptr cell) {~(p1 == null _)}) = p2' in vpattern_rewrite (fun x -> llist x q) p2; rewrite (pts_to _ _) (pts_to _ _); rewrite (freeable _) (freeable _); _
false
FStar.DM4F.ST.fst
FStar.DM4F.ST.st
val st : s: Type -> a: Type -> Type
let st (s:Type) (a:Type) = s -> M (a * s)
{ "file_name": "examples/dm4free/FStar.DM4F.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 41, "end_line": 27, "start_col": 0, "start_line": 27 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.ST (********************************************************** * Dijkstra Monads for Free : Simple state * * A minimal example of defining a state effect along * with actions, over a parametrized state type. * **********************************************************)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Type -> a: Type -> Type
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.tuple2" ]
[]
false
false
false
true
true
let st (s a: Type) =
s -> M (a * s)
false
FStar.DM4F.ST.fst
FStar.DM4F.ST.return_st
val return_st (s a: Type) (x: a) : st s a
val return_st (s a: Type) (x: a) : st s a
let return_st (s:Type) (a:Type) (x:a) : st s a = fun s0 -> x, s0
{ "file_name": "examples/dm4free/FStar.DM4F.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 64, "end_line": 30, "start_col": 0, "start_line": 30 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.ST (********************************************************** * Dijkstra Monads for Free : Simple state * * A minimal example of defining a state effect along * with actions, over a parametrized state type. * **********************************************************) (* The underlying representation type *) let st (s:Type) (a:Type) = s -> M (a * s)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Type -> a: Type -> x: a -> FStar.DM4F.ST.st s a
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.ST.st" ]
[]
false
false
false
true
false
let return_st (s a: Type) (x: a) : st s a =
fun s0 -> x, s0
false
FStar.DM4F.ST.fst
FStar.DM4F.ST.bind_st
val bind_st (s a b: Type) (f: st s a) (g: (a -> st s b)) : st s b
val bind_st (s a b: Type) (f: st s a) (g: (a -> st s b)) : st s b
let bind_st (s:Type) (a:Type) (b:Type) (f:st s a) (g:a -> st s b) : st s b = fun (s0:s) -> let (x,s) = f s0 in g x s
{ "file_name": "examples/dm4free/FStar.DM4F.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 43, "end_line": 33, "start_col": 0, "start_line": 32 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.ST (********************************************************** * Dijkstra Monads for Free : Simple state * * A minimal example of defining a state effect along * with actions, over a parametrized state type. * **********************************************************) (* The underlying representation type *) let st (s:Type) (a:Type) = s -> M (a * s) (* Monad definition *) let return_st (s:Type) (a:Type) (x:a) : st s a = fun s0 -> x, s0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Type -> a: Type -> b: Type -> f: FStar.DM4F.ST.st s a -> g: (_: a -> FStar.DM4F.ST.st s b) -> FStar.DM4F.ST.st s b
Prims.Tot
[ "total" ]
[]
[ "FStar.DM4F.ST.st", "FStar.Pervasives.Native.tuple2" ]
[]
false
false
false
true
false
let bind_st (s a b: Type) (f: st s a) (g: (a -> st s b)) : st s b =
fun (s0: s) -> let x, s = f s0 in g x s
false
FStar.DM4F.ST.fst
FStar.DM4F.ST.get
val get: s: Type -> Prims.unit -> st s s
val get: s: Type -> Prims.unit -> st s s
let get (s:Type) () : st s s = fun s0 -> s0, s0
{ "file_name": "examples/dm4free/FStar.DM4F.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 47, "end_line": 38, "start_col": 0, "start_line": 38 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.ST (********************************************************** * Dijkstra Monads for Free : Simple state * * A minimal example of defining a state effect along * with actions, over a parametrized state type. * **********************************************************) (* The underlying representation type *) let st (s:Type) (a:Type) = s -> M (a * s) (* Monad definition *) let return_st (s:Type) (a:Type) (x:a) : st s a = fun s0 -> x, s0 let bind_st (s:Type) (a:Type) (b:Type) (f:st s a) (g:a -> st s b) : st s b = fun (s0:s) -> let (x,s) = f s0 in g x s //<: M (b * s) (* TODO : investigate why the following does not work *) (* let h (s0:s) : = let (x,s) = f s0 in g x s <: M (a * s) in h *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Type -> _: Prims.unit -> FStar.DM4F.ST.st s s
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.ST.st" ]
[]
false
false
false
true
false
let get (s: Type) () : st s s =
fun s0 -> s0, s0
false
FStar.DM4F.ST.fst
FStar.DM4F.ST.put
val put (s: Type) (x: s) : st s unit
val put (s: Type) (x: s) : st s unit
let put (s:Type) (x:s) : st s unit = fun _ -> (), x
{ "file_name": "examples/dm4free/FStar.DM4F.ST.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 51, "end_line": 40, "start_col": 0, "start_line": 40 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.DM4F.ST (********************************************************** * Dijkstra Monads for Free : Simple state * * A minimal example of defining a state effect along * with actions, over a parametrized state type. * **********************************************************) (* The underlying representation type *) let st (s:Type) (a:Type) = s -> M (a * s) (* Monad definition *) let return_st (s:Type) (a:Type) (x:a) : st s a = fun s0 -> x, s0 let bind_st (s:Type) (a:Type) (b:Type) (f:st s a) (g:a -> st s b) : st s b = fun (s0:s) -> let (x,s) = f s0 in g x s //<: M (b * s) (* TODO : investigate why the following does not work *) (* let h (s0:s) : = let (x,s) = f s0 in g x s <: M (a * s) in h *) (* Actions *) let get (s:Type) () : st s s = fun s0 -> s0, s0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.DM4F.ST.fst" }
[ { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.DM4F", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: Type -> x: s -> FStar.DM4F.ST.st s Prims.unit
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "FStar.Pervasives.Native.tuple2", "FStar.DM4F.ST.st" ]
[]
false
false
false
true
false
let put (s: Type) (x: s) : st s unit =
fun _ -> (), x
false
FStar.PtrdiffT.fst
FStar.PtrdiffT.min_bound
val min_bound:erased int
val min_bound:erased int
let min_bound : erased int = hide (- (reveal max_bound + 1))
{ "file_name": "ulib/FStar.PtrdiffT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 60, "end_line": 15, "start_col": 0, "start_line": 15 }
module FStar.PtrdiffT module Cast = FStar.Int.Cast module I64 = FStar.Int64 open FStar.Ghost friend FStar.SizeT (** We assume the existence of lower and upper bounds corresponding to PTRDIFF_MIN and PTRDIFF_MAX, which ensure that a ptrdiff_t has at least width 16 according to the C standard *) assume
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.PtrdiffT.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "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
FStar.Ghost.erased Prims.int
Prims.Tot
[ "total" ]
[]
[ "FStar.Ghost.hide", "Prims.int", "Prims.op_Minus", "Prims.op_Addition", "FStar.Ghost.reveal", "FStar.PtrdiffT.max_bound" ]
[]
false
false
false
true
false
let min_bound:erased int =
hide (- (reveal max_bound + 1))
false
FStar.PtrdiffT.fst
FStar.PtrdiffT.fits
val fits (x: int) : Tot prop
val fits (x: int) : Tot prop
let fits x = FStar.Int.fits x I64.n == true /\ x <= max_bound /\ x >= min_bound
{ "file_name": "ulib/FStar.PtrdiffT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 34, "end_line": 25, "start_col": 0, "start_line": 23 }
module FStar.PtrdiffT module Cast = FStar.Int.Cast module I64 = FStar.Int64 open FStar.Ghost friend FStar.SizeT (** We assume the existence of lower and upper bounds corresponding to PTRDIFF_MIN and PTRDIFF_MAX, which ensure that a ptrdiff_t has at least width 16 according to the C standard *) assume val max_bound : x:erased int { x >= pow2 15 - 1 } let min_bound : erased int = hide (- (reveal max_bound + 1)) (** We also assume that size_t is wider than ptrdiff_t *) assume val bounds_lemma (_:unit) : Lemma (SizeT.bound > max_bound) let t = x:I64.t{I64.v x >= min_bound /\ I64.v x <= max_bound }
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.PtrdiffT.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "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: Prims.int -> Prims.prop
Prims.Tot
[ "total" ]
[]
[ "Prims.int", "Prims.l_and", "Prims.eq2", "Prims.bool", "FStar.Int.fits", "FStar.Int64.n", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Ghost.reveal", "FStar.PtrdiffT.max_bound", "Prims.op_GreaterThanOrEqual", "FStar.PtrdiffT.min_bound", "Prims.prop" ]
[]
false
false
false
true
true
let fits x =
FStar.Int.fits x I64.n == true /\ x <= max_bound /\ x >= min_bound
false
FStar.PtrdiffT.fst
FStar.PtrdiffT.t
val t : eqtype
val t : eqtype
let t = x:I64.t{I64.v x >= min_bound /\ I64.v x <= max_bound }
{ "file_name": "ulib/FStar.PtrdiffT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 62, "end_line": 21, "start_col": 0, "start_line": 21 }
module FStar.PtrdiffT module Cast = FStar.Int.Cast module I64 = FStar.Int64 open FStar.Ghost friend FStar.SizeT (** We assume the existence of lower and upper bounds corresponding to PTRDIFF_MIN and PTRDIFF_MAX, which ensure that a ptrdiff_t has at least width 16 according to the C standard *) assume val max_bound : x:erased int { x >= pow2 15 - 1 } let min_bound : erased int = hide (- (reveal max_bound + 1)) (** We also assume that size_t is wider than ptrdiff_t *) assume val bounds_lemma (_:unit) : Lemma (SizeT.bound > max_bound)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.PtrdiffT.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "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
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.Int64.t", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.Int64.v", "FStar.Ghost.reveal", "Prims.int", "FStar.PtrdiffT.min_bound", "Prims.op_LessThanOrEqual", "FStar.PtrdiffT.max_bound" ]
[]
false
false
false
true
false
let t =
x: I64.t{I64.v x >= min_bound /\ I64.v x <= max_bound}
false
FStar.PtrdiffT.fst
FStar.PtrdiffT.v
val v (x: t) : Pure int (requires True) (ensures (fun y -> fits y))
val v (x: t) : Pure int (requires True) (ensures (fun y -> fits y))
let v x = I64.v x
{ "file_name": "ulib/FStar.PtrdiffT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 9, "end_line": 30, "start_col": 0, "start_line": 29 }
module FStar.PtrdiffT module Cast = FStar.Int.Cast module I64 = FStar.Int64 open FStar.Ghost friend FStar.SizeT (** We assume the existence of lower and upper bounds corresponding to PTRDIFF_MIN and PTRDIFF_MAX, which ensure that a ptrdiff_t has at least width 16 according to the C standard *) assume val max_bound : x:erased int { x >= pow2 15 - 1 } let min_bound : erased int = hide (- (reveal max_bound + 1)) (** We also assume that size_t is wider than ptrdiff_t *) assume val bounds_lemma (_:unit) : Lemma (SizeT.bound > max_bound) let t = x:I64.t{I64.v x >= min_bound /\ I64.v x <= max_bound } let fits x = FStar.Int.fits x I64.n == true /\ x <= max_bound /\ x >= min_bound let fits_lt x y = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.PtrdiffT.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "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.PtrdiffT.t -> Prims.Pure Prims.int
Prims.Pure
[]
[]
[ "FStar.PtrdiffT.t", "FStar.Int64.v", "Prims.int" ]
[]
false
false
false
false
false
let v x =
I64.v x
false
FStar.PtrdiffT.fst
FStar.PtrdiffT.int_to_t
val int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x))
val int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x))
let int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) = I64.int_to_t x
{ "file_name": "ulib/FStar.PtrdiffT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 18, "end_line": 35, "start_col": 0, "start_line": 32 }
module FStar.PtrdiffT module Cast = FStar.Int.Cast module I64 = FStar.Int64 open FStar.Ghost friend FStar.SizeT (** We assume the existence of lower and upper bounds corresponding to PTRDIFF_MIN and PTRDIFF_MAX, which ensure that a ptrdiff_t has at least width 16 according to the C standard *) assume val max_bound : x:erased int { x >= pow2 15 - 1 } let min_bound : erased int = hide (- (reveal max_bound + 1)) (** We also assume that size_t is wider than ptrdiff_t *) assume val bounds_lemma (_:unit) : Lemma (SizeT.bound > max_bound) let t = x:I64.t{I64.v x >= min_bound /\ I64.v x <= max_bound } let fits x = FStar.Int.fits x I64.n == true /\ x <= max_bound /\ x >= min_bound let fits_lt x y = () let v x = I64.v x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.PtrdiffT.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "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: Prims.int -> Prims.Pure FStar.PtrdiffT.t
Prims.Pure
[]
[]
[ "Prims.int", "FStar.Int64.int_to_t", "FStar.PtrdiffT.t", "FStar.PtrdiffT.fits", "Prims.eq2", "FStar.PtrdiffT.v" ]
[]
false
false
false
false
false
let int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) =
I64.int_to_t x
false
FStar.PtrdiffT.fst
FStar.PtrdiffT.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 = I64.add x y
{ "file_name": "ulib/FStar.PtrdiffT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 46, "start_col": 0, "start_line": 46 }
module FStar.PtrdiffT module Cast = FStar.Int.Cast module I64 = FStar.Int64 open FStar.Ghost friend FStar.SizeT (** We assume the existence of lower and upper bounds corresponding to PTRDIFF_MIN and PTRDIFF_MAX, which ensure that a ptrdiff_t has at least width 16 according to the C standard *) assume val max_bound : x:erased int { x >= pow2 15 - 1 } let min_bound : erased int = hide (- (reveal max_bound + 1)) (** We also assume that size_t is wider than ptrdiff_t *) assume val bounds_lemma (_:unit) : Lemma (SizeT.bound > max_bound) let t = x:I64.t{I64.v x >= min_bound /\ I64.v x <= max_bound } let fits x = FStar.Int.fits x I64.n == true /\ x <= max_bound /\ x >= min_bound let fits_lt x y = () let v x = I64.v x let int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) = I64.int_to_t x let ptrdiff_v_inj x = () let ptrdiff_int_to_t_inj x = () let mk x = int_to_t (I16.v x) let ptrdifft_to_sizet x = bounds_lemma (); Cast.int64_to_uint64 x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.PtrdiffT.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "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.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure FStar.PtrdiffT.t
Prims.Pure
[]
[]
[ "FStar.PtrdiffT.t", "FStar.Int64.add" ]
[]
false
false
false
false
false
let add x y =
I64.add x y
false
FStar.PtrdiffT.fst
FStar.PtrdiffT.ptrdifft_to_sizet
val ptrdifft_to_sizet (x:t{v x >= 0}) : Pure US.t (requires True) (ensures fun c -> v x == US.v c)
val ptrdifft_to_sizet (x:t{v x >= 0}) : Pure US.t (requires True) (ensures fun c -> v x == US.v c)
let ptrdifft_to_sizet x = bounds_lemma (); Cast.int64_to_uint64 x
{ "file_name": "ulib/FStar.PtrdiffT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 24, "end_line": 44, "start_col": 0, "start_line": 42 }
module FStar.PtrdiffT module Cast = FStar.Int.Cast module I64 = FStar.Int64 open FStar.Ghost friend FStar.SizeT (** We assume the existence of lower and upper bounds corresponding to PTRDIFF_MIN and PTRDIFF_MAX, which ensure that a ptrdiff_t has at least width 16 according to the C standard *) assume val max_bound : x:erased int { x >= pow2 15 - 1 } let min_bound : erased int = hide (- (reveal max_bound + 1)) (** We also assume that size_t is wider than ptrdiff_t *) assume val bounds_lemma (_:unit) : Lemma (SizeT.bound > max_bound) let t = x:I64.t{I64.v x >= min_bound /\ I64.v x <= max_bound } let fits x = FStar.Int.fits x I64.n == true /\ x <= max_bound /\ x >= min_bound let fits_lt x y = () let v x = I64.v x let int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) = I64.int_to_t x let ptrdiff_v_inj x = () let ptrdiff_int_to_t_inj x = () let mk x = int_to_t (I16.v x)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.PtrdiffT.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "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.PtrdiffT.t{FStar.PtrdiffT.v x >= 0} -> Prims.Pure FStar.SizeT.t
Prims.Pure
[]
[]
[ "FStar.PtrdiffT.t", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.PtrdiffT.v", "FStar.Int.Cast.int64_to_uint64", "Prims.unit", "FStar.PtrdiffT.bounds_lemma", "FStar.SizeT.t" ]
[]
false
false
false
false
false
let ptrdifft_to_sizet x =
bounds_lemma (); Cast.int64_to_uint64 x
false
FStar.PtrdiffT.fst
FStar.PtrdiffT.mk
val mk (x: I16.t) : Pure t (requires True) (ensures (fun y -> v y == I16.v x))
val mk (x: I16.t) : Pure t (requires True) (ensures (fun y -> v y == I16.v x))
let mk x = int_to_t (I16.v x)
{ "file_name": "ulib/FStar.PtrdiffT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 40, "start_col": 0, "start_line": 40 }
module FStar.PtrdiffT module Cast = FStar.Int.Cast module I64 = FStar.Int64 open FStar.Ghost friend FStar.SizeT (** We assume the existence of lower and upper bounds corresponding to PTRDIFF_MIN and PTRDIFF_MAX, which ensure that a ptrdiff_t has at least width 16 according to the C standard *) assume val max_bound : x:erased int { x >= pow2 15 - 1 } let min_bound : erased int = hide (- (reveal max_bound + 1)) (** We also assume that size_t is wider than ptrdiff_t *) assume val bounds_lemma (_:unit) : Lemma (SizeT.bound > max_bound) let t = x:I64.t{I64.v x >= min_bound /\ I64.v x <= max_bound } let fits x = FStar.Int.fits x I64.n == true /\ x <= max_bound /\ x >= min_bound let fits_lt x y = () let v x = I64.v x let int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) = I64.int_to_t x let ptrdiff_v_inj x = () let ptrdiff_int_to_t_inj x = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.PtrdiffT.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "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.Int16.t -> Prims.Pure FStar.PtrdiffT.t
Prims.Pure
[]
[]
[ "FStar.Int16.t", "FStar.PtrdiffT.int_to_t", "FStar.Int16.v", "FStar.PtrdiffT.t" ]
[]
false
false
false
false
false
let mk x =
int_to_t (I16.v x)
false
FStar.PtrdiffT.fst
FStar.PtrdiffT.rem
val rem (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures (fun c -> mod_spec (v a) (v b) = v c))
val rem (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures (fun c -> mod_spec (v a) (v b) = v c))
let rem x y = I64.rem x y
{ "file_name": "ulib/FStar.PtrdiffT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 52, "start_col": 0, "start_line": 52 }
module FStar.PtrdiffT module Cast = FStar.Int.Cast module I64 = FStar.Int64 open FStar.Ghost friend FStar.SizeT (** We assume the existence of lower and upper bounds corresponding to PTRDIFF_MIN and PTRDIFF_MAX, which ensure that a ptrdiff_t has at least width 16 according to the C standard *) assume val max_bound : x:erased int { x >= pow2 15 - 1 } let min_bound : erased int = hide (- (reveal max_bound + 1)) (** We also assume that size_t is wider than ptrdiff_t *) assume val bounds_lemma (_:unit) : Lemma (SizeT.bound > max_bound) let t = x:I64.t{I64.v x >= min_bound /\ I64.v x <= max_bound } let fits x = FStar.Int.fits x I64.n == true /\ x <= max_bound /\ x >= min_bound let fits_lt x y = () let v x = I64.v x let int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) = I64.int_to_t x let ptrdiff_v_inj x = () let ptrdiff_int_to_t_inj x = () let mk x = int_to_t (I16.v x) let ptrdifft_to_sizet x = bounds_lemma (); Cast.int64_to_uint64 x let add x y = I64.add x y let div x y = FStar.Math.Lib.slash_decr_axiom (v x) (v y); I64.div x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.PtrdiffT.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "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
a: FStar.PtrdiffT.t{FStar.PtrdiffT.v a >= 0} -> b: FStar.PtrdiffT.t{FStar.PtrdiffT.v b > 0} -> Prims.Pure FStar.PtrdiffT.t
Prims.Pure
[]
[]
[ "FStar.PtrdiffT.t", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.PtrdiffT.v", "Prims.op_GreaterThan", "FStar.Int64.rem" ]
[]
false
false
false
false
false
let rem x y =
I64.rem x y
false
FStar.PtrdiffT.fst
FStar.PtrdiffT.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 = I64.lt x y
{ "file_name": "ulib/FStar.PtrdiffT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 23, "end_line": 55, "start_col": 0, "start_line": 55 }
module FStar.PtrdiffT module Cast = FStar.Int.Cast module I64 = FStar.Int64 open FStar.Ghost friend FStar.SizeT (** We assume the existence of lower and upper bounds corresponding to PTRDIFF_MIN and PTRDIFF_MAX, which ensure that a ptrdiff_t has at least width 16 according to the C standard *) assume val max_bound : x:erased int { x >= pow2 15 - 1 } let min_bound : erased int = hide (- (reveal max_bound + 1)) (** We also assume that size_t is wider than ptrdiff_t *) assume val bounds_lemma (_:unit) : Lemma (SizeT.bound > max_bound) let t = x:I64.t{I64.v x >= min_bound /\ I64.v x <= max_bound } let fits x = FStar.Int.fits x I64.n == true /\ x <= max_bound /\ x >= min_bound let fits_lt x y = () let v x = I64.v x let int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) = I64.int_to_t x let ptrdiff_v_inj x = () let ptrdiff_int_to_t_inj x = () let mk x = int_to_t (I16.v x) let ptrdifft_to_sizet x = bounds_lemma (); Cast.int64_to_uint64 x let add x y = I64.add x y let div x y = FStar.Math.Lib.slash_decr_axiom (v x) (v y); I64.div x y let rem x y = I64.rem x y let gt x y = I64.gt x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.PtrdiffT.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "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.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
Prims.Pure
[]
[]
[ "FStar.PtrdiffT.t", "FStar.Int64.lt", "Prims.bool" ]
[]
false
false
false
false
false
let lt x y =
I64.lt x y
false
FStar.PtrdiffT.fst
FStar.PtrdiffT.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 = I64.gt x y
{ "file_name": "ulib/FStar.PtrdiffT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 23, "end_line": 53, "start_col": 0, "start_line": 53 }
module FStar.PtrdiffT module Cast = FStar.Int.Cast module I64 = FStar.Int64 open FStar.Ghost friend FStar.SizeT (** We assume the existence of lower and upper bounds corresponding to PTRDIFF_MIN and PTRDIFF_MAX, which ensure that a ptrdiff_t has at least width 16 according to the C standard *) assume val max_bound : x:erased int { x >= pow2 15 - 1 } let min_bound : erased int = hide (- (reveal max_bound + 1)) (** We also assume that size_t is wider than ptrdiff_t *) assume val bounds_lemma (_:unit) : Lemma (SizeT.bound > max_bound) let t = x:I64.t{I64.v x >= min_bound /\ I64.v x <= max_bound } let fits x = FStar.Int.fits x I64.n == true /\ x <= max_bound /\ x >= min_bound let fits_lt x y = () let v x = I64.v x let int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) = I64.int_to_t x let ptrdiff_v_inj x = () let ptrdiff_int_to_t_inj x = () let mk x = int_to_t (I16.v x) let ptrdifft_to_sizet x = bounds_lemma (); Cast.int64_to_uint64 x let add x y = I64.add x y let div x y = FStar.Math.Lib.slash_decr_axiom (v x) (v y); I64.div x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.PtrdiffT.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "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.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
Prims.Pure
[]
[]
[ "FStar.PtrdiffT.t", "FStar.Int64.gt", "Prims.bool" ]
[]
false
false
false
false
false
let gt x y =
I64.gt x y
false
FStar.PtrdiffT.fst
FStar.PtrdiffT.div
val div (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures fun c -> v a / v b == v c)
val div (a:t{v a >= 0}) (b:t{v b > 0}) : Pure t (requires True) (ensures fun c -> v a / v b == v c)
let div x y = FStar.Math.Lib.slash_decr_axiom (v x) (v y); I64.div x y
{ "file_name": "ulib/FStar.PtrdiffT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 50, "start_col": 0, "start_line": 48 }
module FStar.PtrdiffT module Cast = FStar.Int.Cast module I64 = FStar.Int64 open FStar.Ghost friend FStar.SizeT (** We assume the existence of lower and upper bounds corresponding to PTRDIFF_MIN and PTRDIFF_MAX, which ensure that a ptrdiff_t has at least width 16 according to the C standard *) assume val max_bound : x:erased int { x >= pow2 15 - 1 } let min_bound : erased int = hide (- (reveal max_bound + 1)) (** We also assume that size_t is wider than ptrdiff_t *) assume val bounds_lemma (_:unit) : Lemma (SizeT.bound > max_bound) let t = x:I64.t{I64.v x >= min_bound /\ I64.v x <= max_bound } let fits x = FStar.Int.fits x I64.n == true /\ x <= max_bound /\ x >= min_bound let fits_lt x y = () let v x = I64.v x let int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) = I64.int_to_t x let ptrdiff_v_inj x = () let ptrdiff_int_to_t_inj x = () let mk x = int_to_t (I16.v x) let ptrdifft_to_sizet x = bounds_lemma (); Cast.int64_to_uint64 x let add x y = I64.add x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.PtrdiffT.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "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
a: FStar.PtrdiffT.t{FStar.PtrdiffT.v a >= 0} -> b: FStar.PtrdiffT.t{FStar.PtrdiffT.v b > 0} -> Prims.Pure FStar.PtrdiffT.t
Prims.Pure
[]
[]
[ "FStar.PtrdiffT.t", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.PtrdiffT.v", "Prims.op_GreaterThan", "FStar.Int64.div", "Prims.unit", "FStar.Math.Lib.slash_decr_axiom" ]
[]
false
false
false
false
false
let div x y =
FStar.Math.Lib.slash_decr_axiom (v x) (v y); I64.div x y
false
FStar.PtrdiffT.fst
FStar.PtrdiffT.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 = I64.lte x y
{ "file_name": "ulib/FStar.PtrdiffT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 56, "start_col": 0, "start_line": 56 }
module FStar.PtrdiffT module Cast = FStar.Int.Cast module I64 = FStar.Int64 open FStar.Ghost friend FStar.SizeT (** We assume the existence of lower and upper bounds corresponding to PTRDIFF_MIN and PTRDIFF_MAX, which ensure that a ptrdiff_t has at least width 16 according to the C standard *) assume val max_bound : x:erased int { x >= pow2 15 - 1 } let min_bound : erased int = hide (- (reveal max_bound + 1)) (** We also assume that size_t is wider than ptrdiff_t *) assume val bounds_lemma (_:unit) : Lemma (SizeT.bound > max_bound) let t = x:I64.t{I64.v x >= min_bound /\ I64.v x <= max_bound } let fits x = FStar.Int.fits x I64.n == true /\ x <= max_bound /\ x >= min_bound let fits_lt x y = () let v x = I64.v x let int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) = I64.int_to_t x let ptrdiff_v_inj x = () let ptrdiff_int_to_t_inj x = () let mk x = int_to_t (I16.v x) let ptrdifft_to_sizet x = bounds_lemma (); Cast.int64_to_uint64 x let add x y = I64.add x y let div x y = FStar.Math.Lib.slash_decr_axiom (v x) (v y); I64.div x y let rem x y = I64.rem x y let gt x y = I64.gt x y let gte x y = I64.gte x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.PtrdiffT.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "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.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
Prims.Pure
[]
[]
[ "FStar.PtrdiffT.t", "FStar.Int64.lte", "Prims.bool" ]
[]
false
false
false
false
false
let lte x y =
I64.lte x y
false
FStar.PtrdiffT.fst
FStar.PtrdiffT.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 = I64.gte x y
{ "file_name": "ulib/FStar.PtrdiffT.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 54, "start_col": 0, "start_line": 54 }
module FStar.PtrdiffT module Cast = FStar.Int.Cast module I64 = FStar.Int64 open FStar.Ghost friend FStar.SizeT (** We assume the existence of lower and upper bounds corresponding to PTRDIFF_MIN and PTRDIFF_MAX, which ensure that a ptrdiff_t has at least width 16 according to the C standard *) assume val max_bound : x:erased int { x >= pow2 15 - 1 } let min_bound : erased int = hide (- (reveal max_bound + 1)) (** We also assume that size_t is wider than ptrdiff_t *) assume val bounds_lemma (_:unit) : Lemma (SizeT.bound > max_bound) let t = x:I64.t{I64.v x >= min_bound /\ I64.v x <= max_bound } let fits x = FStar.Int.fits x I64.n == true /\ x <= max_bound /\ x >= min_bound let fits_lt x y = () let v x = I64.v x let int_to_t (x: int) : Pure t (requires (fits x)) (ensures (fun y -> v y == x)) = I64.int_to_t x let ptrdiff_v_inj x = () let ptrdiff_int_to_t_inj x = () let mk x = int_to_t (I16.v x) let ptrdifft_to_sizet x = bounds_lemma (); Cast.int64_to_uint64 x let add x y = I64.add x y let div x y = FStar.Math.Lib.slash_decr_axiom (v x) (v y); I64.div x y let rem x y = I64.rem x y
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.SizeT.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Math.Lib.fst.checked", "FStar.Int64.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Int.fsti.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "FStar.PtrdiffT.fst" }
[ { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "US" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "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.PtrdiffT.t -> y: FStar.PtrdiffT.t -> Prims.Pure Prims.bool
Prims.Pure
[]
[]
[ "FStar.PtrdiffT.t", "FStar.Int64.gte", "Prims.bool" ]
[]
false
false
false
false
false
let gte x y =
I64.gte x y
false
Steel.ST.SeqMatch.fst
Steel.ST.SeqMatch.seq_list_match_nil0
val seq_list_match_nil0 (#t: Type) (c: Seq.seq t) : Tot vprop
val seq_list_match_nil0 (#t: Type) (c: Seq.seq t) : Tot vprop
let seq_list_match_nil0 (#t: Type) (c: Seq.seq t) : Tot vprop = pure (c `Seq.equal` Seq.empty)
{ "file_name": "lib/steel/Steel.ST.SeqMatch.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 32, "end_line": 19, "start_col": 0, "start_line": 15 }
module Steel.ST.SeqMatch include Steel.ST.OnRange open Steel.ST.GenElim module Seq = FStar.Seq module SZ = FStar.SizeT (* `seq_list_match` describes how to match a sequence of low-level values (the low-level contents of an array) with a list of high-level values. `seq_list_match` is carefully designed to be usable within (mutually) recursive definitions of matching functions on the type of high-level values. *)
{ "checked_file": "/", "dependencies": [ "Steel.ST.OnRange.fsti.checked", "Steel.ST.GenElim.fsti.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Steel.ST.SeqMatch.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.OnRange", "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
c: FStar.Seq.Base.seq t -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "FStar.Seq.Base.seq", "Steel.ST.Util.pure", "FStar.Seq.Base.equal", "FStar.Seq.Base.empty", "Steel.Effect.Common.vprop" ]
[]
false
false
false
true
false
let seq_list_match_nil0 (#t: Type) (c: Seq.seq t) : Tot vprop =
pure (c `Seq.equal` Seq.empty)
false
Steel.ST.SeqMatch.fst
Steel.ST.SeqMatch.seq_seq_match
val seq_seq_match (#t1 #t2: Type) (p: (t1 -> t2 -> vprop)) (c: Seq.seq t1) (l: Seq.seq t2) (i j: nat) : Tot vprop
val seq_seq_match (#t1 #t2: Type) (p: (t1 -> t2 -> vprop)) (c: Seq.seq t1) (l: Seq.seq t2) (i j: nat) : Tot vprop
let seq_seq_match (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: Seq.seq t2) (i j: nat) : Tot vprop = on_range (seq_seq_match_item p c l) i j
{ "file_name": "lib/steel/Steel.ST.SeqMatch.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 41, "end_line": 226, "start_col": 0, "start_line": 219 }
module Steel.ST.SeqMatch include Steel.ST.OnRange open Steel.ST.GenElim module Seq = FStar.Seq module SZ = FStar.SizeT (* `seq_list_match` describes how to match a sequence of low-level values (the low-level contents of an array) with a list of high-level values. `seq_list_match` is carefully designed to be usable within (mutually) recursive definitions of matching functions on the type of high-level values. *) [@@__reduce__] let seq_list_match_nil0 (#t: Type) (c: Seq.seq t) : Tot vprop = pure (c `Seq.equal` Seq.empty) [@@__reduce__] let seq_list_match_cons0 (#t #t': Type) (c: Seq.seq t) (l: list t' { Cons? l }) (item_match: (t -> (v': t' { v' << l }) -> vprop)) (seq_list_match: (Seq.seq t -> (v': list t') -> (raw_data_item_match: (t -> (v'': t' { v'' << v' }) -> vprop) { v' << l }) -> vprop)) : Tot vprop = exists_ (fun (c1: t) -> exists_ (fun (c2: Seq.seq t) -> item_match c1 (List.Tot.hd l) `star` seq_list_match c2 (List.Tot.tl l) item_match `star` pure (c `Seq.equal` Seq.cons c1 c2) )) let rec seq_list_match (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : Tot vprop (decreases v) = if Nil? v then seq_list_match_nil0 c else seq_list_match_cons0 c v item_match seq_list_match let seq_list_match_cons_eq (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : Lemma (requires (Cons? v)) (ensures ( seq_list_match c v item_match == seq_list_match_cons0 c v item_match seq_list_match )) = let a :: q = v in assert_norm (seq_list_match c (a :: q) item_match == seq_list_match_cons0 c (a :: q) item_match seq_list_match ) let seq_list_match_nil (#opened: _) (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : STGhost unit opened emp (fun _ -> seq_list_match c v item_match) (c `Seq.equal` Seq.empty /\ Nil? v) (fun _ -> True) = noop (); rewrite (seq_list_match_nil0 c) (seq_list_match c v item_match) let list_cons_precedes (#t: Type) (a: t) (q: list t) : Lemma ((a << a :: q) /\ (q << a :: q)) [SMTPat (a :: q)] = assert (List.Tot.hd (a :: q) << (a :: q)); assert (List.Tot.tl (a :: q) << (a :: q)) let seq_list_match_cons_intro (#opened: _) (#t #t': Type) (a: t) (a' : t') (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << a' :: v }) -> vprop)) : STGhostT unit opened (item_match a a' `star` seq_list_match c v item_match) (fun _ -> seq_list_match (Seq.cons a c) (a' :: v) item_match) = seq_list_match_cons_eq (Seq.cons a c) (a' :: v) item_match; noop (); rewrite (seq_list_match_cons0 (Seq.cons a c) (a' :: v) item_match seq_list_match) (seq_list_match (Seq.cons a c) (a' :: v) item_match) let seq_list_match_cons_elim (#opened: _) (#t #t': Type) (c: Seq.seq t) (v: list t' { Cons? v \/ Seq.length c > 0 }) (item_match: (t -> (v': t' { v' << v }) -> vprop)) : STGhostT (squash (Cons? v /\ Seq.length c > 0)) opened (seq_list_match c v item_match) (fun _ -> item_match (Seq.head c) (List.Tot.hd v) `star` seq_list_match (Seq.tail c) (List.Tot.tl v) item_match) = if Nil? v then begin rewrite (seq_list_match c v item_match) (seq_list_match_nil0 c); let _ = gen_elim () in assert False; rewrite // by contradiction emp (item_match (Seq.head c) (List.Tot.hd v) `star` seq_list_match (Seq.tail c) (List.Tot.tl v) item_match) end else begin seq_list_match_cons_eq c v item_match; noop (); rewrite (seq_list_match c v item_match) (seq_list_match_cons0 c v item_match seq_list_match); let _ = gen_elim () in let prf : squash (Cons? v /\ Seq.length c > 0) = () in let c1 = vpattern (fun c1 -> item_match c1 (List.Tot.hd v)) in let c2 = vpattern (fun c2 -> seq_list_match c2 (List.Tot.tl v) item_match) in Seq.lemma_cons_inj c1 (Seq.head c) c2 (Seq.tail c); vpattern_rewrite (fun c1 -> item_match c1 (List.Tot.hd v)) (Seq.head c); vpattern_rewrite (fun c2 -> seq_list_match c2 (List.Tot.tl v) item_match) (Seq.tail c); prf end // this one cannot be proven with seq_seq_match because of the << refinement in the type of item_match let rec seq_list_match_weaken (#opened: _) (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match1 item_match2: (t -> (v': t' { v' << v }) -> vprop)) (prf: ( (#opened: _) -> (c': t) -> (v': t' { v' << v }) -> STGhostT unit opened (item_match1 c' v') (fun _ -> item_match2 c' v') )) : STGhostT unit opened (seq_list_match c v item_match1) (fun _ -> seq_list_match c v item_match2) (decreases v) = if Nil? v then rewrite (seq_list_match c v item_match1) (seq_list_match c v item_match2) else begin let _ : squash (Cons? v) = () in seq_list_match_cons_eq c v item_match1; seq_list_match_cons_eq c v item_match2; rewrite (seq_list_match c v item_match1) (seq_list_match_cons0 c v item_match1 seq_list_match); let _ = gen_elim () in prf _ _; seq_list_match_weaken _ (List.Tot.tl v) item_match1 item_match2 prf; rewrite (seq_list_match_cons0 c v item_match2 seq_list_match) (seq_list_match c v item_match2) end (* `seq_seq_match` describes how to match a sequence of low-level values (the low-level contents of an array) with a sequence of high-level values. Contrary to `seq_list_match`, `seq_seq_match` is not meant to be usable within (mutually) recursive definitions of matching functions on the type of high-level values, because no lemma ensures that `Seq.index s i << s` *) let seq_seq_match_item (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: Seq.seq t2) (i: nat) : Tot vprop = if i < Seq.length c && i < Seq.length l then p (Seq.index c i) (Seq.index l i) else pure (squash False) let seq_seq_match_item_tail (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: Seq.seq t2) (delta: nat) (i: nat) : Lemma (requires ( i + delta <= Seq.length c /\ i + delta <= Seq.length l )) (ensures ( seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) i == seq_seq_match_item p c l (i + delta) )) = ()
{ "checked_file": "/", "dependencies": [ "Steel.ST.OnRange.fsti.checked", "Steel.ST.GenElim.fsti.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Steel.ST.SeqMatch.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.OnRange", "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
p: (_: t1 -> _: t2 -> Steel.Effect.Common.vprop) -> c: FStar.Seq.Base.seq t1 -> l: FStar.Seq.Base.seq t2 -> i: Prims.nat -> j: Prims.nat -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.Effect.Common.vprop", "FStar.Seq.Base.seq", "Prims.nat", "Steel.ST.OnRange.on_range", "Steel.ST.SeqMatch.seq_seq_match_item" ]
[]
false
false
false
true
false
let seq_seq_match (#t1 #t2: Type) (p: (t1 -> t2 -> vprop)) (c: Seq.seq t1) (l: Seq.seq t2) (i j: nat) : Tot vprop =
on_range (seq_seq_match_item p c l) i j
false
Steel.ST.SeqMatch.fst
Steel.ST.SeqMatch.seq_list_match_cons0
val seq_list_match_cons0 (#t #t': Type) (c: Seq.seq t) (l: list t' {Cons? l}) (item_match: (t -> v': t'{v' << l} -> vprop)) (seq_list_match: ( Seq.seq t -> v': list t' -> raw_data_item_match: (t -> v'': t'{v'' << v'} -> vprop){v' << l} -> vprop)) : Tot vprop
val seq_list_match_cons0 (#t #t': Type) (c: Seq.seq t) (l: list t' {Cons? l}) (item_match: (t -> v': t'{v' << l} -> vprop)) (seq_list_match: ( Seq.seq t -> v': list t' -> raw_data_item_match: (t -> v'': t'{v'' << v'} -> vprop){v' << l} -> vprop)) : Tot vprop
let seq_list_match_cons0 (#t #t': Type) (c: Seq.seq t) (l: list t' { Cons? l }) (item_match: (t -> (v': t' { v' << l }) -> vprop)) (seq_list_match: (Seq.seq t -> (v': list t') -> (raw_data_item_match: (t -> (v'': t' { v'' << v' }) -> vprop) { v' << l }) -> vprop)) : Tot vprop = exists_ (fun (c1: t) -> exists_ (fun (c2: Seq.seq t) -> item_match c1 (List.Tot.hd l) `star` seq_list_match c2 (List.Tot.tl l) item_match `star` pure (c `Seq.equal` Seq.cons c1 c2) ))
{ "file_name": "lib/steel/Steel.ST.SeqMatch.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 4, "end_line": 34, "start_col": 0, "start_line": 22 }
module Steel.ST.SeqMatch include Steel.ST.OnRange open Steel.ST.GenElim module Seq = FStar.Seq module SZ = FStar.SizeT (* `seq_list_match` describes how to match a sequence of low-level values (the low-level contents of an array) with a list of high-level values. `seq_list_match` is carefully designed to be usable within (mutually) recursive definitions of matching functions on the type of high-level values. *) [@@__reduce__] let seq_list_match_nil0 (#t: Type) (c: Seq.seq t) : Tot vprop = pure (c `Seq.equal` Seq.empty)
{ "checked_file": "/", "dependencies": [ "Steel.ST.OnRange.fsti.checked", "Steel.ST.GenElim.fsti.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Steel.ST.SeqMatch.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.OnRange", "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
c: FStar.Seq.Base.seq t -> l: Prims.list t' {Cons? l} -> item_match: (_: t -> v': t'{v' << l} -> Steel.Effect.Common.vprop) -> seq_list_match: ( _: FStar.Seq.Base.seq t -> v': Prims.list t' -> raw_data_item_match: (_: t -> v'': t'{v'' << v'} -> Steel.Effect.Common.vprop){v' << l} -> Steel.Effect.Common.vprop) -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "FStar.Seq.Base.seq", "Prims.list", "Prims.b2t", "Prims.uu___is_Cons", "Prims.precedes", "Steel.Effect.Common.vprop", "Steel.ST.Util.exists_", "Steel.Effect.Common.star", "FStar.List.Tot.Base.hd", "FStar.List.Tot.Base.tl", "Steel.ST.Util.pure", "FStar.Seq.Base.equal", "FStar.Seq.Base.cons" ]
[]
false
false
false
false
false
let seq_list_match_cons0 (#t #t': Type) (c: Seq.seq t) (l: list t' {Cons? l}) (item_match: (t -> v': t'{v' << l} -> vprop)) (seq_list_match: ( Seq.seq t -> v': list t' -> raw_data_item_match: (t -> v'': t'{v'' << v'} -> vprop){v' << l} -> vprop)) : Tot vprop =
exists_ (fun (c1: t) -> exists_ (fun (c2: Seq.seq t) -> ((item_match c1 (List.Tot.hd l)) `star` (seq_list_match c2 (List.Tot.tl l) item_match)) `star` (pure (c `Seq.equal` (Seq.cons c1 c2)))))
false
Steel.ST.SeqMatch.fst
Steel.ST.SeqMatch.seq_list_match
val seq_list_match (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> v': t'{v' << v} -> vprop)) : Tot vprop (decreases v)
val seq_list_match (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> v': t'{v' << v} -> vprop)) : Tot vprop (decreases v)
let rec seq_list_match (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : Tot vprop (decreases v) = if Nil? v then seq_list_match_nil0 c else seq_list_match_cons0 c v item_match seq_list_match
{ "file_name": "lib/steel/Steel.ST.SeqMatch.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 57, "end_line": 45, "start_col": 0, "start_line": 36 }
module Steel.ST.SeqMatch include Steel.ST.OnRange open Steel.ST.GenElim module Seq = FStar.Seq module SZ = FStar.SizeT (* `seq_list_match` describes how to match a sequence of low-level values (the low-level contents of an array) with a list of high-level values. `seq_list_match` is carefully designed to be usable within (mutually) recursive definitions of matching functions on the type of high-level values. *) [@@__reduce__] let seq_list_match_nil0 (#t: Type) (c: Seq.seq t) : Tot vprop = pure (c `Seq.equal` Seq.empty) [@@__reduce__] let seq_list_match_cons0 (#t #t': Type) (c: Seq.seq t) (l: list t' { Cons? l }) (item_match: (t -> (v': t' { v' << l }) -> vprop)) (seq_list_match: (Seq.seq t -> (v': list t') -> (raw_data_item_match: (t -> (v'': t' { v'' << v' }) -> vprop) { v' << l }) -> vprop)) : Tot vprop = exists_ (fun (c1: t) -> exists_ (fun (c2: Seq.seq t) -> item_match c1 (List.Tot.hd l) `star` seq_list_match c2 (List.Tot.tl l) item_match `star` pure (c `Seq.equal` Seq.cons c1 c2) ))
{ "checked_file": "/", "dependencies": [ "Steel.ST.OnRange.fsti.checked", "Steel.ST.GenElim.fsti.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Steel.ST.SeqMatch.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.OnRange", "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
c: FStar.Seq.Base.seq t -> v: Prims.list t' -> item_match: (_: t -> v': t'{v' << v} -> Steel.Effect.Common.vprop) -> Prims.Tot Steel.Effect.Common.vprop
Prims.Tot
[ "total", "" ]
[]
[ "FStar.Seq.Base.seq", "Prims.list", "Prims.precedes", "Steel.Effect.Common.vprop", "Prims.uu___is_Nil", "Steel.ST.SeqMatch.seq_list_match_nil0", "Prims.bool", "Steel.ST.SeqMatch.seq_list_match_cons0", "Steel.ST.SeqMatch.seq_list_match" ]
[ "recursion" ]
false
false
false
false
false
let rec seq_list_match (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> v': t'{v' << v} -> vprop)) : Tot vprop (decreases v) =
if Nil? v then seq_list_match_nil0 c else seq_list_match_cons0 c v item_match seq_list_match
false
Steel.ST.SeqMatch.fst
Steel.ST.SeqMatch.seq_list_match_cons_eq
val seq_list_match_cons_eq (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> v': t'{v' << v} -> vprop)) : Lemma (requires (Cons? v)) (ensures (seq_list_match c v item_match == seq_list_match_cons0 c v item_match seq_list_match) )
val seq_list_match_cons_eq (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> v': t'{v' << v} -> vprop)) : Lemma (requires (Cons? v)) (ensures (seq_list_match c v item_match == seq_list_match_cons0 c v item_match seq_list_match) )
let seq_list_match_cons_eq (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : Lemma (requires (Cons? v)) (ensures ( seq_list_match c v item_match == seq_list_match_cons0 c v item_match seq_list_match )) = let a :: q = v in assert_norm (seq_list_match c (a :: q) item_match == seq_list_match_cons0 c (a :: q) item_match seq_list_match )
{ "file_name": "lib/steel/Steel.ST.SeqMatch.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 3, "end_line": 61, "start_col": 0, "start_line": 47 }
module Steel.ST.SeqMatch include Steel.ST.OnRange open Steel.ST.GenElim module Seq = FStar.Seq module SZ = FStar.SizeT (* `seq_list_match` describes how to match a sequence of low-level values (the low-level contents of an array) with a list of high-level values. `seq_list_match` is carefully designed to be usable within (mutually) recursive definitions of matching functions on the type of high-level values. *) [@@__reduce__] let seq_list_match_nil0 (#t: Type) (c: Seq.seq t) : Tot vprop = pure (c `Seq.equal` Seq.empty) [@@__reduce__] let seq_list_match_cons0 (#t #t': Type) (c: Seq.seq t) (l: list t' { Cons? l }) (item_match: (t -> (v': t' { v' << l }) -> vprop)) (seq_list_match: (Seq.seq t -> (v': list t') -> (raw_data_item_match: (t -> (v'': t' { v'' << v' }) -> vprop) { v' << l }) -> vprop)) : Tot vprop = exists_ (fun (c1: t) -> exists_ (fun (c2: Seq.seq t) -> item_match c1 (List.Tot.hd l) `star` seq_list_match c2 (List.Tot.tl l) item_match `star` pure (c `Seq.equal` Seq.cons c1 c2) )) let rec seq_list_match (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : Tot vprop (decreases v) = if Nil? v then seq_list_match_nil0 c else seq_list_match_cons0 c v item_match seq_list_match
{ "checked_file": "/", "dependencies": [ "Steel.ST.OnRange.fsti.checked", "Steel.ST.GenElim.fsti.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Steel.ST.SeqMatch.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.OnRange", "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
c: FStar.Seq.Base.seq t -> v: Prims.list t' -> item_match: (_: t -> v': t'{v' << v} -> Steel.Effect.Common.vprop) -> FStar.Pervasives.Lemma (requires Cons? v) (ensures Steel.ST.SeqMatch.seq_list_match c v item_match == Steel.ST.SeqMatch.seq_list_match_cons0 c v item_match Steel.ST.SeqMatch.seq_list_match)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.list", "Prims.precedes", "Steel.Effect.Common.vprop", "FStar.Pervasives.assert_norm", "Prims.eq2", "Steel.ST.SeqMatch.seq_list_match", "Prims.Cons", "Steel.ST.SeqMatch.seq_list_match_cons0", "Prims.unit", "Prims.b2t", "Prims.uu___is_Cons", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let seq_list_match_cons_eq (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> v': t'{v' << v} -> vprop)) : Lemma (requires (Cons? v)) (ensures (seq_list_match c v item_match == seq_list_match_cons0 c v item_match seq_list_match) ) =
let a :: q = v in assert_norm (seq_list_match c (a :: q) item_match == seq_list_match_cons0 c (a :: q) item_match seq_list_match)
false
Steel.ST.SeqMatch.fst
Steel.ST.SeqMatch.list_cons_precedes
val list_cons_precedes (#t: Type) (a: t) (q: list t) : Lemma ((a << a :: q) /\ (q << a :: q)) [SMTPat (a :: q)]
val list_cons_precedes (#t: Type) (a: t) (q: list t) : Lemma ((a << a :: q) /\ (q << a :: q)) [SMTPat (a :: q)]
let list_cons_precedes (#t: Type) (a: t) (q: list t) : Lemma ((a << a :: q) /\ (q << a :: q)) [SMTPat (a :: q)] = assert (List.Tot.hd (a :: q) << (a :: q)); assert (List.Tot.tl (a :: q) << (a :: q))
{ "file_name": "lib/steel/Steel.ST.SeqMatch.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 43, "end_line": 88, "start_col": 0, "start_line": 80 }
module Steel.ST.SeqMatch include Steel.ST.OnRange open Steel.ST.GenElim module Seq = FStar.Seq module SZ = FStar.SizeT (* `seq_list_match` describes how to match a sequence of low-level values (the low-level contents of an array) with a list of high-level values. `seq_list_match` is carefully designed to be usable within (mutually) recursive definitions of matching functions on the type of high-level values. *) [@@__reduce__] let seq_list_match_nil0 (#t: Type) (c: Seq.seq t) : Tot vprop = pure (c `Seq.equal` Seq.empty) [@@__reduce__] let seq_list_match_cons0 (#t #t': Type) (c: Seq.seq t) (l: list t' { Cons? l }) (item_match: (t -> (v': t' { v' << l }) -> vprop)) (seq_list_match: (Seq.seq t -> (v': list t') -> (raw_data_item_match: (t -> (v'': t' { v'' << v' }) -> vprop) { v' << l }) -> vprop)) : Tot vprop = exists_ (fun (c1: t) -> exists_ (fun (c2: Seq.seq t) -> item_match c1 (List.Tot.hd l) `star` seq_list_match c2 (List.Tot.tl l) item_match `star` pure (c `Seq.equal` Seq.cons c1 c2) )) let rec seq_list_match (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : Tot vprop (decreases v) = if Nil? v then seq_list_match_nil0 c else seq_list_match_cons0 c v item_match seq_list_match let seq_list_match_cons_eq (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : Lemma (requires (Cons? v)) (ensures ( seq_list_match c v item_match == seq_list_match_cons0 c v item_match seq_list_match )) = let a :: q = v in assert_norm (seq_list_match c (a :: q) item_match == seq_list_match_cons0 c (a :: q) item_match seq_list_match ) let seq_list_match_nil (#opened: _) (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : STGhost unit opened emp (fun _ -> seq_list_match c v item_match) (c `Seq.equal` Seq.empty /\ Nil? v) (fun _ -> True) = noop (); rewrite (seq_list_match_nil0 c) (seq_list_match c v item_match)
{ "checked_file": "/", "dependencies": [ "Steel.ST.OnRange.fsti.checked", "Steel.ST.GenElim.fsti.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Steel.ST.SeqMatch.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.OnRange", "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
a: t -> q: Prims.list t -> FStar.Pervasives.Lemma (ensures a << a :: q /\ q << a :: q) [SMTPat (a :: q)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.list", "Prims._assert", "Prims.precedes", "FStar.List.Tot.Base.tl", "Prims.Cons", "Prims.unit", "FStar.List.Tot.Base.hd", "Prims.l_True", "Prims.squash", "Prims.l_and", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
true
false
true
false
false
let list_cons_precedes (#t: Type) (a: t) (q: list t) : Lemma ((a << a :: q) /\ (q << a :: q)) [SMTPat (a :: q)] =
assert (List.Tot.hd (a :: q) << (a :: q)); assert (List.Tot.tl (a :: q) << (a :: q))
false
Steel.ST.SeqMatch.fst
Steel.ST.SeqMatch.seq_seq_match_item
val seq_seq_match_item (#t1 #t2: Type) (p: (t1 -> t2 -> vprop)) (c: Seq.seq t1) (l: Seq.seq t2) (i: nat) : Tot vprop
val seq_seq_match_item (#t1 #t2: Type) (p: (t1 -> t2 -> vprop)) (c: Seq.seq t1) (l: Seq.seq t2) (i: nat) : Tot vprop
let seq_seq_match_item (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: Seq.seq t2) (i: nat) : Tot vprop = if i < Seq.length c && i < Seq.length l then p (Seq.index c i) (Seq.index l i) else pure (squash False)
{ "file_name": "lib/steel/Steel.ST.SeqMatch.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 23, "end_line": 198, "start_col": 0, "start_line": 187 }
module Steel.ST.SeqMatch include Steel.ST.OnRange open Steel.ST.GenElim module Seq = FStar.Seq module SZ = FStar.SizeT (* `seq_list_match` describes how to match a sequence of low-level values (the low-level contents of an array) with a list of high-level values. `seq_list_match` is carefully designed to be usable within (mutually) recursive definitions of matching functions on the type of high-level values. *) [@@__reduce__] let seq_list_match_nil0 (#t: Type) (c: Seq.seq t) : Tot vprop = pure (c `Seq.equal` Seq.empty) [@@__reduce__] let seq_list_match_cons0 (#t #t': Type) (c: Seq.seq t) (l: list t' { Cons? l }) (item_match: (t -> (v': t' { v' << l }) -> vprop)) (seq_list_match: (Seq.seq t -> (v': list t') -> (raw_data_item_match: (t -> (v'': t' { v'' << v' }) -> vprop) { v' << l }) -> vprop)) : Tot vprop = exists_ (fun (c1: t) -> exists_ (fun (c2: Seq.seq t) -> item_match c1 (List.Tot.hd l) `star` seq_list_match c2 (List.Tot.tl l) item_match `star` pure (c `Seq.equal` Seq.cons c1 c2) )) let rec seq_list_match (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : Tot vprop (decreases v) = if Nil? v then seq_list_match_nil0 c else seq_list_match_cons0 c v item_match seq_list_match let seq_list_match_cons_eq (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : Lemma (requires (Cons? v)) (ensures ( seq_list_match c v item_match == seq_list_match_cons0 c v item_match seq_list_match )) = let a :: q = v in assert_norm (seq_list_match c (a :: q) item_match == seq_list_match_cons0 c (a :: q) item_match seq_list_match ) let seq_list_match_nil (#opened: _) (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : STGhost unit opened emp (fun _ -> seq_list_match c v item_match) (c `Seq.equal` Seq.empty /\ Nil? v) (fun _ -> True) = noop (); rewrite (seq_list_match_nil0 c) (seq_list_match c v item_match) let list_cons_precedes (#t: Type) (a: t) (q: list t) : Lemma ((a << a :: q) /\ (q << a :: q)) [SMTPat (a :: q)] = assert (List.Tot.hd (a :: q) << (a :: q)); assert (List.Tot.tl (a :: q) << (a :: q)) let seq_list_match_cons_intro (#opened: _) (#t #t': Type) (a: t) (a' : t') (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << a' :: v }) -> vprop)) : STGhostT unit opened (item_match a a' `star` seq_list_match c v item_match) (fun _ -> seq_list_match (Seq.cons a c) (a' :: v) item_match) = seq_list_match_cons_eq (Seq.cons a c) (a' :: v) item_match; noop (); rewrite (seq_list_match_cons0 (Seq.cons a c) (a' :: v) item_match seq_list_match) (seq_list_match (Seq.cons a c) (a' :: v) item_match) let seq_list_match_cons_elim (#opened: _) (#t #t': Type) (c: Seq.seq t) (v: list t' { Cons? v \/ Seq.length c > 0 }) (item_match: (t -> (v': t' { v' << v }) -> vprop)) : STGhostT (squash (Cons? v /\ Seq.length c > 0)) opened (seq_list_match c v item_match) (fun _ -> item_match (Seq.head c) (List.Tot.hd v) `star` seq_list_match (Seq.tail c) (List.Tot.tl v) item_match) = if Nil? v then begin rewrite (seq_list_match c v item_match) (seq_list_match_nil0 c); let _ = gen_elim () in assert False; rewrite // by contradiction emp (item_match (Seq.head c) (List.Tot.hd v) `star` seq_list_match (Seq.tail c) (List.Tot.tl v) item_match) end else begin seq_list_match_cons_eq c v item_match; noop (); rewrite (seq_list_match c v item_match) (seq_list_match_cons0 c v item_match seq_list_match); let _ = gen_elim () in let prf : squash (Cons? v /\ Seq.length c > 0) = () in let c1 = vpattern (fun c1 -> item_match c1 (List.Tot.hd v)) in let c2 = vpattern (fun c2 -> seq_list_match c2 (List.Tot.tl v) item_match) in Seq.lemma_cons_inj c1 (Seq.head c) c2 (Seq.tail c); vpattern_rewrite (fun c1 -> item_match c1 (List.Tot.hd v)) (Seq.head c); vpattern_rewrite (fun c2 -> seq_list_match c2 (List.Tot.tl v) item_match) (Seq.tail c); prf end // this one cannot be proven with seq_seq_match because of the << refinement in the type of item_match let rec seq_list_match_weaken (#opened: _) (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match1 item_match2: (t -> (v': t' { v' << v }) -> vprop)) (prf: ( (#opened: _) -> (c': t) -> (v': t' { v' << v }) -> STGhostT unit opened (item_match1 c' v') (fun _ -> item_match2 c' v') )) : STGhostT unit opened (seq_list_match c v item_match1) (fun _ -> seq_list_match c v item_match2) (decreases v) = if Nil? v then rewrite (seq_list_match c v item_match1) (seq_list_match c v item_match2) else begin let _ : squash (Cons? v) = () in seq_list_match_cons_eq c v item_match1; seq_list_match_cons_eq c v item_match2; rewrite (seq_list_match c v item_match1) (seq_list_match_cons0 c v item_match1 seq_list_match); let _ = gen_elim () in prf _ _; seq_list_match_weaken _ (List.Tot.tl v) item_match1 item_match2 prf; rewrite (seq_list_match_cons0 c v item_match2 seq_list_match) (seq_list_match c v item_match2) end (* `seq_seq_match` describes how to match a sequence of low-level values (the low-level contents of an array) with a sequence of high-level values. Contrary to `seq_list_match`, `seq_seq_match` is not meant to be usable within (mutually) recursive definitions of matching functions on the type of high-level values, because no lemma ensures that `Seq.index s i << s` *)
{ "checked_file": "/", "dependencies": [ "Steel.ST.OnRange.fsti.checked", "Steel.ST.GenElim.fsti.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Steel.ST.SeqMatch.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.OnRange", "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
p: (_: t1 -> _: t2 -> Steel.Effect.Common.vprop) -> c: FStar.Seq.Base.seq t1 -> l: FStar.Seq.Base.seq t2 -> i: Prims.nat -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.Effect.Common.vprop", "FStar.Seq.Base.seq", "Prims.nat", "Prims.op_AmpAmp", "Prims.op_LessThan", "FStar.Seq.Base.length", "FStar.Seq.Base.index", "Prims.bool", "Steel.ST.Util.pure", "Prims.squash", "Prims.l_False" ]
[]
false
false
false
true
false
let seq_seq_match_item (#t1 #t2: Type) (p: (t1 -> t2 -> vprop)) (c: Seq.seq t1) (l: Seq.seq t2) (i: nat) : Tot vprop =
if i < Seq.length c && i < Seq.length l then p (Seq.index c i) (Seq.index l i) else pure (squash False)
false
Steel.ST.SeqMatch.fst
Steel.ST.SeqMatch.seq_map
val seq_map (#t1 #t2: Type) (f: (t1 -> t2)) (s: Seq.seq t1) : Tot (Seq.seq t2)
val seq_map (#t1 #t2: Type) (f: (t1 -> t2)) (s: Seq.seq t1) : Tot (Seq.seq t2)
let seq_map (#t1 #t2: Type) (f: t1 -> t2) (s: Seq.seq t1) : Tot (Seq.seq t2) = Seq.init (Seq.length s) (fun i -> f (Seq.index s i))
{ "file_name": "lib/steel/Steel.ST.SeqMatch.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 54, "end_line": 599, "start_col": 0, "start_line": 598 }
module Steel.ST.SeqMatch include Steel.ST.OnRange open Steel.ST.GenElim module Seq = FStar.Seq module SZ = FStar.SizeT (* `seq_list_match` describes how to match a sequence of low-level values (the low-level contents of an array) with a list of high-level values. `seq_list_match` is carefully designed to be usable within (mutually) recursive definitions of matching functions on the type of high-level values. *) [@@__reduce__] let seq_list_match_nil0 (#t: Type) (c: Seq.seq t) : Tot vprop = pure (c `Seq.equal` Seq.empty) [@@__reduce__] let seq_list_match_cons0 (#t #t': Type) (c: Seq.seq t) (l: list t' { Cons? l }) (item_match: (t -> (v': t' { v' << l }) -> vprop)) (seq_list_match: (Seq.seq t -> (v': list t') -> (raw_data_item_match: (t -> (v'': t' { v'' << v' }) -> vprop) { v' << l }) -> vprop)) : Tot vprop = exists_ (fun (c1: t) -> exists_ (fun (c2: Seq.seq t) -> item_match c1 (List.Tot.hd l) `star` seq_list_match c2 (List.Tot.tl l) item_match `star` pure (c `Seq.equal` Seq.cons c1 c2) )) let rec seq_list_match (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : Tot vprop (decreases v) = if Nil? v then seq_list_match_nil0 c else seq_list_match_cons0 c v item_match seq_list_match let seq_list_match_cons_eq (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : Lemma (requires (Cons? v)) (ensures ( seq_list_match c v item_match == seq_list_match_cons0 c v item_match seq_list_match )) = let a :: q = v in assert_norm (seq_list_match c (a :: q) item_match == seq_list_match_cons0 c (a :: q) item_match seq_list_match ) let seq_list_match_nil (#opened: _) (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : STGhost unit opened emp (fun _ -> seq_list_match c v item_match) (c `Seq.equal` Seq.empty /\ Nil? v) (fun _ -> True) = noop (); rewrite (seq_list_match_nil0 c) (seq_list_match c v item_match) let list_cons_precedes (#t: Type) (a: t) (q: list t) : Lemma ((a << a :: q) /\ (q << a :: q)) [SMTPat (a :: q)] = assert (List.Tot.hd (a :: q) << (a :: q)); assert (List.Tot.tl (a :: q) << (a :: q)) let seq_list_match_cons_intro (#opened: _) (#t #t': Type) (a: t) (a' : t') (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << a' :: v }) -> vprop)) : STGhostT unit opened (item_match a a' `star` seq_list_match c v item_match) (fun _ -> seq_list_match (Seq.cons a c) (a' :: v) item_match) = seq_list_match_cons_eq (Seq.cons a c) (a' :: v) item_match; noop (); rewrite (seq_list_match_cons0 (Seq.cons a c) (a' :: v) item_match seq_list_match) (seq_list_match (Seq.cons a c) (a' :: v) item_match) let seq_list_match_cons_elim (#opened: _) (#t #t': Type) (c: Seq.seq t) (v: list t' { Cons? v \/ Seq.length c > 0 }) (item_match: (t -> (v': t' { v' << v }) -> vprop)) : STGhostT (squash (Cons? v /\ Seq.length c > 0)) opened (seq_list_match c v item_match) (fun _ -> item_match (Seq.head c) (List.Tot.hd v) `star` seq_list_match (Seq.tail c) (List.Tot.tl v) item_match) = if Nil? v then begin rewrite (seq_list_match c v item_match) (seq_list_match_nil0 c); let _ = gen_elim () in assert False; rewrite // by contradiction emp (item_match (Seq.head c) (List.Tot.hd v) `star` seq_list_match (Seq.tail c) (List.Tot.tl v) item_match) end else begin seq_list_match_cons_eq c v item_match; noop (); rewrite (seq_list_match c v item_match) (seq_list_match_cons0 c v item_match seq_list_match); let _ = gen_elim () in let prf : squash (Cons? v /\ Seq.length c > 0) = () in let c1 = vpattern (fun c1 -> item_match c1 (List.Tot.hd v)) in let c2 = vpattern (fun c2 -> seq_list_match c2 (List.Tot.tl v) item_match) in Seq.lemma_cons_inj c1 (Seq.head c) c2 (Seq.tail c); vpattern_rewrite (fun c1 -> item_match c1 (List.Tot.hd v)) (Seq.head c); vpattern_rewrite (fun c2 -> seq_list_match c2 (List.Tot.tl v) item_match) (Seq.tail c); prf end // this one cannot be proven with seq_seq_match because of the << refinement in the type of item_match let rec seq_list_match_weaken (#opened: _) (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match1 item_match2: (t -> (v': t' { v' << v }) -> vprop)) (prf: ( (#opened: _) -> (c': t) -> (v': t' { v' << v }) -> STGhostT unit opened (item_match1 c' v') (fun _ -> item_match2 c' v') )) : STGhostT unit opened (seq_list_match c v item_match1) (fun _ -> seq_list_match c v item_match2) (decreases v) = if Nil? v then rewrite (seq_list_match c v item_match1) (seq_list_match c v item_match2) else begin let _ : squash (Cons? v) = () in seq_list_match_cons_eq c v item_match1; seq_list_match_cons_eq c v item_match2; rewrite (seq_list_match c v item_match1) (seq_list_match_cons0 c v item_match1 seq_list_match); let _ = gen_elim () in prf _ _; seq_list_match_weaken _ (List.Tot.tl v) item_match1 item_match2 prf; rewrite (seq_list_match_cons0 c v item_match2 seq_list_match) (seq_list_match c v item_match2) end (* `seq_seq_match` describes how to match a sequence of low-level values (the low-level contents of an array) with a sequence of high-level values. Contrary to `seq_list_match`, `seq_seq_match` is not meant to be usable within (mutually) recursive definitions of matching functions on the type of high-level values, because no lemma ensures that `Seq.index s i << s` *) let seq_seq_match_item (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: Seq.seq t2) (i: nat) : Tot vprop = if i < Seq.length c && i < Seq.length l then p (Seq.index c i) (Seq.index l i) else pure (squash False) let seq_seq_match_item_tail (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: Seq.seq t2) (delta: nat) (i: nat) : Lemma (requires ( i + delta <= Seq.length c /\ i + delta <= Seq.length l )) (ensures ( seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) i == seq_seq_match_item p c l (i + delta) )) = () [@@__reduce__] let seq_seq_match (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: Seq.seq t2) (i j: nat) : Tot vprop = on_range (seq_seq_match_item p c l) i j let seq_seq_match_length (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (s1: Seq.seq t1) (s2: Seq.seq t2) (i j: nat) : STGhost unit opened (seq_seq_match p s1 s2 i j) (fun _ -> seq_seq_match p s1 s2 i j) True (fun _ -> i <= j /\ (i == j \/ (j <= Seq.length s1 /\ j <= Seq.length s2))) = on_range_le (seq_seq_match_item p s1 s2) i j; if i = j then noop () else begin let j' = j - 1 in if j' < Seq.length s1 && j' < Seq.length s2 then noop () else begin on_range_unsnoc (seq_seq_match_item p s1 s2) i j' j; rewrite (seq_seq_match_item p _ _ _) (pure (squash False)); let _ = gen_elim () in rewrite (seq_seq_match p s1 s2 i j') (seq_seq_match p s1 s2 i j) // by contradiction end end let seq_seq_match_weaken (#opened: _) (#t1 #t2: Type) (p p': t1 -> t2 -> vprop) (w: ((x1: t1) -> (x2: t2) -> STGhostT unit opened (p x1 x2) (fun _ -> p' x1 x2) )) (c1 c1': Seq.seq t1) (c2 c2': Seq.seq t2) (i j: nat) : STGhost unit opened (seq_seq_match p c1 c2 i j) (fun _ -> seq_seq_match p' c1' c2' i j) (i <= j /\ (i == j \/ ( j <= Seq.length c1 /\ j <= Seq.length c2 /\ j <= Seq.length c1' /\ j <= Seq.length c2' /\ Seq.slice c1 i j `Seq.equal` Seq.slice c1' i j /\ Seq.slice c2 i j `Seq.equal` Seq.slice c2' i j ))) (fun _ -> True) = on_range_weaken (seq_seq_match_item p c1 c2) (seq_seq_match_item p' c1' c2') i j (fun k -> rewrite (seq_seq_match_item p c1 c2 k) (p (Seq.index (Seq.slice c1 i j) (k - i)) (Seq.index (Seq.slice c2 i j) (k - i))); w _ _; rewrite (p' _ _) (seq_seq_match_item p' c1' c2' k) ) let seq_seq_match_weaken_with_implies (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c1 c1': Seq.seq t1) (c2 c2': Seq.seq t2) (i j: nat) : STGhost unit opened (seq_seq_match p c1 c2 i j) (fun _ -> seq_seq_match p c1' c2' i j `star` (seq_seq_match p c1' c2' i j `implies_` seq_seq_match p c1 c2 i j) ) (i <= j /\ (i == j \/ ( j <= Seq.length c1 /\ j <= Seq.length c2 /\ j <= Seq.length c1' /\ j <= Seq.length c2' /\ Seq.slice c1 i j `Seq.equal` Seq.slice c1' i j /\ Seq.slice c2 i j `Seq.equal` Seq.slice c2' i j ))) (fun _ -> True) = seq_seq_match_weaken p p (fun _ _ -> noop ()) c1 c1' c2 c2' i j; intro_implies (seq_seq_match p c1' c2' i j) (seq_seq_match p c1 c2 i j) emp (fun _ -> seq_seq_match_weaken p p (fun _ _ -> noop ()) c1' c1 c2' c2 i j ) (* Going between `seq_list_match` and `seq_seq_match` *) let seq_seq_match_tail_elim (#t1 #t2: Type) (#opened: _) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: Seq.seq (t2)) (delta: nat { delta <= Seq.length c /\ delta <= Seq.length l }) (i j: nat) : STGhostT unit opened (seq_seq_match p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) i j) (fun _ -> seq_seq_match p c l (i + delta) (j + delta)) = on_range_le (seq_seq_match_item p _ _) _ _; on_range_weaken_and_shift (seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l))) (seq_seq_match_item p c l) delta i j (fun k -> if k < Seq.length c - delta && k < Seq.length l - delta then begin seq_seq_match_item_tail p c l delta k; rewrite (seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) k) (seq_seq_match_item p c l (k + delta)) end else begin rewrite (seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) k) (pure (squash False)); let _ = gen_elim () in rewrite emp (seq_seq_match_item p c l (k + delta)) // by contradiction end ) (i + delta) (j + delta) let seq_seq_match_tail_intro (#t1 #t2: Type) (#opened: _) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: Seq.seq t2) (delta: nat { delta <= Seq.length c /\ delta <= Seq.length l }) (i: nat { delta <= i }) (j: nat) : STGhostT (squash (i <= j)) opened (seq_seq_match p c l i j) (fun _ -> seq_seq_match p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) (i - delta) (j - delta)) = on_range_le (seq_seq_match_item p _ _) _ _; on_range_weaken_and_shift (seq_seq_match_item p c l) (seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l))) (0 - delta) i j (fun k -> if k < Seq.length c && k < Seq.length l then begin seq_seq_match_item_tail p c l delta (k - delta); rewrite (seq_seq_match_item p c l k) (seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) (k + (0 - delta))) end else begin rewrite (seq_seq_match_item p c l k) (pure (squash False)); let _ = gen_elim () in rewrite emp (seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) (k + (0 - delta))) // by contradiction end ) (i - delta) (j - delta) let rec seq_seq_match_seq_list_match (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: list t2) : STGhost unit opened (seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l)) (fun _ -> seq_list_match c l p) (Seq.length c == List.Tot.length l) (fun _ -> True) (decreases l) = match l with | [] -> drop (seq_seq_match p _ _ _ _); rewrite (seq_list_match_nil0 c) (seq_list_match c l p) | a :: q -> Seq.lemma_seq_of_list_induction (a :: q); seq_list_match_cons_eq c l p; on_range_uncons (seq_seq_match_item p _ _) _ 1 _; rewrite (seq_seq_match_item p _ _ _) (p (Seq.head c) (List.Tot.hd l)); let _ = seq_seq_match_tail_intro p _ _ 1 _ _ in rewrite (seq_seq_match p _ _ _ _) (seq_seq_match p (Seq.tail c) (Seq.seq_of_list (List.Tot.tl l)) 0 (List.Tot.length (List.Tot.tl l))); seq_seq_match_seq_list_match p _ (List.Tot.tl l); rewrite (seq_list_match_cons0 c l p seq_list_match) (seq_list_match c l p) let rec seq_list_match_seq_seq_match (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: list t2) : STGhost unit opened (seq_list_match c l p) (fun _ -> seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l)) True (fun _ -> Seq.length c == List.Tot.length l) (decreases l) = match l with | [] -> rewrite (seq_list_match c l p) (seq_list_match_nil0 c); let _ = gen_elim () in on_range_empty (seq_seq_match_item p c (Seq.seq_of_list l)) 0 (List.Tot.length l) | a :: q -> let _l_nonempty : squash (Cons? l) = () in Seq.lemma_seq_of_list_induction (a :: q); seq_list_match_cons_eq c l p; noop (); rewrite (seq_list_match c l p) (seq_list_match_cons0 c l p seq_list_match); let _ = gen_elim () in let a' = vpattern (fun a' -> p a' _) in let c' = vpattern (fun c' -> seq_list_match c' _ _) in Seq.lemma_cons_inj (Seq.head c) a' (Seq.tail c) c'; assert (a' == Seq.head c); assert (c' == Seq.tail c); noop (); seq_list_match_seq_seq_match p _ _; rewrite (seq_seq_match p _ _ _ _) (seq_seq_match p (Seq.slice c 1 (Seq.length c)) (Seq.slice (Seq.seq_of_list l) 1 (Seq.length (Seq.seq_of_list l))) 0 (List.Tot.length (List.Tot.tl l))); let _ = seq_seq_match_tail_elim p c (Seq.seq_of_list l) 1 0 (List.Tot.length (List.Tot.tl l)) in rewrite (seq_seq_match p _ _ _ _) (seq_seq_match p c (Seq.seq_of_list l) 1 (List.Tot.length l)); rewrite (p _ _) (seq_seq_match_item p c (Seq.seq_of_list l) 0); on_range_cons (seq_seq_match_item p _ _) 0 1 (List.Tot.length l) let seq_seq_match_seq_list_match_with_implies (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: list t2) : STGhost unit opened (seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l)) (fun _ -> seq_list_match c l p `star` (seq_list_match c l p `implies_` seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l))) (Seq.length c == List.Tot.length l) (fun _ -> True) = seq_seq_match_seq_list_match p c l; intro_implies (seq_list_match c l p) (seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l)) emp (fun _ -> seq_list_match_seq_seq_match p c l) let seq_list_match_seq_seq_match_with_implies (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: list t2) : STGhost unit opened (seq_list_match c l p) (fun _ -> seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l) `star` (seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l) `implies_` seq_list_match c l p)) True (fun _ -> Seq.length c == List.Tot.length l) = seq_list_match_seq_seq_match p c l; intro_implies (seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l)) (seq_list_match c l p) emp (fun _ -> seq_seq_match_seq_list_match p c l) let seq_list_match_length (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: list t2) : STGhost unit opened (seq_list_match c l p) (fun _ -> seq_list_match c l p) True (fun _ -> Seq.length c == List.Tot.length l) = seq_list_match_seq_seq_match_with_implies p c l; seq_seq_match_length p _ _ _ _; elim_implies (seq_seq_match p _ _ _ _) (seq_list_match c l p) let seq_list_match_index (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (s1: Seq.seq t1) (s2: list t2) (i: nat) : STGhost (squash (i < Seq.length s1 /\ List.Tot.length s2 == Seq.length s1)) opened (seq_list_match s1 s2 p) (fun _ -> p (Seq.index s1 i) (List.Tot.index s2 i) `star` (p (Seq.index s1 i) (List.Tot.index s2 i) `implies_` seq_list_match s1 s2 p) ) (i < Seq.length s1 \/ i < List.Tot.length s2) (fun _ -> True) = seq_list_match_seq_seq_match_with_implies p s1 s2; let res : squash (i < Seq.length s1 /\ List.Tot.length s2 == Seq.length s1) = () in on_range_focus (seq_seq_match_item p s1 (Seq.seq_of_list s2)) 0 i (List.Tot.length s2); rewrite_with_implies (seq_seq_match_item p _ _ _) (p (Seq.index s1 i) (List.Tot.index s2 i)); implies_trans (p (Seq.index s1 i) (List.Tot.index s2 i)) (seq_seq_match_item p _ _ _) (seq_seq_match p s1 (Seq.seq_of_list s2) 0 (List.Tot.length s2)); implies_trans (p (Seq.index s1 i) (List.Tot.index s2 i)) (seq_seq_match p s1 (Seq.seq_of_list s2) 0 (List.Tot.length s2)) (seq_list_match s1 s2 p); res (* Random array access Since `seq_list_match` is defined recursively on the list of high-level values, it is used naturally left-to-right. By contrast, in practice, an application may populate an array in a different order, or even out-of-order. `seq_seq_match` supports that scenario better, as we show below. *)
{ "checked_file": "/", "dependencies": [ "Steel.ST.OnRange.fsti.checked", "Steel.ST.GenElim.fsti.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Steel.ST.SeqMatch.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.OnRange", "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
f: (_: t1 -> t2) -> s: FStar.Seq.Base.seq t1 -> FStar.Seq.Base.seq t2
Prims.Tot
[ "total" ]
[]
[ "FStar.Seq.Base.seq", "FStar.Seq.Base.init", "FStar.Seq.Base.length", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.index" ]
[]
false
false
false
true
false
let seq_map (#t1 #t2: Type) (f: (t1 -> t2)) (s: Seq.seq t1) : Tot (Seq.seq t2) =
Seq.init (Seq.length s) (fun i -> f (Seq.index s i))
false
FStar.UInt.fst
FStar.UInt.pow2_values
val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)]
val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)]
let pow2_values x = match x with | 0 -> assert_norm (pow2 0 == 1) | 1 -> assert_norm (pow2 1 == 2) | 8 -> assert_norm (pow2 8 == 256) | 16 -> assert_norm (pow2 16 == 65536) | 31 -> assert_norm (pow2 31 == 2147483648) | 32 -> assert_norm (pow2 32 == 4294967296) | 63 -> assert_norm (pow2 63 == 9223372036854775808) | 64 -> assert_norm (pow2 64 == 18446744073709551616) | 128 -> assert_norm (pow2 128 = 0x100000000000000000000000000000000) | _ -> ()
{ "file_name": "ulib/FStar.UInt.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 13, "end_line": 36, "start_col": 0, "start_line": 25 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fst], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt.fst" }
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: Prims.nat -> FStar.Pervasives.Lemma (ensures (let p = Prims.pow2 x in (match x with | 0 -> p = 1 | 1 -> p = 2 | 8 -> p = 256 | 16 -> p = 65536 | 31 -> p = 2147483648 | 32 -> p = 4294967296 | 63 -> p = 9223372036854775808 | 64 -> p = 18446744073709551616 | 128 -> p = 0x100000000000000000000000000000000 | _ -> Prims.l_True) <: Type0)) [SMTPat (Prims.pow2 x)]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.pow2", "Prims.b2t", "Prims.op_Equality", "Prims.unit" ]
[]
false
false
true
false
false
let pow2_values x =
match x with | 0 -> assert_norm (pow2 0 == 1) | 1 -> assert_norm (pow2 1 == 2) | 8 -> assert_norm (pow2 8 == 256) | 16 -> assert_norm (pow2 16 == 65536) | 31 -> assert_norm (pow2 31 == 2147483648) | 32 -> assert_norm (pow2 32 == 4294967296) | 63 -> assert_norm (pow2 63 == 9223372036854775808) | 64 -> assert_norm (pow2 64 == 18446744073709551616) | 128 -> assert_norm (pow2 128 = 0x100000000000000000000000000000000) | _ -> ()
false
FStar.UInt.fst
FStar.UInt.incr_underspec
val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b))
val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b))
let incr_underspec #n a = if a < max_int n then a + 1 else 0
{ "file_name": "ulib/FStar.UInt.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 39, "start_col": 0, "start_line": 38 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fst], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas let pow2_values x = match x with | 0 -> assert_norm (pow2 0 == 1) | 1 -> assert_norm (pow2 1 == 2) | 8 -> assert_norm (pow2 8 == 256) | 16 -> assert_norm (pow2 16 == 65536) | 31 -> assert_norm (pow2 31 == 2147483648) | 32 -> assert_norm (pow2 32 == 4294967296) | 63 -> assert_norm (pow2 63 == 9223372036854775808) | 64 -> assert_norm (pow2 64 == 18446744073709551616) | 128 -> assert_norm (pow2 128 = 0x100000000000000000000000000000000) | _ -> ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt.fst" }
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: FStar.UInt.uint_t n -> Prims.Pure (FStar.UInt.uint_t n)
Prims.Pure
[]
[]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_LessThan", "FStar.UInt.max_int", "Prims.op_Addition", "Prims.bool" ]
[]
false
false
false
false
false
let incr_underspec #n a =
if a < max_int n then a + 1 else 0
false
FStar.UInt.fst
FStar.UInt.add_underspec
val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c))
val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c))
let add_underspec #n a b = if fits (a+b) n then a + b else 0
{ "file_name": "ulib/FStar.UInt.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 45, "start_col": 0, "start_line": 44 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fst], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas let pow2_values x = match x with | 0 -> assert_norm (pow2 0 == 1) | 1 -> assert_norm (pow2 1 == 2) | 8 -> assert_norm (pow2 8 == 256) | 16 -> assert_norm (pow2 16 == 65536) | 31 -> assert_norm (pow2 31 == 2147483648) | 32 -> assert_norm (pow2 32 == 4294967296) | 63 -> assert_norm (pow2 63 == 9223372036854775808) | 64 -> assert_norm (pow2 64 == 18446744073709551616) | 128 -> assert_norm (pow2 128 = 0x100000000000000000000000000000000) | _ -> () let incr_underspec #n a = if a < max_int n then a + 1 else 0 let decr_underspec #n a = if a > min_int n then a - 1 else 0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt.fst" }
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.Pure (FStar.UInt.uint_t n)
Prims.Pure
[]
[]
[ "Prims.nat", "FStar.UInt.uint_t", "FStar.UInt.fits", "Prims.op_Addition", "Prims.bool" ]
[]
false
false
false
false
false
let add_underspec #n a b =
if fits (a + b) n then a + b else 0
false
FStar.UInt.fst
FStar.UInt.decr_underspec
val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b))
val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b))
let decr_underspec #n a = if a > min_int n then a - 1 else 0
{ "file_name": "ulib/FStar.UInt.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 42, "start_col": 0, "start_line": 41 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fst], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas let pow2_values x = match x with | 0 -> assert_norm (pow2 0 == 1) | 1 -> assert_norm (pow2 1 == 2) | 8 -> assert_norm (pow2 8 == 256) | 16 -> assert_norm (pow2 16 == 65536) | 31 -> assert_norm (pow2 31 == 2147483648) | 32 -> assert_norm (pow2 32 == 4294967296) | 63 -> assert_norm (pow2 63 == 9223372036854775808) | 64 -> assert_norm (pow2 64 == 18446744073709551616) | 128 -> assert_norm (pow2 128 = 0x100000000000000000000000000000000) | _ -> () let incr_underspec #n a = if a < max_int n then a + 1 else 0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt.fst" }
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: FStar.UInt.uint_t n -> Prims.Pure (FStar.UInt.uint_t n)
Prims.Pure
[]
[]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_GreaterThan", "FStar.UInt.min_int", "Prims.op_Subtraction", "Prims.bool" ]
[]
false
false
false
false
false
let decr_underspec #n a =
if a > min_int n then a - 1 else 0
false
Steel.ST.SeqMatch.fst
Steel.ST.SeqMatch.item_match_option
val item_match_option (#t1 #t2: Type) (p: (t1 -> t2 -> vprop)) (x1: t1) (x2: option t2) : Tot vprop
val item_match_option (#t1 #t2: Type) (p: (t1 -> t2 -> vprop)) (x1: t1) (x2: option t2) : Tot vprop
let item_match_option (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (x1: t1) (x2: option t2) : Tot vprop = match x2 with | None -> emp | Some x2' -> p x1 x2'
{ "file_name": "lib/steel/Steel.ST.SeqMatch.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 24, "end_line": 609, "start_col": 0, "start_line": 601 }
module Steel.ST.SeqMatch include Steel.ST.OnRange open Steel.ST.GenElim module Seq = FStar.Seq module SZ = FStar.SizeT (* `seq_list_match` describes how to match a sequence of low-level values (the low-level contents of an array) with a list of high-level values. `seq_list_match` is carefully designed to be usable within (mutually) recursive definitions of matching functions on the type of high-level values. *) [@@__reduce__] let seq_list_match_nil0 (#t: Type) (c: Seq.seq t) : Tot vprop = pure (c `Seq.equal` Seq.empty) [@@__reduce__] let seq_list_match_cons0 (#t #t': Type) (c: Seq.seq t) (l: list t' { Cons? l }) (item_match: (t -> (v': t' { v' << l }) -> vprop)) (seq_list_match: (Seq.seq t -> (v': list t') -> (raw_data_item_match: (t -> (v'': t' { v'' << v' }) -> vprop) { v' << l }) -> vprop)) : Tot vprop = exists_ (fun (c1: t) -> exists_ (fun (c2: Seq.seq t) -> item_match c1 (List.Tot.hd l) `star` seq_list_match c2 (List.Tot.tl l) item_match `star` pure (c `Seq.equal` Seq.cons c1 c2) )) let rec seq_list_match (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : Tot vprop (decreases v) = if Nil? v then seq_list_match_nil0 c else seq_list_match_cons0 c v item_match seq_list_match let seq_list_match_cons_eq (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : Lemma (requires (Cons? v)) (ensures ( seq_list_match c v item_match == seq_list_match_cons0 c v item_match seq_list_match )) = let a :: q = v in assert_norm (seq_list_match c (a :: q) item_match == seq_list_match_cons0 c (a :: q) item_match seq_list_match ) let seq_list_match_nil (#opened: _) (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << v }) -> vprop)) : STGhost unit opened emp (fun _ -> seq_list_match c v item_match) (c `Seq.equal` Seq.empty /\ Nil? v) (fun _ -> True) = noop (); rewrite (seq_list_match_nil0 c) (seq_list_match c v item_match) let list_cons_precedes (#t: Type) (a: t) (q: list t) : Lemma ((a << a :: q) /\ (q << a :: q)) [SMTPat (a :: q)] = assert (List.Tot.hd (a :: q) << (a :: q)); assert (List.Tot.tl (a :: q) << (a :: q)) let seq_list_match_cons_intro (#opened: _) (#t #t': Type) (a: t) (a' : t') (c: Seq.seq t) (v: list t') (item_match: (t -> (v': t' { v' << a' :: v }) -> vprop)) : STGhostT unit opened (item_match a a' `star` seq_list_match c v item_match) (fun _ -> seq_list_match (Seq.cons a c) (a' :: v) item_match) = seq_list_match_cons_eq (Seq.cons a c) (a' :: v) item_match; noop (); rewrite (seq_list_match_cons0 (Seq.cons a c) (a' :: v) item_match seq_list_match) (seq_list_match (Seq.cons a c) (a' :: v) item_match) let seq_list_match_cons_elim (#opened: _) (#t #t': Type) (c: Seq.seq t) (v: list t' { Cons? v \/ Seq.length c > 0 }) (item_match: (t -> (v': t' { v' << v }) -> vprop)) : STGhostT (squash (Cons? v /\ Seq.length c > 0)) opened (seq_list_match c v item_match) (fun _ -> item_match (Seq.head c) (List.Tot.hd v) `star` seq_list_match (Seq.tail c) (List.Tot.tl v) item_match) = if Nil? v then begin rewrite (seq_list_match c v item_match) (seq_list_match_nil0 c); let _ = gen_elim () in assert False; rewrite // by contradiction emp (item_match (Seq.head c) (List.Tot.hd v) `star` seq_list_match (Seq.tail c) (List.Tot.tl v) item_match) end else begin seq_list_match_cons_eq c v item_match; noop (); rewrite (seq_list_match c v item_match) (seq_list_match_cons0 c v item_match seq_list_match); let _ = gen_elim () in let prf : squash (Cons? v /\ Seq.length c > 0) = () in let c1 = vpattern (fun c1 -> item_match c1 (List.Tot.hd v)) in let c2 = vpattern (fun c2 -> seq_list_match c2 (List.Tot.tl v) item_match) in Seq.lemma_cons_inj c1 (Seq.head c) c2 (Seq.tail c); vpattern_rewrite (fun c1 -> item_match c1 (List.Tot.hd v)) (Seq.head c); vpattern_rewrite (fun c2 -> seq_list_match c2 (List.Tot.tl v) item_match) (Seq.tail c); prf end // this one cannot be proven with seq_seq_match because of the << refinement in the type of item_match let rec seq_list_match_weaken (#opened: _) (#t #t': Type) (c: Seq.seq t) (v: list t') (item_match1 item_match2: (t -> (v': t' { v' << v }) -> vprop)) (prf: ( (#opened: _) -> (c': t) -> (v': t' { v' << v }) -> STGhostT unit opened (item_match1 c' v') (fun _ -> item_match2 c' v') )) : STGhostT unit opened (seq_list_match c v item_match1) (fun _ -> seq_list_match c v item_match2) (decreases v) = if Nil? v then rewrite (seq_list_match c v item_match1) (seq_list_match c v item_match2) else begin let _ : squash (Cons? v) = () in seq_list_match_cons_eq c v item_match1; seq_list_match_cons_eq c v item_match2; rewrite (seq_list_match c v item_match1) (seq_list_match_cons0 c v item_match1 seq_list_match); let _ = gen_elim () in prf _ _; seq_list_match_weaken _ (List.Tot.tl v) item_match1 item_match2 prf; rewrite (seq_list_match_cons0 c v item_match2 seq_list_match) (seq_list_match c v item_match2) end (* `seq_seq_match` describes how to match a sequence of low-level values (the low-level contents of an array) with a sequence of high-level values. Contrary to `seq_list_match`, `seq_seq_match` is not meant to be usable within (mutually) recursive definitions of matching functions on the type of high-level values, because no lemma ensures that `Seq.index s i << s` *) let seq_seq_match_item (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: Seq.seq t2) (i: nat) : Tot vprop = if i < Seq.length c && i < Seq.length l then p (Seq.index c i) (Seq.index l i) else pure (squash False) let seq_seq_match_item_tail (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: Seq.seq t2) (delta: nat) (i: nat) : Lemma (requires ( i + delta <= Seq.length c /\ i + delta <= Seq.length l )) (ensures ( seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) i == seq_seq_match_item p c l (i + delta) )) = () [@@__reduce__] let seq_seq_match (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: Seq.seq t2) (i j: nat) : Tot vprop = on_range (seq_seq_match_item p c l) i j let seq_seq_match_length (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (s1: Seq.seq t1) (s2: Seq.seq t2) (i j: nat) : STGhost unit opened (seq_seq_match p s1 s2 i j) (fun _ -> seq_seq_match p s1 s2 i j) True (fun _ -> i <= j /\ (i == j \/ (j <= Seq.length s1 /\ j <= Seq.length s2))) = on_range_le (seq_seq_match_item p s1 s2) i j; if i = j then noop () else begin let j' = j - 1 in if j' < Seq.length s1 && j' < Seq.length s2 then noop () else begin on_range_unsnoc (seq_seq_match_item p s1 s2) i j' j; rewrite (seq_seq_match_item p _ _ _) (pure (squash False)); let _ = gen_elim () in rewrite (seq_seq_match p s1 s2 i j') (seq_seq_match p s1 s2 i j) // by contradiction end end let seq_seq_match_weaken (#opened: _) (#t1 #t2: Type) (p p': t1 -> t2 -> vprop) (w: ((x1: t1) -> (x2: t2) -> STGhostT unit opened (p x1 x2) (fun _ -> p' x1 x2) )) (c1 c1': Seq.seq t1) (c2 c2': Seq.seq t2) (i j: nat) : STGhost unit opened (seq_seq_match p c1 c2 i j) (fun _ -> seq_seq_match p' c1' c2' i j) (i <= j /\ (i == j \/ ( j <= Seq.length c1 /\ j <= Seq.length c2 /\ j <= Seq.length c1' /\ j <= Seq.length c2' /\ Seq.slice c1 i j `Seq.equal` Seq.slice c1' i j /\ Seq.slice c2 i j `Seq.equal` Seq.slice c2' i j ))) (fun _ -> True) = on_range_weaken (seq_seq_match_item p c1 c2) (seq_seq_match_item p' c1' c2') i j (fun k -> rewrite (seq_seq_match_item p c1 c2 k) (p (Seq.index (Seq.slice c1 i j) (k - i)) (Seq.index (Seq.slice c2 i j) (k - i))); w _ _; rewrite (p' _ _) (seq_seq_match_item p' c1' c2' k) ) let seq_seq_match_weaken_with_implies (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c1 c1': Seq.seq t1) (c2 c2': Seq.seq t2) (i j: nat) : STGhost unit opened (seq_seq_match p c1 c2 i j) (fun _ -> seq_seq_match p c1' c2' i j `star` (seq_seq_match p c1' c2' i j `implies_` seq_seq_match p c1 c2 i j) ) (i <= j /\ (i == j \/ ( j <= Seq.length c1 /\ j <= Seq.length c2 /\ j <= Seq.length c1' /\ j <= Seq.length c2' /\ Seq.slice c1 i j `Seq.equal` Seq.slice c1' i j /\ Seq.slice c2 i j `Seq.equal` Seq.slice c2' i j ))) (fun _ -> True) = seq_seq_match_weaken p p (fun _ _ -> noop ()) c1 c1' c2 c2' i j; intro_implies (seq_seq_match p c1' c2' i j) (seq_seq_match p c1 c2 i j) emp (fun _ -> seq_seq_match_weaken p p (fun _ _ -> noop ()) c1' c1 c2' c2 i j ) (* Going between `seq_list_match` and `seq_seq_match` *) let seq_seq_match_tail_elim (#t1 #t2: Type) (#opened: _) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: Seq.seq (t2)) (delta: nat { delta <= Seq.length c /\ delta <= Seq.length l }) (i j: nat) : STGhostT unit opened (seq_seq_match p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) i j) (fun _ -> seq_seq_match p c l (i + delta) (j + delta)) = on_range_le (seq_seq_match_item p _ _) _ _; on_range_weaken_and_shift (seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l))) (seq_seq_match_item p c l) delta i j (fun k -> if k < Seq.length c - delta && k < Seq.length l - delta then begin seq_seq_match_item_tail p c l delta k; rewrite (seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) k) (seq_seq_match_item p c l (k + delta)) end else begin rewrite (seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) k) (pure (squash False)); let _ = gen_elim () in rewrite emp (seq_seq_match_item p c l (k + delta)) // by contradiction end ) (i + delta) (j + delta) let seq_seq_match_tail_intro (#t1 #t2: Type) (#opened: _) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: Seq.seq t2) (delta: nat { delta <= Seq.length c /\ delta <= Seq.length l }) (i: nat { delta <= i }) (j: nat) : STGhostT (squash (i <= j)) opened (seq_seq_match p c l i j) (fun _ -> seq_seq_match p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) (i - delta) (j - delta)) = on_range_le (seq_seq_match_item p _ _) _ _; on_range_weaken_and_shift (seq_seq_match_item p c l) (seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l))) (0 - delta) i j (fun k -> if k < Seq.length c && k < Seq.length l then begin seq_seq_match_item_tail p c l delta (k - delta); rewrite (seq_seq_match_item p c l k) (seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) (k + (0 - delta))) end else begin rewrite (seq_seq_match_item p c l k) (pure (squash False)); let _ = gen_elim () in rewrite emp (seq_seq_match_item p (Seq.slice c delta (Seq.length c)) (Seq.slice l delta (Seq.length l)) (k + (0 - delta))) // by contradiction end ) (i - delta) (j - delta) let rec seq_seq_match_seq_list_match (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: list t2) : STGhost unit opened (seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l)) (fun _ -> seq_list_match c l p) (Seq.length c == List.Tot.length l) (fun _ -> True) (decreases l) = match l with | [] -> drop (seq_seq_match p _ _ _ _); rewrite (seq_list_match_nil0 c) (seq_list_match c l p) | a :: q -> Seq.lemma_seq_of_list_induction (a :: q); seq_list_match_cons_eq c l p; on_range_uncons (seq_seq_match_item p _ _) _ 1 _; rewrite (seq_seq_match_item p _ _ _) (p (Seq.head c) (List.Tot.hd l)); let _ = seq_seq_match_tail_intro p _ _ 1 _ _ in rewrite (seq_seq_match p _ _ _ _) (seq_seq_match p (Seq.tail c) (Seq.seq_of_list (List.Tot.tl l)) 0 (List.Tot.length (List.Tot.tl l))); seq_seq_match_seq_list_match p _ (List.Tot.tl l); rewrite (seq_list_match_cons0 c l p seq_list_match) (seq_list_match c l p) let rec seq_list_match_seq_seq_match (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: list t2) : STGhost unit opened (seq_list_match c l p) (fun _ -> seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l)) True (fun _ -> Seq.length c == List.Tot.length l) (decreases l) = match l with | [] -> rewrite (seq_list_match c l p) (seq_list_match_nil0 c); let _ = gen_elim () in on_range_empty (seq_seq_match_item p c (Seq.seq_of_list l)) 0 (List.Tot.length l) | a :: q -> let _l_nonempty : squash (Cons? l) = () in Seq.lemma_seq_of_list_induction (a :: q); seq_list_match_cons_eq c l p; noop (); rewrite (seq_list_match c l p) (seq_list_match_cons0 c l p seq_list_match); let _ = gen_elim () in let a' = vpattern (fun a' -> p a' _) in let c' = vpattern (fun c' -> seq_list_match c' _ _) in Seq.lemma_cons_inj (Seq.head c) a' (Seq.tail c) c'; assert (a' == Seq.head c); assert (c' == Seq.tail c); noop (); seq_list_match_seq_seq_match p _ _; rewrite (seq_seq_match p _ _ _ _) (seq_seq_match p (Seq.slice c 1 (Seq.length c)) (Seq.slice (Seq.seq_of_list l) 1 (Seq.length (Seq.seq_of_list l))) 0 (List.Tot.length (List.Tot.tl l))); let _ = seq_seq_match_tail_elim p c (Seq.seq_of_list l) 1 0 (List.Tot.length (List.Tot.tl l)) in rewrite (seq_seq_match p _ _ _ _) (seq_seq_match p c (Seq.seq_of_list l) 1 (List.Tot.length l)); rewrite (p _ _) (seq_seq_match_item p c (Seq.seq_of_list l) 0); on_range_cons (seq_seq_match_item p _ _) 0 1 (List.Tot.length l) let seq_seq_match_seq_list_match_with_implies (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: list t2) : STGhost unit opened (seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l)) (fun _ -> seq_list_match c l p `star` (seq_list_match c l p `implies_` seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l))) (Seq.length c == List.Tot.length l) (fun _ -> True) = seq_seq_match_seq_list_match p c l; intro_implies (seq_list_match c l p) (seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l)) emp (fun _ -> seq_list_match_seq_seq_match p c l) let seq_list_match_seq_seq_match_with_implies (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: list t2) : STGhost unit opened (seq_list_match c l p) (fun _ -> seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l) `star` (seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l) `implies_` seq_list_match c l p)) True (fun _ -> Seq.length c == List.Tot.length l) = seq_list_match_seq_seq_match p c l; intro_implies (seq_seq_match p c (Seq.seq_of_list l) 0 (List.Tot.length l)) (seq_list_match c l p) emp (fun _ -> seq_seq_match_seq_list_match p c l) let seq_list_match_length (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (c: Seq.seq t1) (l: list t2) : STGhost unit opened (seq_list_match c l p) (fun _ -> seq_list_match c l p) True (fun _ -> Seq.length c == List.Tot.length l) = seq_list_match_seq_seq_match_with_implies p c l; seq_seq_match_length p _ _ _ _; elim_implies (seq_seq_match p _ _ _ _) (seq_list_match c l p) let seq_list_match_index (#opened: _) (#t1 #t2: Type) (p: t1 -> t2 -> vprop) (s1: Seq.seq t1) (s2: list t2) (i: nat) : STGhost (squash (i < Seq.length s1 /\ List.Tot.length s2 == Seq.length s1)) opened (seq_list_match s1 s2 p) (fun _ -> p (Seq.index s1 i) (List.Tot.index s2 i) `star` (p (Seq.index s1 i) (List.Tot.index s2 i) `implies_` seq_list_match s1 s2 p) ) (i < Seq.length s1 \/ i < List.Tot.length s2) (fun _ -> True) = seq_list_match_seq_seq_match_with_implies p s1 s2; let res : squash (i < Seq.length s1 /\ List.Tot.length s2 == Seq.length s1) = () in on_range_focus (seq_seq_match_item p s1 (Seq.seq_of_list s2)) 0 i (List.Tot.length s2); rewrite_with_implies (seq_seq_match_item p _ _ _) (p (Seq.index s1 i) (List.Tot.index s2 i)); implies_trans (p (Seq.index s1 i) (List.Tot.index s2 i)) (seq_seq_match_item p _ _ _) (seq_seq_match p s1 (Seq.seq_of_list s2) 0 (List.Tot.length s2)); implies_trans (p (Seq.index s1 i) (List.Tot.index s2 i)) (seq_seq_match p s1 (Seq.seq_of_list s2) 0 (List.Tot.length s2)) (seq_list_match s1 s2 p); res (* Random array access Since `seq_list_match` is defined recursively on the list of high-level values, it is used naturally left-to-right. By contrast, in practice, an application may populate an array in a different order, or even out-of-order. `seq_seq_match` supports that scenario better, as we show below. *) let seq_map (#t1 #t2: Type) (f: t1 -> t2) (s: Seq.seq t1) : Tot (Seq.seq t2) = Seq.init (Seq.length s) (fun i -> f (Seq.index s i))
{ "checked_file": "/", "dependencies": [ "Steel.ST.OnRange.fsti.checked", "Steel.ST.GenElim.fsti.checked", "prims.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Steel.ST.SeqMatch.fst" }
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "Steel.ST.GenElim", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.OnRange", "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
p: (_: t1 -> _: t2 -> Steel.Effect.Common.vprop) -> x1: t1 -> x2: FStar.Pervasives.Native.option t2 -> Steel.Effect.Common.vprop
Prims.Tot
[ "total" ]
[]
[ "Steel.Effect.Common.vprop", "FStar.Pervasives.Native.option", "Steel.Effect.Common.emp" ]
[]
false
false
false
true
false
let item_match_option (#t1 #t2: Type) (p: (t1 -> t2 -> vprop)) (x1: t1) (x2: option t2) : Tot vprop =
match x2 with | None -> emp | Some x2' -> p x1 x2'
false
FStar.UInt.fst
FStar.UInt.sub_underspec
val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c))
val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c))
let sub_underspec #n a b = if fits (a-b) n then a - b else 0
{ "file_name": "ulib/FStar.UInt.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 48, "start_col": 0, "start_line": 47 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fst], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas let pow2_values x = match x with | 0 -> assert_norm (pow2 0 == 1) | 1 -> assert_norm (pow2 1 == 2) | 8 -> assert_norm (pow2 8 == 256) | 16 -> assert_norm (pow2 16 == 65536) | 31 -> assert_norm (pow2 31 == 2147483648) | 32 -> assert_norm (pow2 32 == 4294967296) | 63 -> assert_norm (pow2 63 == 9223372036854775808) | 64 -> assert_norm (pow2 64 == 18446744073709551616) | 128 -> assert_norm (pow2 128 = 0x100000000000000000000000000000000) | _ -> () let incr_underspec #n a = if a < max_int n then a + 1 else 0 let decr_underspec #n a = if a > min_int n then a - 1 else 0 let add_underspec #n a b = if fits (a+b) n then a + b else 0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt.fst" }
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.Pure (FStar.UInt.uint_t n)
Prims.Pure
[]
[]
[ "Prims.nat", "FStar.UInt.uint_t", "FStar.UInt.fits", "Prims.op_Subtraction", "Prims.bool" ]
[]
false
false
false
false
false
let sub_underspec #n a b =
if fits (a - b) n then a - b else 0
false
FStar.UInt.fst
FStar.UInt.mul_underspec
val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c))
val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c))
let mul_underspec #n a b = if fits (a*b) n then a * b else 0
{ "file_name": "ulib/FStar.UInt.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 35, "end_line": 51, "start_col": 0, "start_line": 50 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fst], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas let pow2_values x = match x with | 0 -> assert_norm (pow2 0 == 1) | 1 -> assert_norm (pow2 1 == 2) | 8 -> assert_norm (pow2 8 == 256) | 16 -> assert_norm (pow2 16 == 65536) | 31 -> assert_norm (pow2 31 == 2147483648) | 32 -> assert_norm (pow2 32 == 4294967296) | 63 -> assert_norm (pow2 63 == 9223372036854775808) | 64 -> assert_norm (pow2 64 == 18446744073709551616) | 128 -> assert_norm (pow2 128 = 0x100000000000000000000000000000000) | _ -> () let incr_underspec #n a = if a < max_int n then a + 1 else 0 let decr_underspec #n a = if a > min_int n then a - 1 else 0 let add_underspec #n a b = if fits (a+b) n then a + b else 0 let sub_underspec #n a b = if fits (a-b) n then a - b else 0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt.fst" }
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.Pure (FStar.UInt.uint_t n)
Prims.Pure
[]
[]
[ "Prims.nat", "FStar.UInt.uint_t", "FStar.UInt.fits", "FStar.Mul.op_Star", "Prims.bool" ]
[]
false
false
false
false
false
let mul_underspec #n a b =
if fits (a * b) n then a * b else 0
false
FStar.UInt.fst
FStar.UInt.div_size
val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n))
val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n))
let div_size #n a b = FStar.Math.Lib.slash_decr_axiom a b; ()
{ "file_name": "ulib/FStar.UInt.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 41, "end_line": 61, "start_col": 0, "start_line": 60 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fst], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas let pow2_values x = match x with | 0 -> assert_norm (pow2 0 == 1) | 1 -> assert_norm (pow2 1 == 2) | 8 -> assert_norm (pow2 8 == 256) | 16 -> assert_norm (pow2 16 == 65536) | 31 -> assert_norm (pow2 31 == 2147483648) | 32 -> assert_norm (pow2 32 == 4294967296) | 63 -> assert_norm (pow2 63 == 9223372036854775808) | 64 -> assert_norm (pow2 64 == 18446744073709551616) | 128 -> assert_norm (pow2 128 = 0x100000000000000000000000000000000) | _ -> () let incr_underspec #n a = if a < max_int n then a + 1 else 0 let decr_underspec #n a = if a > min_int n then a - 1 else 0 let add_underspec #n a b = if fits (a+b) n then a + b else 0 let sub_underspec #n a b = if fits (a-b) n then a - b else 0 let mul_underspec #n a b = if fits (a*b) n then a * b else 0 #push-options "--fuel 0 --ifuel 0" let lt_square_div_lt a b = () let div_underspec #n a b = if fits (a / b) n then a / b else 0 #pop-options
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt.fst" }
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n {b <> 0} -> FStar.Pervasives.Lemma (requires FStar.UInt.size a n) (ensures FStar.UInt.size (a / b) n)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "FStar.UInt.uint_t", "Prims.b2t", "Prims.op_disEquality", "Prims.int", "Prims.unit", "FStar.Math.Lib.slash_decr_axiom" ]
[]
true
false
true
false
false
let div_size #n a b =
FStar.Math.Lib.slash_decr_axiom a b; ()
false
FStar.UInt.fst
FStar.UInt.div_underspec
val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c))
val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c))
let div_underspec #n a b = if fits (a / b) n then a / b else 0
{ "file_name": "ulib/FStar.UInt.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 37, "end_line": 57, "start_col": 0, "start_line": 56 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fst], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas let pow2_values x = match x with | 0 -> assert_norm (pow2 0 == 1) | 1 -> assert_norm (pow2 1 == 2) | 8 -> assert_norm (pow2 8 == 256) | 16 -> assert_norm (pow2 16 == 65536) | 31 -> assert_norm (pow2 31 == 2147483648) | 32 -> assert_norm (pow2 32 == 4294967296) | 63 -> assert_norm (pow2 63 == 9223372036854775808) | 64 -> assert_norm (pow2 64 == 18446744073709551616) | 128 -> assert_norm (pow2 128 = 0x100000000000000000000000000000000) | _ -> () let incr_underspec #n a = if a < max_int n then a + 1 else 0 let decr_underspec #n a = if a > min_int n then a - 1 else 0 let add_underspec #n a b = if fits (a+b) n then a + b else 0 let sub_underspec #n a b = if fits (a-b) n then a - b else 0 let mul_underspec #n a b = if fits (a*b) n then a * b else 0 #push-options "--fuel 0 --ifuel 0" let lt_square_div_lt a b = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt.fst" }
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n {b <> 0} -> Prims.Pure (FStar.UInt.uint_t n)
Prims.Pure
[]
[]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.b2t", "Prims.op_disEquality", "Prims.int", "FStar.UInt.fits", "Prims.op_Division", "Prims.bool" ]
[]
false
false
false
false
false
let div_underspec #n a b =
if fits (a / b) n then a / b else 0
false
FStar.UInt.fst
FStar.UInt.to_vec_lemma_2
val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b)
val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b)
let rec to_vec_lemma_2 #n a b = if n = 0 then () else begin assert(equal (slice (to_vec b) 0 (n - 1)) (to_vec #(n - 1) (b / 2))); assert(equal (slice (to_vec a) 0 (n - 1)) (to_vec #(n - 1) (a / 2))); to_vec_lemma_2 #(n - 1) (a / 2) (b / 2); assert(a % 2 = (if index (to_vec a) (n - 1) then 1 else 0)); assert(b % 2 = (if index (to_vec b) (n - 1) then 1 else 0)); assert(a % 2 = b % 2) end
{ "file_name": "ulib/FStar.UInt.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 5, "end_line": 75, "start_col": 0, "start_line": 67 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fst], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas let pow2_values x = match x with | 0 -> assert_norm (pow2 0 == 1) | 1 -> assert_norm (pow2 1 == 2) | 8 -> assert_norm (pow2 8 == 256) | 16 -> assert_norm (pow2 16 == 65536) | 31 -> assert_norm (pow2 31 == 2147483648) | 32 -> assert_norm (pow2 32 == 4294967296) | 63 -> assert_norm (pow2 63 == 9223372036854775808) | 64 -> assert_norm (pow2 64 == 18446744073709551616) | 128 -> assert_norm (pow2 128 = 0x100000000000000000000000000000000) | _ -> () let incr_underspec #n a = if a < max_int n then a + 1 else 0 let decr_underspec #n a = if a > min_int n then a - 1 else 0 let add_underspec #n a b = if fits (a+b) n then a + b else 0 let sub_underspec #n a b = if fits (a-b) n then a - b else 0 let mul_underspec #n a b = if fits (a*b) n then a * b else 0 #push-options "--fuel 0 --ifuel 0" let lt_square_div_lt a b = () let div_underspec #n a b = if fits (a / b) n then a / b else 0 #pop-options let div_size #n a b = FStar.Math.Lib.slash_decr_axiom a b; () open FStar.Seq let to_vec_lemma_1 #n a b = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.equal (FStar.UInt.to_vec a) (FStar.UInt.to_vec b)) (ensures a = b)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_Equality", "Prims.int", "Prims.bool", "Prims._assert", "Prims.b2t", "Prims.op_Modulus", "Prims.unit", "FStar.Seq.Base.index", "FStar.UInt.to_vec", "Prims.op_Subtraction", "FStar.UInt.to_vec_lemma_2", "Prims.op_Division", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice" ]
[ "recursion" ]
false
false
true
false
false
let rec to_vec_lemma_2 #n a b =
if n = 0 then () else (assert (equal (slice (to_vec b) 0 (n - 1)) (to_vec #(n - 1) (b / 2))); assert (equal (slice (to_vec a) 0 (n - 1)) (to_vec #(n - 1) (a / 2))); to_vec_lemma_2 #(n - 1) (a / 2) (b / 2); assert (a % 2 = (if index (to_vec a) (n - 1) then 1 else 0)); assert (b % 2 = (if index (to_vec b) (n - 1) then 1 else 0)); assert (a % 2 = b % 2))
false
FStar.UInt.fst
FStar.UInt.inverse_num_lemma
val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))]
val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))]
let inverse_num_lemma #n num = to_vec_lemma_2 #n num (from_vec (to_vec num))
{ "file_name": "ulib/FStar.UInt.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 76, "end_line": 84, "start_col": 0, "start_line": 84 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fst], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas let pow2_values x = match x with | 0 -> assert_norm (pow2 0 == 1) | 1 -> assert_norm (pow2 1 == 2) | 8 -> assert_norm (pow2 8 == 256) | 16 -> assert_norm (pow2 16 == 65536) | 31 -> assert_norm (pow2 31 == 2147483648) | 32 -> assert_norm (pow2 32 == 4294967296) | 63 -> assert_norm (pow2 63 == 9223372036854775808) | 64 -> assert_norm (pow2 64 == 18446744073709551616) | 128 -> assert_norm (pow2 128 = 0x100000000000000000000000000000000) | _ -> () let incr_underspec #n a = if a < max_int n then a + 1 else 0 let decr_underspec #n a = if a > min_int n then a - 1 else 0 let add_underspec #n a b = if fits (a+b) n then a + b else 0 let sub_underspec #n a b = if fits (a-b) n then a - b else 0 let mul_underspec #n a b = if fits (a*b) n then a * b else 0 #push-options "--fuel 0 --ifuel 0" let lt_square_div_lt a b = () let div_underspec #n a b = if fits (a / b) n then a / b else 0 #pop-options let div_size #n a b = FStar.Math.Lib.slash_decr_axiom a b; () open FStar.Seq let to_vec_lemma_1 #n a b = () let rec to_vec_lemma_2 #n a b = if n = 0 then () else begin assert(equal (slice (to_vec b) 0 (n - 1)) (to_vec #(n - 1) (b / 2))); assert(equal (slice (to_vec a) 0 (n - 1)) (to_vec #(n - 1) (a / 2))); to_vec_lemma_2 #(n - 1) (a / 2) (b / 2); assert(a % 2 = (if index (to_vec a) (n - 1) then 1 else 0)); assert(b % 2 = (if index (to_vec b) (n - 1) then 1 else 0)); assert(a % 2 = b % 2) end let rec inverse_aux #n vec i = if i = n - 1 then assert((from_vec vec) % 2 = (if index vec (n - 1) then 1 else 0)) else inverse_aux #(n - 1) (slice vec 0 (n - 1)) i let inverse_vec_lemma #n vec = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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
num: FStar.UInt.uint_t n -> FStar.Pervasives.Lemma (ensures num = FStar.UInt.from_vec (FStar.UInt.to_vec num)) [SMTPat (FStar.UInt.from_vec (FStar.UInt.to_vec num))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "FStar.UInt.uint_t", "FStar.UInt.to_vec_lemma_2", "FStar.UInt.from_vec", "FStar.UInt.to_vec", "Prims.unit" ]
[]
true
false
true
false
false
let inverse_num_lemma #n num =
to_vec_lemma_2 #n num (from_vec (to_vec num))
false
FStar.UInt.fst
FStar.UInt.from_vec_lemma_2
val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b)
val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b)
let from_vec_lemma_2 #n a b = inverse_vec_lemma a; inverse_vec_lemma b
{ "file_name": "ulib/FStar.UInt.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 70, "end_line": 88, "start_col": 0, "start_line": 88 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fst], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas let pow2_values x = match x with | 0 -> assert_norm (pow2 0 == 1) | 1 -> assert_norm (pow2 1 == 2) | 8 -> assert_norm (pow2 8 == 256) | 16 -> assert_norm (pow2 16 == 65536) | 31 -> assert_norm (pow2 31 == 2147483648) | 32 -> assert_norm (pow2 32 == 4294967296) | 63 -> assert_norm (pow2 63 == 9223372036854775808) | 64 -> assert_norm (pow2 64 == 18446744073709551616) | 128 -> assert_norm (pow2 128 = 0x100000000000000000000000000000000) | _ -> () let incr_underspec #n a = if a < max_int n then a + 1 else 0 let decr_underspec #n a = if a > min_int n then a - 1 else 0 let add_underspec #n a b = if fits (a+b) n then a + b else 0 let sub_underspec #n a b = if fits (a-b) n then a - b else 0 let mul_underspec #n a b = if fits (a*b) n then a * b else 0 #push-options "--fuel 0 --ifuel 0" let lt_square_div_lt a b = () let div_underspec #n a b = if fits (a / b) n then a / b else 0 #pop-options let div_size #n a b = FStar.Math.Lib.slash_decr_axiom a b; () open FStar.Seq let to_vec_lemma_1 #n a b = () let rec to_vec_lemma_2 #n a b = if n = 0 then () else begin assert(equal (slice (to_vec b) 0 (n - 1)) (to_vec #(n - 1) (b / 2))); assert(equal (slice (to_vec a) 0 (n - 1)) (to_vec #(n - 1) (a / 2))); to_vec_lemma_2 #(n - 1) (a / 2) (b / 2); assert(a % 2 = (if index (to_vec a) (n - 1) then 1 else 0)); assert(b % 2 = (if index (to_vec b) (n - 1) then 1 else 0)); assert(a % 2 = b % 2) end let rec inverse_aux #n vec i = if i = n - 1 then assert((from_vec vec) % 2 = (if index vec (n - 1) then 1 else 0)) else inverse_aux #(n - 1) (slice vec 0 (n - 1)) i let inverse_vec_lemma #n vec = () let inverse_num_lemma #n num = to_vec_lemma_2 #n num (from_vec (to_vec num)) let from_vec_lemma_1 #n a b = ()
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lib.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked", "FStar.BitVector.fst.checked" ], "interface_file": true, "source_file": "FStar.UInt.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "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: FStar.BitVector.bv_t n -> b: FStar.BitVector.bv_t n -> FStar.Pervasives.Lemma (requires FStar.UInt.from_vec a = FStar.UInt.from_vec b) (ensures FStar.Seq.Base.equal a b)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "FStar.BitVector.bv_t", "FStar.UInt.inverse_vec_lemma", "Prims.unit" ]
[]
true
false
true
false
false
let from_vec_lemma_2 #n a b =
inverse_vec_lemma a; inverse_vec_lemma b
false