effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
Prims.Tot
val decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 {y == decode_bounded_integer 3 (B32.reveal b)})
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b
val decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 {y == decode_bounded_integer 3 (B32.reveal b)}) let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 {y == decode_bounded_integer 3 (B32.reveal b)}) =
false
null
false
be_to_n_3 b
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Bytes.lbytes", "LowParse.SLow.BoundedInt.be_to_n_3", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.eq2", "LowParse.Spec.BoundedInt.decode_bounded_integer", "FStar.Bytes.reveal" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 {y == decode_bounded_integer 3 (B32.reveal b)})
[]
LowParse.SLow.BoundedInt.decode32_bounded_integer_3
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
b: FStar.Bytes.lbytes 3 -> y: LowParse.Spec.BoundedInt.bounded_integer 3 {y == LowParse.Spec.BoundedInt.decode_bounded_integer 3 (FStar.Bytes.reveal b)}
{ "end_col": 13, "end_line": 46, "start_col": 2, "start_line": 46 }
Prims.Tot
val bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 {y == bounded_integer_of_le 2 (B32.reveal b)})
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b
val bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 {y == bounded_integer_of_le 2 (B32.reveal b)}) let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 {y == bounded_integer_of_le 2 (B32.reveal b)}) =
false
null
false
le_to_n_2 b
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Bytes.lbytes", "LowParse.SLow.BoundedInt.le_to_n_2", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.eq2", "LowParse.Spec.BoundedInt.bounded_integer_of_le", "FStar.Bytes.reveal" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 {y == bounded_integer_of_le 2 (B32.reveal b)})
[]
LowParse.SLow.BoundedInt.bounded_integer_of_le_32_2
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
b: FStar.Bytes.lbytes 2 -> y: LowParse.Spec.BoundedInt.bounded_integer 2 {y == LowParse.Spec.BoundedInt.bounded_integer_of_le 2 (FStar.Bytes.reveal b)}
{ "end_col": 13, "end_line": 142, "start_col": 2, "start_line": 142 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let n_to_le_3 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.n_to_le_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_n_to_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val n_to_le_3 : LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3
[]
LowParse.SLow.BoundedInt.n_to_le_3
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3
{ "end_col": 112, "end_line": 220, "start_col": 16, "start_line": 220 }
Prims.Tot
val bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 {y == bounded_integer_of_le 3 (B32.reveal b)})
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b
val bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 {y == bounded_integer_of_le 3 (B32.reveal b)}) let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 {y == bounded_integer_of_le 3 (B32.reveal b)}) =
false
null
false
le_to_n_3 b
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Bytes.lbytes", "LowParse.SLow.BoundedInt.le_to_n_3", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.eq2", "LowParse.Spec.BoundedInt.bounded_integer_of_le", "FStar.Bytes.reveal" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 {y == bounded_integer_of_le 3 (B32.reveal b)})
[]
LowParse.SLow.BoundedInt.bounded_integer_of_le_32_3
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
b: FStar.Bytes.lbytes 3 -> y: LowParse.Spec.BoundedInt.bounded_integer 3 {y == LowParse.Spec.BoundedInt.bounded_integer_of_le 3 (FStar.Bytes.reveal b)}
{ "end_col": 13, "end_line": 152, "start_col": 2, "start_line": 152 }
Prims.Tot
val parse32_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul
val parse32_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) let parse32_bounded_int32_4 min max =
false
null
false
parse32_bounded_int32' min max 4ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "Prims.op_LessThan", "LowParse.SLow.BoundedInt.parse32_bounded_int32'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.parse32_bounded_int32_4
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 16777216 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
{ "end_col": 36, "end_line": 283, "start_col": 2, "start_line": 283 }
Prims.Tot
val bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 {y == bounded_integer_of_le 1 (B32.reveal b)})
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b
val bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 {y == bounded_integer_of_le 1 (B32.reveal b)}) let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 {y == bounded_integer_of_le 1 (B32.reveal b)}) =
false
null
false
le_to_n_1 b
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Bytes.lbytes", "LowParse.SLow.BoundedInt.le_to_n_1", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.eq2", "LowParse.Spec.BoundedInt.bounded_integer_of_le", "FStar.Bytes.reveal" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 {y == bounded_integer_of_le 1 (B32.reveal b)})
[]
LowParse.SLow.BoundedInt.bounded_integer_of_le_32_1
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
b: FStar.Bytes.lbytes 1 -> y: LowParse.Spec.BoundedInt.bounded_integer 1 {y == LowParse.Spec.BoundedInt.bounded_integer_of_le 1 (FStar.Bytes.reveal b)}
{ "end_col": 13, "end_line": 132, "start_col": 2, "start_line": 132 }
Prims.Tot
val parse32_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul
val parse32_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) let parse32_bounded_int32_2 min max =
false
null
false
parse32_bounded_int32' min max 2ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "Prims.op_LessThan", "LowParse.SLow.BoundedInt.parse32_bounded_int32'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.parse32_bounded_int32_2
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 256 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 65536 } -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
{ "end_col": 36, "end_line": 275, "start_col": 2, "start_line": 275 }
Prims.Tot
val parse32_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_int32_le_1 min max = parse32_bounded_int32_le' min max 1ul
val parse32_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) let parse32_bounded_int32_le_1 min max =
false
null
false
parse32_bounded_int32_le' min max 1ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.SLow.BoundedInt.parse32_bounded_int32_le'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul let serialize32_bounded_int32_3 min max = serialize32_bounded_int32' min max 3ul let serialize32_bounded_int32_4 min max = serialize32_bounded_int32' min max 4ul inline_for_extraction let parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_le_1
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.parse32_bounded_int32_le_1
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 256 } -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
{ "end_col": 39, "end_line": 344, "start_col": 2, "start_line": 344 }
Prims.Tot
val parse32_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul
val parse32_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) let parse32_bounded_int32_1 min max =
false
null
false
parse32_bounded_int32' min max 1ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.SLow.BoundedInt.parse32_bounded_int32'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.parse32_bounded_int32_1
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 256 } -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
{ "end_col": 36, "end_line": 271, "start_col": 2, "start_line": 271 }
Prims.Tot
val bounded_integer_of_le_32 (sz: integer_size) : Tot (b: B32.lbytes sz -> Tot (y: bounded_integer sz {y == bounded_integer_of_le sz (B32.reveal b)}))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4
val bounded_integer_of_le_32 (sz: integer_size) : Tot (b: B32.lbytes sz -> Tot (y: bounded_integer sz {y == bounded_integer_of_le sz (B32.reveal b)})) let bounded_integer_of_le_32 (sz: integer_size) : Tot (b: B32.lbytes sz -> Tot (y: bounded_integer sz {y == bounded_integer_of_le sz (B32.reveal b)})) =
false
null
false
match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.SLow.BoundedInt.bounded_integer_of_le_32_1", "LowParse.SLow.BoundedInt.bounded_integer_of_le_32_2", "LowParse.SLow.BoundedInt.bounded_integer_of_le_32_3", "LowParse.SLow.BoundedInt.bounded_integer_of_le_32_4", "FStar.Bytes.lbytes", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.eq2", "LowParse.Spec.BoundedInt.bounded_integer_of_le", "FStar.Bytes.reveal" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bounded_integer_of_le_32 (sz: integer_size) : Tot (b: B32.lbytes sz -> Tot (y: bounded_integer sz {y == bounded_integer_of_le sz (B32.reveal b)}))
[]
LowParse.SLow.BoundedInt.bounded_integer_of_le_32
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> b: FStar.Bytes.lbytes sz -> y: LowParse.Spec.BoundedInt.bounded_integer sz {y == LowParse.Spec.BoundedInt.bounded_integer_of_le sz (FStar.Bytes.reveal b)}
{ "end_col": 35, "end_line": 174, "start_col": 2, "start_line": 170 }
Prims.Tot
val decode32_bounded_integer (sz: integer_size) : Tot (b: B32.lbytes sz -> Tot (y: bounded_integer sz {y == decode_bounded_integer sz (B32.reveal b)}) )
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4
val decode32_bounded_integer (sz: integer_size) : Tot (b: B32.lbytes sz -> Tot (y: bounded_integer sz {y == decode_bounded_integer sz (B32.reveal b)}) ) let decode32_bounded_integer (sz: integer_size) : Tot (b: B32.lbytes sz -> Tot (y: bounded_integer sz {y == decode_bounded_integer sz (B32.reveal b)}) ) =
false
null
false
match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.SLow.BoundedInt.decode32_bounded_integer_1", "LowParse.SLow.BoundedInt.decode32_bounded_integer_2", "LowParse.SLow.BoundedInt.decode32_bounded_integer_3", "LowParse.SLow.BoundedInt.decode32_bounded_integer_4", "FStar.Bytes.lbytes", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.eq2", "LowParse.Spec.BoundedInt.decode_bounded_integer", "FStar.Bytes.reveal" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val decode32_bounded_integer (sz: integer_size) : Tot (b: B32.lbytes sz -> Tot (y: bounded_integer sz {y == decode_bounded_integer sz (B32.reveal b)}) )
[]
LowParse.SLow.BoundedInt.decode32_bounded_integer
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> b: FStar.Bytes.lbytes sz -> y: LowParse.Spec.BoundedInt.bounded_integer sz {y == LowParse.Spec.BoundedInt.decode_bounded_integer sz (FStar.Bytes.reveal b)}
{ "end_col": 35, "end_line": 68, "start_col": 2, "start_line": 64 }
Prims.Tot
val parse32_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_int32_le_2 min max = parse32_bounded_int32_le' min max 2ul
val parse32_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) let parse32_bounded_int32_le_2 min max =
false
null
false
parse32_bounded_int32_le' min max 2ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "Prims.op_LessThan", "LowParse.SLow.BoundedInt.parse32_bounded_int32_le'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul let serialize32_bounded_int32_3 min max = serialize32_bounded_int32' min max 3ul let serialize32_bounded_int32_4 min max = serialize32_bounded_int32' min max 4ul inline_for_extraction let parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_le_1 min max = parse32_bounded_int32_le' min max 1ul let parse32_bounded_int32_le_2
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.parse32_bounded_int32_le_2
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 256 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 65536 } -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
{ "end_col": 39, "end_line": 348, "start_col": 2, "start_line": 348 }
Prims.Tot
val parse32_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul
val parse32_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) let parse32_bounded_int32_3 min max =
false
null
false
parse32_bounded_int32' min max 3ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "Prims.op_LessThan", "LowParse.SLow.BoundedInt.parse32_bounded_int32'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.parse32_bounded_int32_3
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 65536 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 16777216 } -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
{ "end_col": 36, "end_line": 279, "start_col": 2, "start_line": 279 }
Prims.Tot
val serialize32_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_int32_le_3 min max = serialize32_bounded_int32_le' min max 3ul
val serialize32_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) let serialize32_bounded_int32_le_3 min max =
false
null
false
serialize32_bounded_int32_le' min max 3ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "Prims.op_LessThan", "LowParse.SLow.BoundedInt.serialize32_bounded_int32_le'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.serializer32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32_le", "LowParse.Spec.BoundedInt.serialize_bounded_int32_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul let serialize32_bounded_int32_3 min max = serialize32_bounded_int32' min max 3ul let serialize32_bounded_int32_4 min max = serialize32_bounded_int32' min max 4ul inline_for_extraction let parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_le_1 min max = parse32_bounded_int32_le' min max 1ul let parse32_bounded_int32_le_2 min max = parse32_bounded_int32_le' min max 2ul let parse32_bounded_int32_le_3 min max = parse32_bounded_int32_le' min max 3ul let parse32_bounded_int32_le_4 min max = parse32_bounded_int32_le' min max 4ul inline_for_extraction let serialize32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer_le sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () #push-options "--z3rlimit 40" #restart-solver // somehow needed let serialize32_bounded_int32_le_1 min max = serialize32_bounded_int32_le' min max 1ul let serialize32_bounded_int32_le_2 min max = serialize32_bounded_int32_le' min max 2ul let serialize32_bounded_int32_le_3
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_int32_le_3
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 65536 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 16777216 } -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32_le (FStar.UInt32.v min32) (FStar.UInt32.v max32))
{ "end_col": 43, "end_line": 392, "start_col": 2, "start_line": 392 }
Prims.Tot
val serialize32_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_int32_le_1 min max = serialize32_bounded_int32_le' min max 1ul
val serialize32_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) let serialize32_bounded_int32_le_1 min max =
false
null
false
serialize32_bounded_int32_le' min max 1ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.SLow.BoundedInt.serialize32_bounded_int32_le'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.serializer32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32_le", "LowParse.Spec.BoundedInt.serialize_bounded_int32_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul let serialize32_bounded_int32_3 min max = serialize32_bounded_int32' min max 3ul let serialize32_bounded_int32_4 min max = serialize32_bounded_int32' min max 4ul inline_for_extraction let parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_le_1 min max = parse32_bounded_int32_le' min max 1ul let parse32_bounded_int32_le_2 min max = parse32_bounded_int32_le' min max 2ul let parse32_bounded_int32_le_3 min max = parse32_bounded_int32_le' min max 3ul let parse32_bounded_int32_le_4 min max = parse32_bounded_int32_le' min max 4ul inline_for_extraction let serialize32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer_le sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () #push-options "--z3rlimit 40" #restart-solver // somehow needed let serialize32_bounded_int32_le_1
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_int32_le_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_int32_le_1
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 256 } -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32_le (FStar.UInt32.v min32) (FStar.UInt32.v max32))
{ "end_col": 43, "end_line": 384, "start_col": 2, "start_line": 384 }
Prims.Tot
val serialize32_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t { U32.v min32 <= U32.v max32 }) : Tot (serializer32 (serialize_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_int32_le_fixed_size min32 max32 = serialize32_filter serialize32_u32_le (in_bounds (U32.v min32) (U32.v max32))
val serialize32_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t { U32.v min32 <= U32.v max32 }) : Tot (serializer32 (serialize_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32))) let serialize32_bounded_int32_le_fixed_size min32 max32 =
false
null
false
serialize32_filter serialize32_u32_le (in_bounds (U32.v min32) (U32.v max32))
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "LowParse.SLow.Combinators.serialize32_filter", "LowParse.Spec.Int.parse_u32_kind", "LowParse.Spec.BoundedInt.parse_u32_le", "LowParse.Spec.BoundedInt.serialize_u32_le", "LowParse.SLow.BoundedInt.serialize32_u32_le", "LowParse.Spec.BoundedInt.in_bounds", "LowParse.SLow.Base.serializer32", "LowParse.Spec.BoundedInt.parse_bounded_int32_fixed_size_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32_le_fixed_size", "LowParse.Spec.BoundedInt.serialize_bounded_int32_le_fixed_size" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul let serialize32_bounded_int32_3 min max = serialize32_bounded_int32' min max 3ul let serialize32_bounded_int32_4 min max = serialize32_bounded_int32' min max 4ul inline_for_extraction let parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_le_1 min max = parse32_bounded_int32_le' min max 1ul let parse32_bounded_int32_le_2 min max = parse32_bounded_int32_le' min max 2ul let parse32_bounded_int32_le_3 min max = parse32_bounded_int32_le' min max 3ul let parse32_bounded_int32_le_4 min max = parse32_bounded_int32_le' min max 4ul inline_for_extraction let serialize32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer_le sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () #push-options "--z3rlimit 40" #restart-solver // somehow needed let serialize32_bounded_int32_le_1 min max = serialize32_bounded_int32_le' min max 1ul let serialize32_bounded_int32_le_2 min max = serialize32_bounded_int32_le' min max 2ul let serialize32_bounded_int32_le_3 min max = serialize32_bounded_int32_le' min max 3ul let serialize32_bounded_int32_le_4 min max = serialize32_bounded_int32_le' min max 4ul let parse32_bounded_int32_le_fixed_size min32 max32 = parse32_filter parse32_u32_le (in_bounds (U32.v min32) (U32.v max32)) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)) let serialize32_bounded_int32_le_fixed_size
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t { U32.v min32 <= U32.v max32 }) : Tot (serializer32 (serialize_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_int32_le_fixed_size
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t{FStar.UInt32.v min32 <= FStar.UInt32.v max32} -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32_le_fixed_size (FStar.UInt32.v min32) (FStar.UInt32.v max32))
{ "end_col": 79, "end_line": 404, "start_col": 2, "start_line": 404 }
Prims.Tot
val serialize32_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_int32_le_2 min max = serialize32_bounded_int32_le' min max 2ul
val serialize32_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) let serialize32_bounded_int32_le_2 min max =
false
null
false
serialize32_bounded_int32_le' min max 2ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "Prims.op_LessThan", "LowParse.SLow.BoundedInt.serialize32_bounded_int32_le'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.serializer32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32_le", "LowParse.Spec.BoundedInt.serialize_bounded_int32_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul let serialize32_bounded_int32_3 min max = serialize32_bounded_int32' min max 3ul let serialize32_bounded_int32_4 min max = serialize32_bounded_int32' min max 4ul inline_for_extraction let parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_le_1 min max = parse32_bounded_int32_le' min max 1ul let parse32_bounded_int32_le_2 min max = parse32_bounded_int32_le' min max 2ul let parse32_bounded_int32_le_3 min max = parse32_bounded_int32_le' min max 3ul let parse32_bounded_int32_le_4 min max = parse32_bounded_int32_le' min max 4ul inline_for_extraction let serialize32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer_le sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () #push-options "--z3rlimit 40" #restart-solver // somehow needed let serialize32_bounded_int32_le_1 min max = serialize32_bounded_int32_le' min max 1ul let serialize32_bounded_int32_le_2
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_int32_le_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_int32_le_2
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 256 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 65536 } -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32_le (FStar.UInt32.v min32) (FStar.UInt32.v max32))
{ "end_col": 43, "end_line": 388, "start_col": 2, "start_line": 388 }
Prims.Tot
val serialize32_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_int32_4 min max = serialize32_bounded_int32' min max 4ul
val serialize32_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) let serialize32_bounded_int32_4 min max =
false
null
false
serialize32_bounded_int32' min max 4ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "Prims.op_LessThan", "LowParse.SLow.BoundedInt.serialize32_bounded_int32'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.serializer32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32", "LowParse.Spec.BoundedInt.serialize_bounded_int32" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul let serialize32_bounded_int32_3 min max = serialize32_bounded_int32' min max 3ul let serialize32_bounded_int32_4
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_int32_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_int32_4
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 16777216 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32 (FStar.UInt32.v min32) (FStar.UInt32.v max32))
{ "end_col": 40, "end_line": 320, "start_col": 2, "start_line": 320 }
Prims.Tot
val parse32_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t { U32.v min32 <= U32.v max32 }) : Tot (parser32 (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_int32_le_fixed_size min32 max32 = parse32_filter parse32_u32_le (in_bounds (U32.v min32) (U32.v max32)) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))
val parse32_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t { U32.v min32 <= U32.v max32 }) : Tot (parser32 (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32))) let parse32_bounded_int32_le_fixed_size min32 max32 =
false
null
false
parse32_filter parse32_u32_le (in_bounds (U32.v min32) (U32.v max32)) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "LowParse.SLow.Combinators.parse32_filter", "LowParse.Spec.Int.parse_u32_kind", "LowParse.Spec.BoundedInt.parse_u32_le", "LowParse.SLow.BoundedInt.parse32_u32_le", "LowParse.Spec.BoundedInt.in_bounds", "Prims.op_Negation", "Prims.op_BarBar", "FStar.UInt32.lt", "Prims.bool", "Prims.eq2", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_int32_fixed_size_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32_le_fixed_size" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul let serialize32_bounded_int32_3 min max = serialize32_bounded_int32' min max 3ul let serialize32_bounded_int32_4 min max = serialize32_bounded_int32' min max 4ul inline_for_extraction let parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_le_1 min max = parse32_bounded_int32_le' min max 1ul let parse32_bounded_int32_le_2 min max = parse32_bounded_int32_le' min max 2ul let parse32_bounded_int32_le_3 min max = parse32_bounded_int32_le' min max 3ul let parse32_bounded_int32_le_4 min max = parse32_bounded_int32_le' min max 4ul inline_for_extraction let serialize32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer_le sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () #push-options "--z3rlimit 40" #restart-solver // somehow needed let serialize32_bounded_int32_le_1 min max = serialize32_bounded_int32_le' min max 1ul let serialize32_bounded_int32_le_2 min max = serialize32_bounded_int32_le' min max 2ul let serialize32_bounded_int32_le_3 min max = serialize32_bounded_int32_le' min max 3ul let serialize32_bounded_int32_le_4 min max = serialize32_bounded_int32_le' min max 4ul let parse32_bounded_int32_le_fixed_size
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_int32_le_fixed_size (min32: U32.t) (max32: U32.t { U32.v min32 <= U32.v max32 }) : Tot (parser32 (parse_bounded_int32_le_fixed_size (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.parse32_bounded_int32_le_fixed_size
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t{FStar.UInt32.v min32 <= FStar.UInt32.v max32} -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32_le_fixed_size (FStar.UInt32.v min32) (FStar.UInt32.v max32))
{ "end_col": 125, "end_line": 400, "start_col": 2, "start_line": 400 }
Prims.Tot
val serialize32_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul
val serialize32_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) let serialize32_bounded_int32_2 min max =
false
null
false
serialize32_bounded_int32' min max 2ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "Prims.op_LessThan", "LowParse.SLow.BoundedInt.serialize32_bounded_int32'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.serializer32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32", "LowParse.Spec.BoundedInt.serialize_bounded_int32" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_int32_2 (min32: U32.t) (max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_int32_2
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 256 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 65536 } -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32 (FStar.UInt32.v min32) (FStar.UInt32.v max32))
{ "end_col": 40, "end_line": 312, "start_col": 2, "start_line": 312 }
Prims.Tot
val serialize32_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_int32_le_4 min max = serialize32_bounded_int32_le' min max 4ul
val serialize32_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) let serialize32_bounded_int32_le_4 min max =
false
null
false
serialize32_bounded_int32_le' min max 4ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "Prims.op_LessThan", "LowParse.SLow.BoundedInt.serialize32_bounded_int32_le'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.serializer32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32_le", "LowParse.Spec.BoundedInt.serialize_bounded_int32_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul let serialize32_bounded_int32_3 min max = serialize32_bounded_int32' min max 3ul let serialize32_bounded_int32_4 min max = serialize32_bounded_int32' min max 4ul inline_for_extraction let parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_le_1 min max = parse32_bounded_int32_le' min max 1ul let parse32_bounded_int32_le_2 min max = parse32_bounded_int32_le' min max 2ul let parse32_bounded_int32_le_3 min max = parse32_bounded_int32_le' min max 3ul let parse32_bounded_int32_le_4 min max = parse32_bounded_int32_le' min max 4ul inline_for_extraction let serialize32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer_le sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () #push-options "--z3rlimit 40" #restart-solver // somehow needed let serialize32_bounded_int32_le_1 min max = serialize32_bounded_int32_le' min max 1ul let serialize32_bounded_int32_le_2 min max = serialize32_bounded_int32_le' min max 2ul let serialize32_bounded_int32_le_3 min max = serialize32_bounded_int32_le' min max 3ul let serialize32_bounded_int32_le_4
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_int32_le_4
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 16777216 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32_le (FStar.UInt32.v min32) (FStar.UInt32.v max32))
{ "end_col": 43, "end_line": 396, "start_col": 2, "start_line": 396 }
Prims.Tot
val parse32_bounded_int32' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) ()
val parse32_bounded_int32' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) let parse32_bounded_int32' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) =
false
null
false
[@@ inline_let ]let sz = U32.v sz32 in [@@ inline_let ]let min = U32.v min32 in [@@ inline_let ]let max = U32.v max32 in parse32_synth ((parse_bounded_integer sz) `parse_filter` (in_bounds min max)) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) ()
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt32.n", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.Combinators.parse32_synth", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.in_bounds", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.SLow.Combinators.parse32_filter", "LowParse.SLow.BoundedInt.parse32_bounded_integer", "Prims.op_Negation", "Prims.op_BarBar", "FStar.UInt32.lt", "Prims.bool", "FStar.UInt.uint_t", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.parse_bounded_int32" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_int32' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.parse32_bounded_int32'
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> sz32: FStar.UInt32.t{LowParse.Spec.BoundedInt.log256' (FStar.UInt32.v max32) == FStar.UInt32.v sz32} -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
{ "end_col": 6, "end_line": 267, "start_col": 2, "start_line": 256 }
Prims.Tot
val serialize32_bounded_int32_le' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer_le sz) (in_bounds min max)) (fun x -> x) (fun x -> x) ()
val serialize32_bounded_int32_le' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) let serialize32_bounded_int32_le' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) =
false
null
false
[@@ inline_let ]let sz = U32.v sz32 in [@@ inline_let ]let min = U32.v min32 in [@@ inline_let ]let max = U32.v max32 in serialize32_synth ((parse_bounded_integer_le sz) `parse_filter` (in_bounds min max)) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer_le sz) (in_bounds min max)) (fun x -> x) (fun x -> x) ()
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt32.n", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.Combinators.serialize32_synth", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.in_bounds", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.Combinators.serialize_filter", "LowParse.Spec.BoundedInt.serialize_bounded_integer_le", "LowParse.SLow.Combinators.serialize32_filter", "LowParse.SLow.BoundedInt.serialize32_bounded_integer_le", "FStar.UInt.uint_t", "LowParse.SLow.Base.serializer32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.parse_bounded_int32_le", "LowParse.Spec.BoundedInt.serialize_bounded_int32_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul let serialize32_bounded_int32_3 min max = serialize32_bounded_int32' min max 3ul let serialize32_bounded_int32_4 min max = serialize32_bounded_int32' min max 4ul inline_for_extraction let parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_le_1 min max = parse32_bounded_int32_le' min max 1ul let parse32_bounded_int32_le_2 min max = parse32_bounded_int32_le' min max 2ul let parse32_bounded_int32_le_3 min max = parse32_bounded_int32_le' min max 3ul let parse32_bounded_int32_le_4 min max = parse32_bounded_int32_le' min max 4ul inline_for_extraction let serialize32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_int32_le' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_int32_le'
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> sz32: FStar.UInt32.t{LowParse.Spec.BoundedInt.log256' (FStar.UInt32.v max32) == FStar.UInt32.v sz32} -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32_le (FStar.UInt32.v min32) (FStar.UInt32.v max32))
{ "end_col": 6, "end_line": 377, "start_col": 2, "start_line": 364 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
let n_to_be_2 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.n_to_be_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_n_to_be" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val n_to_be_2 : LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2
[]
LowParse.SLow.BoundedInt.n_to_be_2
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2
{ "end_col": 112, "end_line": 96, "start_col": 16, "start_line": 96 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
let n_to_be_4 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.n_to_be_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_n_to_be" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val n_to_be_4 : LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4
[]
LowParse.SLow.BoundedInt.n_to_be_4
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4
{ "end_col": 112, "end_line": 116, "start_col": 16, "start_line": 116 }
Prims.Tot
val decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 {y == decode_bounded_integer 1 (B32.reveal b)})
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b
val decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 {y == decode_bounded_integer 1 (B32.reveal b)}) let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 {y == decode_bounded_integer 1 (B32.reveal b)}) =
false
null
false
be_to_n_1 b
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Bytes.lbytes", "LowParse.SLow.BoundedInt.be_to_n_1", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.eq2", "LowParse.Spec.BoundedInt.decode_bounded_integer", "FStar.Bytes.reveal" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 {y == decode_bounded_integer 1 (B32.reveal b)})
[]
LowParse.SLow.BoundedInt.decode32_bounded_integer_1
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
b: FStar.Bytes.lbytes 1 -> y: LowParse.Spec.BoundedInt.bounded_integer 1 {y == LowParse.Spec.BoundedInt.decode_bounded_integer 1 (FStar.Bytes.reveal b)}
{ "end_col": 13, "end_line": 26, "start_col": 2, "start_line": 26 }
Prims.Tot
val decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 {y == decode_bounded_integer 2 (B32.reveal b)})
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b
val decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 {y == decode_bounded_integer 2 (B32.reveal b)}) let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 {y == decode_bounded_integer 2 (B32.reveal b)}) =
false
null
false
be_to_n_2 b
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Bytes.lbytes", "LowParse.SLow.BoundedInt.be_to_n_2", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.eq2", "LowParse.Spec.BoundedInt.decode_bounded_integer", "FStar.Bytes.reveal" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 {y == decode_bounded_integer 2 (B32.reveal b)})
[]
LowParse.SLow.BoundedInt.decode32_bounded_integer_2
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
b: FStar.Bytes.lbytes 2 -> y: LowParse.Spec.BoundedInt.bounded_integer 2 {y == LowParse.Spec.BoundedInt.decode_bounded_integer 2 (FStar.Bytes.reveal b)}
{ "end_col": 13, "end_line": 36, "start_col": 2, "start_line": 36 }
Prims.Tot
val bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 {y == bounded_integer_of_le 4 (B32.reveal b)})
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b
val bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 {y == bounded_integer_of_le 4 (B32.reveal b)}) let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 {y == bounded_integer_of_le 4 (B32.reveal b)}) =
false
null
false
le_to_n_4 b
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Bytes.lbytes", "LowParse.SLow.BoundedInt.le_to_n_4", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.eq2", "LowParse.Spec.BoundedInt.bounded_integer_of_le", "FStar.Bytes.reveal" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 {y == bounded_integer_of_le 4 (B32.reveal b)})
[]
LowParse.SLow.BoundedInt.bounded_integer_of_le_32_4
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
b: FStar.Bytes.lbytes 4 -> y: LowParse.Spec.BoundedInt.bounded_integer 4 {y == LowParse.Spec.BoundedInt.bounded_integer_of_le 4 (FStar.Bytes.reveal b)}
{ "end_col": 13, "end_line": 162, "start_col": 2, "start_line": 162 }
Prims.Tot
val decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 {y == decode_bounded_integer 4 (B32.reveal b)})
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b
val decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 {y == decode_bounded_integer 4 (B32.reveal b)}) let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 {y == decode_bounded_integer 4 (B32.reveal b)}) =
false
null
false
be_to_n_4 b
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Bytes.lbytes", "LowParse.SLow.BoundedInt.be_to_n_4", "LowParse.Spec.BoundedInt.bounded_integer", "Prims.eq2", "LowParse.Spec.BoundedInt.decode_bounded_integer", "FStar.Bytes.reveal" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 {y == decode_bounded_integer 4 (B32.reveal b)})
[]
LowParse.SLow.BoundedInt.decode32_bounded_integer_4
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
b: FStar.Bytes.lbytes 4 -> y: LowParse.Spec.BoundedInt.bounded_integer 4 {y == LowParse.Spec.BoundedInt.decode_bounded_integer 4 (FStar.Bytes.reveal b)}
{ "end_col": 13, "end_line": 56, "start_col": 2, "start_line": 56 }
Prims.Tot
val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1)
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x
val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) let serialize32_bounded_integer_le_1 =
false
null
false
fun (x: bounded_integer 1) -> n_to_le_1 x
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.SLow.BoundedInt.n_to_le_1", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.BoundedInt.serialize_bounded_integer_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1)
[]
LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_1
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer_le 1)
{ "end_col": 13, "end_line": 209, "start_col": 39, "start_line": 208 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let n_to_le_2 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.n_to_le_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_n_to_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val n_to_le_2 : LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2
[]
LowParse.SLow.BoundedInt.n_to_le_2
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2
{ "end_col": 112, "end_line": 213, "start_col": 16, "start_line": 213 }
Prims.Tot
val serialize32_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul
val serialize32_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) let serialize32_bounded_int32_1 min max =
false
null
false
serialize32_bounded_int32' min max 1ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "LowParse.SLow.BoundedInt.serialize32_bounded_int32'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.serializer32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32", "LowParse.Spec.BoundedInt.serialize_bounded_int32" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_int32_1 (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_int32_1
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 256 } -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32 (FStar.UInt32.v min32) (FStar.UInt32.v max32))
{ "end_col": 40, "end_line": 308, "start_col": 2, "start_line": 308 }
Prims.Tot
val serialize32_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_int32_3 min max = serialize32_bounded_int32' min max 3ul
val serialize32_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) let serialize32_bounded_int32_3 min max =
false
null
false
serialize32_bounded_int32' min max 3ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "Prims.op_LessThan", "LowParse.SLow.BoundedInt.serialize32_bounded_int32'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.serializer32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32", "LowParse.Spec.BoundedInt.serialize_bounded_int32" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul let serialize32_bounded_int32_3
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_int32_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_int32_3
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 65536 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 16777216 } -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32 (FStar.UInt32.v min32) (FStar.UInt32.v max32))
{ "end_col": 40, "end_line": 316, "start_col": 2, "start_line": 316 }
Prims.Tot
val parse32_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_int32_le_3 min max = parse32_bounded_int32_le' min max 3ul
val parse32_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) let parse32_bounded_int32_le_3 min max =
false
null
false
parse32_bounded_int32_le' min max 3ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "Prims.op_LessThan", "LowParse.SLow.BoundedInt.parse32_bounded_int32_le'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul let serialize32_bounded_int32_3 min max = serialize32_bounded_int32' min max 3ul let serialize32_bounded_int32_4 min max = serialize32_bounded_int32' min max 4ul inline_for_extraction let parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_le_1 min max = parse32_bounded_int32_le' min max 1ul let parse32_bounded_int32_le_2 min max = parse32_bounded_int32_le' min max 2ul let parse32_bounded_int32_le_3
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_int32_le_3 (min32: U32.t) (max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.parse32_bounded_int32_le_3
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 65536 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 16777216 } -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
{ "end_col": 39, "end_line": 352, "start_col": 2, "start_line": 352 }
Prims.Tot
val parse32_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_int32_le_4 min max = parse32_bounded_int32_le' min max 4ul
val parse32_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) let parse32_bounded_int32_le_4 min max =
false
null
false
parse32_bounded_int32_le' min max 4ul
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "Prims.op_LessThan", "LowParse.SLow.BoundedInt.parse32_bounded_int32_le'", "FStar.UInt32.__uint_to_t", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.BoundedInt.parse_bounded_int32_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul let serialize32_bounded_int32_3 min max = serialize32_bounded_int32' min max 3ul let serialize32_bounded_int32_4 min max = serialize32_bounded_int32' min max 4ul inline_for_extraction let parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_le_1 min max = parse32_bounded_int32_le' min max 1ul let parse32_bounded_int32_le_2 min max = parse32_bounded_int32_le' min max 2ul let parse32_bounded_int32_le_3 min max = parse32_bounded_int32_le' min max 3ul let parse32_bounded_int32_le_4
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_int32_le_4 (min32: U32.t) (max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.parse32_bounded_int32_le_4
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 16777216 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
{ "end_col": 39, "end_line": 356, "start_col": 2, "start_line": 356 }
Prims.Tot
val parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer_le sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) ()
val parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) let parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) =
false
null
false
[@@ inline_let ]let sz = U32.v sz32 in [@@ inline_let ]let min = U32.v min32 in [@@ inline_let ]let max = U32.v max32 in parse32_synth ((parse_bounded_integer_le sz) `parse_filter` (in_bounds min max)) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) ()
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt32.n", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.Combinators.parse32_synth", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.in_bounds", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.SLow.Combinators.parse32_filter", "LowParse.SLow.BoundedInt.parse32_bounded_integer_le", "Prims.op_Negation", "Prims.op_BarBar", "FStar.UInt32.lt", "Prims.bool", "FStar.UInt.uint_t", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.parse_bounded_int32_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) () let serialize32_bounded_int32_1 min max = serialize32_bounded_int32' min max 1ul let serialize32_bounded_int32_2 min max = serialize32_bounded_int32' min max 2ul let serialize32_bounded_int32_3 min max = serialize32_bounded_int32' min max 3ul let serialize32_bounded_int32_4 min max = serialize32_bounded_int32' min max 4ul inline_for_extraction let parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_int32_le' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.parse32_bounded_int32_le'
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> sz32: FStar.UInt32.t{LowParse.Spec.BoundedInt.log256' (FStar.UInt32.v max32) == FStar.UInt32.v sz32} -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32 ) (FStar.UInt32.v max32))
{ "end_col": 6, "end_line": 340, "start_col": 2, "start_line": 329 }
Prims.Tot
val serialize32_bounded_int32' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "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": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in serialize32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) ()
val serialize32_bounded_int32' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) =
false
null
false
[@@ inline_let ]let sz = U32.v sz32 in [@@ inline_let ]let min = U32.v min32 in [@@ inline_let ]let max = U32.v max32 in serialize32_synth ((parse_bounded_integer sz) `parse_filter` (in_bounds min max)) (fun x -> (x <: bounded_int32 min max)) _ (serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max)) (fun x -> x) (fun x -> x) ()
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.op_LessThanOrEqual", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt32.n", "LowParse.Spec.BoundedInt.log256'", "LowParse.SLow.Combinators.serialize32_synth", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.in_bounds", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.Combinators.serialize_filter", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "LowParse.SLow.Combinators.serialize32_filter", "LowParse.SLow.BoundedInt.serialize32_bounded_integer", "FStar.UInt.uint_t", "LowParse.SLow.Base.serializer32", "LowParse.Spec.BoundedInt.parse_bounded_int32_kind", "LowParse.Spec.BoundedInt.parse_bounded_int32", "LowParse.Spec.BoundedInt.serialize_bounded_int32" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () inline_for_extraction let parse32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 }) : Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) = [@inline_let] let sz = U32.v sz32 in [@inline_let] let min = U32.v min32 in [@inline_let] let max = U32.v max32 in parse32_synth (parse_bounded_integer sz `parse_filter` in_bounds min max) (fun x -> (x <: bounded_int32 min max)) (fun x -> x) (parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x))) () let parse32_bounded_int32_1 min max = parse32_bounded_int32' min max 1ul let parse32_bounded_int32_2 min max = parse32_bounded_int32' min max 2ul let parse32_bounded_int32_3 min max = parse32_bounded_int32' min max 3ul let parse32_bounded_int32_4 min max = parse32_bounded_int32' min max 4ul inline_for_extraction let serialize32_bounded_int32' (min32: U32.t) (max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 }) (sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_int32' (min32: U32.t) (max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296}) (sz32: U32.t{log256' (U32.v max32) == U32.v sz32}) : Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_int32'
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
min32: FStar.UInt32.t -> max32: FStar.UInt32.t { 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\ FStar.UInt32.v max32 < 4294967296 } -> sz32: FStar.UInt32.t{LowParse.Spec.BoundedInt.log256' (FStar.UInt32.v max32) == FStar.UInt32.v sz32} -> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32 (FStar.UInt32.v min32) (FStar.UInt32.v max32))
{ "end_col": 6, "end_line": 304, "start_col": 2, "start_line": 291 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_stack_slot64 (ptr:int) (h:vale_stack) (t:taint) (stackTaint:memtaint) = valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint
let valid_stack_slot64 (ptr: int) (h: vale_stack) (t: taint) (stackTaint: memtaint) =
false
null
false
valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint
{ "checked_file": "Vale.X64.Stack_i.fsti.checked", "dependencies": [ "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Stack_i.fsti" }
[ "total" ]
[ "Prims.int", "Vale.X64.Stack_i.vale_stack", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Memory.memtaint", "Prims.l_and", "Prims.b2t", "Vale.X64.Stack_i.valid_src_stack64", "Vale.X64.Stack_i.valid_taint_stack64", "Prims.logical" ]
[]
module Vale.X64.Stack_i open FStar.Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Prop_s val vale_stack : Type u#0 val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64 val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32 val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack val init_rsp (h:vale_stack) : (n:nat64{n >= 4096}) let modifies_stack (lo_rsp hi_rsp:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') } valid_src_stack64 addr h /\ (addr + 8 <= lo_rsp || addr >= hi_rsp) ==> valid_src_stack64 addr h' /\ load_stack64 addr h == load_stack64 addr h' let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (valid_src_stack64 addr h)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h (* Validity preservation *) val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures valid_src_stack64 i (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 i (store_stack64 ptr v h))] val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures valid_src_stack64 ptr (free_stack64 start finish h)) [SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))] (* Validity update *) val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (valid_src_stack64 ptr (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))] (* Classic select/update lemmas *) val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (load_stack64 ptr (store_stack64 ptr v h) == v) [SMTPat (load_stack64 ptr (store_stack64 ptr v h))] val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h)) [SMTPat (load_stack64 i (store_stack64 ptr v h))] val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h)) [SMTPat (load_stack64 ptr (free_stack64 start finish h))] (* Free composition *) val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma (requires start <= inter /\ inter <= finish) (ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h) [SMTPat (free_stack64 inter finish (free_stack64 start inter h))] (* Preservation of the initial stack pointer *) val lemma_same_init_rsp_free_stack64 (start:int) (finish:int) (h:vale_stack) : Lemma (init_rsp (free_stack64 start finish h) == init_rsp h) [SMTPat (init_rsp (free_stack64 start finish h))] val lemma_same_init_rsp_store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (init_rsp (store_stack64 ptr v h) == init_rsp h) [SMTPat (init_rsp (store_stack64 ptr v h))] // Taint for the stack val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint val lemma_valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires valid_taint_stack64 ptr t stackTaint) (ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t) val lemma_valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires valid_taint_stack128 ptr t stackTaint) (ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t) val lemma_valid_taint_stack64_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t) (ensures valid_taint_stack64 ptr t stackTaint) val lemma_correct_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint)) [SMTPat (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))] val lemma_frame_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma (requires i >= ptr + 8 \/ i + 8 <= ptr) (ensures valid_taint_stack64 i t' stackTaint == valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint)) [SMTPat (valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))]
false
true
Vale.X64.Stack_i.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_stack_slot64 : ptr: Prims.int -> h: Vale.X64.Stack_i.vale_stack -> t: Vale.Arch.HeapTypes_s.taint -> stackTaint: Vale.X64.Memory.memtaint -> Prims.logical
[]
Vale.X64.Stack_i.valid_stack_slot64
{ "file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ptr: Prims.int -> h: Vale.X64.Stack_i.vale_stack -> t: Vale.Arch.HeapTypes_s.taint -> stackTaint: Vale.X64.Memory.memtaint -> Prims.logical
{ "end_col": 65, "end_line": 113, "start_col": 2, "start_line": 113 }
Prims.Tot
val valid_src_stack64s (base num_slots: nat) (h: vale_stack) : Vale.Def.Prop_s.prop0
[ { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (valid_src_stack64 addr h)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h
val valid_src_stack64s (base num_slots: nat) (h: vale_stack) : Vale.Def.Prop_s.prop0 let valid_src_stack64s (base num_slots: nat) (h: vale_stack) : Vale.Def.Prop_s.prop0 =
false
null
false
forall addr. {:pattern (valid_src_stack64 addr h)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h
{ "checked_file": "Vale.X64.Stack_i.fsti.checked", "dependencies": [ "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Stack_i.fsti" }
[ "total" ]
[ "Prims.nat", "Vale.X64.Stack_i.vale_stack", "Prims.l_Forall", "Prims.int", "Prims.l_imp", "Prims.b2t", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.op_Equality", "Prims.op_Modulus", "Prims.op_Subtraction", "Vale.X64.Stack_i.valid_src_stack64", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.X64.Stack_i open FStar.Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Prop_s val vale_stack : Type u#0 val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64 val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32 val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack val init_rsp (h:vale_stack) : (n:nat64{n >= 4096}) let modifies_stack (lo_rsp hi_rsp:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') } valid_src_stack64 addr h /\ (addr + 8 <= lo_rsp || addr >= hi_rsp) ==> valid_src_stack64 addr h' /\ load_stack64 addr h == load_stack64 addr h'
false
true
Vale.X64.Stack_i.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_src_stack64s (base num_slots: nat) (h: vale_stack) : Vale.Def.Prop_s.prop0
[]
Vale.X64.Stack_i.valid_src_stack64s
{ "file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
base: Prims.nat -> num_slots: Prims.nat -> h: Vale.X64.Stack_i.vale_stack -> Vale.Def.Prop_s.prop0
{ "end_col": 30, "end_line": 30, "start_col": 2, "start_line": 28 }
Prims.Tot
val modifies_stack (lo_rsp hi_rsp: nat) (h h': vale_stack) : Vale.Def.Prop_s.prop0
[ { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let modifies_stack (lo_rsp hi_rsp:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') } valid_src_stack64 addr h /\ (addr + 8 <= lo_rsp || addr >= hi_rsp) ==> valid_src_stack64 addr h' /\ load_stack64 addr h == load_stack64 addr h'
val modifies_stack (lo_rsp hi_rsp: nat) (h h': vale_stack) : Vale.Def.Prop_s.prop0 let modifies_stack (lo_rsp hi_rsp: nat) (h h': vale_stack) : Vale.Def.Prop_s.prop0 =
false
null
false
forall addr. {:pattern (load_stack64 addr h')\/(valid_src_stack64 addr h')} valid_src_stack64 addr h /\ (addr + 8 <= lo_rsp || addr >= hi_rsp) ==> valid_src_stack64 addr h' /\ load_stack64 addr h == load_stack64 addr h'
{ "checked_file": "Vale.X64.Stack_i.fsti.checked", "dependencies": [ "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Stack_i.fsti" }
[ "total" ]
[ "Prims.nat", "Vale.X64.Stack_i.vale_stack", "Prims.l_Forall", "Prims.int", "Prims.l_imp", "Prims.l_and", "Prims.b2t", "Vale.X64.Stack_i.valid_src_stack64", "Prims.op_BarBar", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Prims.op_GreaterThanOrEqual", "Prims.eq2", "Vale.X64.Memory.nat64", "Vale.X64.Stack_i.load_stack64", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.X64.Stack_i open FStar.Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Prop_s val vale_stack : Type u#0 val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64 val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32 val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack val init_rsp (h:vale_stack) : (n:nat64{n >= 4096})
false
true
Vale.X64.Stack_i.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val modifies_stack (lo_rsp hi_rsp: nat) (h h': vale_stack) : Vale.Def.Prop_s.prop0
[]
Vale.X64.Stack_i.modifies_stack
{ "file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
lo_rsp: Prims.nat -> hi_rsp: Prims.nat -> h: Vale.X64.Stack_i.vale_stack -> h': Vale.X64.Stack_i.vale_stack -> Vale.Def.Prop_s.prop0
{ "end_col": 49, "end_line": 25, "start_col": 2, "start_line": 22 }
Prims.Tot
val modifies_stacktaint (lo_rsp hi_rsp: nat) (h h': memtaint) : Vale.Def.Prop_s.prop0
[ { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let modifies_stacktaint (lo_rsp hi_rsp:nat) (h h':memtaint) : Vale.Def.Prop_s.prop0 = forall addr t. {:pattern (valid_taint_stack64 addr t h') } (addr + 8 <= lo_rsp || addr >= hi_rsp) ==> valid_taint_stack64 addr t h == valid_taint_stack64 addr t h'
val modifies_stacktaint (lo_rsp hi_rsp: nat) (h h': memtaint) : Vale.Def.Prop_s.prop0 let modifies_stacktaint (lo_rsp hi_rsp: nat) (h h': memtaint) : Vale.Def.Prop_s.prop0 =
false
null
false
forall addr t. {:pattern (valid_taint_stack64 addr t h')} (addr + 8 <= lo_rsp || addr >= hi_rsp) ==> valid_taint_stack64 addr t h == valid_taint_stack64 addr t h'
{ "checked_file": "Vale.X64.Stack_i.fsti.checked", "dependencies": [ "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Stack_i.fsti" }
[ "total" ]
[ "Prims.nat", "Vale.X64.Memory.memtaint", "Prims.l_Forall", "Prims.int", "Vale.Arch.HeapTypes_s.taint", "Prims.l_imp", "Prims.b2t", "Prims.op_BarBar", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Prims.op_GreaterThanOrEqual", "Prims.eq2", "Vale.Def.Prop_s.prop0", "Vale.X64.Stack_i.valid_taint_stack64" ]
[]
module Vale.X64.Stack_i open FStar.Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Prop_s val vale_stack : Type u#0 val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64 val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32 val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack val init_rsp (h:vale_stack) : (n:nat64{n >= 4096}) let modifies_stack (lo_rsp hi_rsp:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') } valid_src_stack64 addr h /\ (addr + 8 <= lo_rsp || addr >= hi_rsp) ==> valid_src_stack64 addr h' /\ load_stack64 addr h == load_stack64 addr h' let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (valid_src_stack64 addr h)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h (* Validity preservation *) val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures valid_src_stack64 i (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 i (store_stack64 ptr v h))] val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures valid_src_stack64 ptr (free_stack64 start finish h)) [SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))] (* Validity update *) val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (valid_src_stack64 ptr (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))] (* Classic select/update lemmas *) val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (load_stack64 ptr (store_stack64 ptr v h) == v) [SMTPat (load_stack64 ptr (store_stack64 ptr v h))] val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h)) [SMTPat (load_stack64 i (store_stack64 ptr v h))] val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h)) [SMTPat (load_stack64 ptr (free_stack64 start finish h))] (* Free composition *) val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma (requires start <= inter /\ inter <= finish) (ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h) [SMTPat (free_stack64 inter finish (free_stack64 start inter h))] (* Preservation of the initial stack pointer *) val lemma_same_init_rsp_free_stack64 (start:int) (finish:int) (h:vale_stack) : Lemma (init_rsp (free_stack64 start finish h) == init_rsp h) [SMTPat (init_rsp (free_stack64 start finish h))] val lemma_same_init_rsp_store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (init_rsp (store_stack64 ptr v h) == init_rsp h) [SMTPat (init_rsp (store_stack64 ptr v h))] // Taint for the stack val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint val lemma_valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires valid_taint_stack64 ptr t stackTaint) (ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t) val lemma_valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires valid_taint_stack128 ptr t stackTaint) (ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t) val lemma_valid_taint_stack64_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t) (ensures valid_taint_stack64 ptr t stackTaint) val lemma_correct_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint)) [SMTPat (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))] val lemma_frame_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma (requires i >= ptr + 8 \/ i + 8 <= ptr) (ensures valid_taint_stack64 i t' stackTaint == valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint)) [SMTPat (valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))] let valid_stack_slot64 (ptr:int) (h:vale_stack) (t:taint) (stackTaint:memtaint) = valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint let valid_stack_slot64s (base num_slots:nat) (h:vale_stack) (t:taint) (stackTaint:memtaint) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (valid_src_stack64 addr h) \/ (valid_taint_stack64 addr t stackTaint) \/ (valid_stack_slot64 addr h t stackTaint)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h /\ valid_taint_stack64 addr t stackTaint
false
true
Vale.X64.Stack_i.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val modifies_stacktaint (lo_rsp hi_rsp: nat) (h h': memtaint) : Vale.Def.Prop_s.prop0
[]
Vale.X64.Stack_i.modifies_stacktaint
{ "file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
lo_rsp: Prims.nat -> hi_rsp: Prims.nat -> h: Vale.X64.Memory.memtaint -> h': Vale.X64.Memory.memtaint -> Vale.Def.Prop_s.prop0
{ "end_col": 67, "end_line": 124, "start_col": 2, "start_line": 122 }
Prims.Tot
val valid_stack_slot64s (base num_slots: nat) (h: vale_stack) (t: taint) (stackTaint: memtaint) : Vale.Def.Prop_s.prop0
[ { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_stack_slot64s (base num_slots:nat) (h:vale_stack) (t:taint) (stackTaint:memtaint) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (valid_src_stack64 addr h) \/ (valid_taint_stack64 addr t stackTaint) \/ (valid_stack_slot64 addr h t stackTaint)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h /\ valid_taint_stack64 addr t stackTaint
val valid_stack_slot64s (base num_slots: nat) (h: vale_stack) (t: taint) (stackTaint: memtaint) : Vale.Def.Prop_s.prop0 let valid_stack_slot64s (base num_slots: nat) (h: vale_stack) (t: taint) (stackTaint: memtaint) : Vale.Def.Prop_s.prop0 =
false
null
false
forall addr. {:pattern (valid_src_stack64 addr h)\/(valid_taint_stack64 addr t stackTaint)\/(valid_stack_slot64 addr h t stackTaint)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h /\ valid_taint_stack64 addr t stackTaint
{ "checked_file": "Vale.X64.Stack_i.fsti.checked", "dependencies": [ "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Stack_i.fsti" }
[ "total" ]
[ "Prims.nat", "Vale.X64.Stack_i.vale_stack", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Memory.memtaint", "Prims.l_Forall", "Prims.int", "Prims.l_imp", "Prims.b2t", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.op_Equality", "Prims.op_Modulus", "Prims.op_Subtraction", "Prims.l_and", "Vale.X64.Stack_i.valid_src_stack64", "Vale.X64.Stack_i.valid_taint_stack64", "Vale.X64.Stack_i.valid_stack_slot64", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.X64.Stack_i open FStar.Mul open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Def.Prop_s val vale_stack : Type u#0 val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64 val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32 val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack val init_rsp (h:vale_stack) : (n:nat64{n >= 4096}) let modifies_stack (lo_rsp hi_rsp:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') } valid_src_stack64 addr h /\ (addr + 8 <= lo_rsp || addr >= hi_rsp) ==> valid_src_stack64 addr h' /\ load_stack64 addr h == load_stack64 addr h' let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 = forall addr . {:pattern (valid_src_stack64 addr h)} (base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==> valid_src_stack64 addr h (* Validity preservation *) val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures valid_src_stack64 i (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 i (store_stack64 ptr v h))] val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures valid_src_stack64 ptr (free_stack64 start finish h)) [SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))] (* Validity update *) val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (valid_src_stack64 ptr (store_stack64 ptr v h)) [SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))] (* Classic select/update lemmas *) val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (load_stack64 ptr (store_stack64 ptr v h) == v) [SMTPat (load_stack64 ptr (store_stack64 ptr v h))] val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma (requires valid_src_stack64 i h /\ (i >= ptr + 8 \/ i + 8 <= ptr)) (ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h)) [SMTPat (load_stack64 i (store_stack64 ptr v h))] val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma (requires valid_src_stack64 ptr h /\ (ptr >= finish \/ ptr + 8 <= start)) (ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h)) [SMTPat (load_stack64 ptr (free_stack64 start finish h))] (* Free composition *) val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma (requires start <= inter /\ inter <= finish) (ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h) [SMTPat (free_stack64 inter finish (free_stack64 start inter h))] (* Preservation of the initial stack pointer *) val lemma_same_init_rsp_free_stack64 (start:int) (finish:int) (h:vale_stack) : Lemma (init_rsp (free_stack64 start finish h) == init_rsp h) [SMTPat (init_rsp (free_stack64 start finish h))] val lemma_same_init_rsp_store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma (init_rsp (store_stack64 ptr v h) == init_rsp h) [SMTPat (init_rsp (store_stack64 ptr v h))] // Taint for the stack val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0 val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint val lemma_valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires valid_taint_stack64 ptr t stackTaint) (ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t) val lemma_valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires valid_taint_stack128 ptr t stackTaint) (ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t) val lemma_valid_taint_stack64_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t) (ensures valid_taint_stack64 ptr t stackTaint) val lemma_correct_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint)) [SMTPat (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))] val lemma_frame_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma (requires i >= ptr + 8 \/ i + 8 <= ptr) (ensures valid_taint_stack64 i t' stackTaint == valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint)) [SMTPat (valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))] let valid_stack_slot64 (ptr:int) (h:vale_stack) (t:taint) (stackTaint:memtaint) = valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint
false
true
Vale.X64.Stack_i.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_stack_slot64s (base num_slots: nat) (h: vale_stack) (t: taint) (stackTaint: memtaint) : Vale.Def.Prop_s.prop0
[]
Vale.X64.Stack_i.valid_stack_slot64s
{ "file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
base: Prims.nat -> num_slots: Prims.nat -> h: Vale.X64.Stack_i.vale_stack -> t: Vale.Arch.HeapTypes_s.taint -> stackTaint: Vale.X64.Memory.memtaint -> Vale.Def.Prop_s.prop0
{ "end_col": 71, "end_line": 119, "start_col": 2, "start_line": 116 }
Prims.Tot
val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul)
val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l =
false
null
false
(vec_and l (mask26 w), vec_shift_right l 26ul)
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "total" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "FStar.Pervasives.Native.Mktuple2", "Lib.IntVector.vec_and", "Lib.IntTypes.U64", "Hacl.Spec.Poly1305.Field32xN.mask26", "Lib.IntVector.vec_shift_right", "FStar.UInt32.__uint_to_t", "FStar.Pervasives.Native.tuple2" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_zero
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Hacl.Spec.Poly1305.Field32xN.uint64xN w -> Hacl.Spec.Poly1305.Field32xN.uint64xN w * Hacl.Spec.Poly1305.Field32xN.uint64xN w
{ "end_col": 75, "end_line": 23, "start_col": 29, "start_line": 23 }
FStar.Pervasives.Lemma
val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp)
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp)
val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp =
false
null
true
let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp)
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem_wide5", "Lib.Sequence.eq_intro", "Hacl.Spec.Poly1305.Vec.pfelem", "Hacl.Spec.Poly1305.Field32xN.feval5", "Prims.unit", "FStar.Classical.forall_intro", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.eq2", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Hacl.Spec.Poly1305.Field32xN.carry_wide_felem5", "Lib.Sequence.op_String_Access", "Hacl.Poly1305.Field32xN.Lemmas1.carry_wide_felem5_eval_lemma_i", "Hacl.Spec.Poly1305.Field32xN.felem5" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp)
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp)
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_wide_felem5_eval_lemma
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
inp: Hacl.Spec.Poly1305.Field32xN.felem_wide5 w -> FStar.Pervasives.Lemma (requires Hacl.Spec.Poly1305.Field32xN.felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures Hacl.Spec.Poly1305.Field32xN.feval5 (Hacl.Spec.Poly1305.Field32xN.carry_wide_felem5 inp) == Hacl.Spec.Poly1305.Field32xN.feval5 inp)
{ "end_col": 34, "end_line": 469, "start_col": 41, "start_line": 466 }
FStar.Pervasives.Lemma
val lemma_prime: unit -> Lemma (pow2 130 % prime = 5)
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime
val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () =
false
null
true
assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Prims.unit", "FStar.Math.Lemmas.modulo_lemma", "Hacl.Spec.Poly1305.Vec.prime", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.pow2" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5)
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_prime: unit -> Lemma (pow2 130 % prime = 5)
[]
Hacl.Poly1305.Field32xN.Lemmas1.lemma_prime
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Prims.pow2 130 % Hacl.Spec.Poly1305.Vec.prime = 5)
{ "end_col": 40, "end_line": 19, "start_col": 2, "start_line": 17 }
FStar.Pervasives.Lemma
val carry_full_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_fits5 inp (8, 8, 8, 8, 8)) (ensures feval5 (carry_full_felem5 #w inp) == feval5 inp)
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_full_felem5_eval_lemma #w inp = let o = carry_full_felem5 #w inp in FStar.Classical.forall_intro (carry_full_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp)
val carry_full_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_fits5 inp (8, 8, 8, 8, 8)) (ensures feval5 (carry_full_felem5 #w inp) == feval5 inp) let carry_full_felem5_eval_lemma #w inp =
false
null
true
let o = carry_full_felem5 #w inp in FStar.Classical.forall_intro (carry_full_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp)
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem_wide5", "Lib.Sequence.eq_intro", "Hacl.Spec.Poly1305.Vec.pfelem", "Hacl.Spec.Poly1305.Field32xN.feval5", "Prims.unit", "FStar.Classical.forall_intro", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.eq2", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Hacl.Spec.Poly1305.Field32xN.carry_full_felem5", "Lib.Sequence.op_String_Access", "Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_eval_lemma_i", "Hacl.Spec.Poly1305.Field32xN.felem5" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26) val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4)) let acc_inv_lemma #w acc cin = match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3 val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9) let carry_full_felem5_fits_lemma0 #w (f0, f1, f2, f3, f4) = let tmp0,c0 = carry26 f0 (zero w) in carry26_fits_lemma 1 8 f0 (zero w); let tmp1,c1 = carry26 f1 c0 in carry26_fits_lemma 1 8 f1 c0; let tmp2,c2 = carry26 f2 c1 in carry26_fits_lemma 1 8 f2 c1; let tmp3,c3 = carry26 f3 c2 in carry26_fits_lemma 1 8 f3 c2; let tmp4,c4 = carry26 f4 c3 in carry26_fits_lemma 1 8 f4 c3; assert (felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1)); assert (uint64xN_fits c4 9) val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (acc_inv_t (carry_full_felem5 f)) let carry_full_felem5_fits_lemma #w f = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_full_felem5_fits_lemma0 #w f; assert (felem_fits1 tmp0 1 /\ uint64xN_fits c4 9); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in acc_inv_lemma (tmp0, tmp1, tmp2, tmp3, tmp4) (vec_smul_mod c4 (u64 5)) val carry_full_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in v ti0 == vc0 * pow2 26 + v t0 /\ v ti1 + vc0 == vc1 * pow2 26 + v t1 /\ v ti2 + vc1 == vc2 * pow2 26 + v t2 /\ v ti3 + vc2 == vc3 * pow2 26 + v t3 /\ v ti4 + vc3 == vc4 * pow2 26 + v t4)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_full_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 = let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v ti0 + v ti1 * pow26 + v ti2 * pow52 + v ti3 * pow78 + v ti4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_full_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_full_felem5_eval_lemma_i1 #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in carry26_eval_lemma 1 8 i0 (zero w); assert (v ti0 == vc0 * pow2 26 + v t0); carry26_eval_lemma 1 8 i1 c0; assert (v ti1 + vc0 == vc1 * pow2 26 + v t1); carry26_eval_lemma 1 8 i2 c1; assert (v ti2 + vc1 == vc2 * pow2 26 + v t2); carry26_eval_lemma 1 8 i3 c2; assert (v ti3 + vc2 == vc3 * pow2 26 + v t3); carry26_eval_lemma 1 8 i4 c3; assert (v ti4 + vc3 == vc4 * pow2 26 + v t4); carry_full_felem5_eval_lemma_i0 (ti0, ti1, ti2, ti3, ti4) (t0, t1, t2, t3, t4) vc0 vc1 vc2 vc3 vc4; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) val carry_full_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma ((feval5 (carry_full_felem5 #w inp)).[i] == (feval5 inp).[i]) let carry_full_felem5_eval_lemma_i #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc4 = (uint64xN_v c4).[i] in carry_full_felem5_fits_lemma0 #w inp; let cin = vec_smul_mod c4 (u64 5) in assert ((uint64xN_v cin).[i] == vc4 * 5); let tmp0' = vec_add_mod tmp0 cin in Math.Lemmas.small_mod ((uint64xN_v tmp0).[i] + vc4 * 5) (pow2 64); assert ((uint64xN_v tmp0').[i] == (uint64xN_v tmp0).[i] + vc4 * 5); let out = (tmp0', tmp1, tmp2, tmp3, tmp4) in let (o0, o1, o2, o3, o4) = as_tup64_i out i in assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_full_felem5_eval_lemma_i1 #w inp i; assert ((feval5 out).[i] == (feval5 inp).[i]) val carry_full_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_fits5 inp (8, 8, 8, 8, 8)) (ensures feval5 (carry_full_felem5 #w inp) == feval5 inp)
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_full_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_fits5 inp (8, 8, 8, 8, 8)) (ensures feval5 (carry_full_felem5 #w inp) == feval5 inp)
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_eval_lemma
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
inp: Hacl.Spec.Poly1305.Field32xN.felem_wide5 w -> FStar.Pervasives.Lemma (requires Hacl.Spec.Poly1305.Field32xN.felem_fits5 inp (8, 8, 8, 8, 8)) (ensures Hacl.Spec.Poly1305.Field32xN.feval5 (Hacl.Spec.Poly1305.Field32xN.carry_full_felem5 inp) == Hacl.Spec.Poly1305.Field32xN.feval5 inp)
{ "end_col": 34, "end_line": 868, "start_col": 41, "start_line": 865 }
Prims.Tot
val acc_inv_t (#w: lanes) (acc: felem5 w) : Type0
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1))
val acc_inv_t (#w: lanes) (acc: felem5 w) : Type0 let acc_inv_t (#w: lanes) (acc: felem5 w) : Type0 =
false
null
false
let o0, o1, o2, o3, o4 = acc in forall (i: nat). i < w ==> (if uint_v (vec_v o0).[ i ] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[ i ] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1))
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "total" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.uint_v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.Sequence.op_String_Access", "Lib.IntTypes.uint_t", "Lib.IntVector.vec_v", "Prims.pow2", "Prims.l_and", "Hacl.Spec.Poly1305.Field32xN.tup64_fits5", "Hacl.Spec.Poly1305.Field32xN.as_tup64_i", "FStar.Pervasives.Native.Mktuple5", "Prims.op_Modulus", "Prims.bool", "Prims.logical" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val acc_inv_t (#w: lanes) (acc: felem5 w) : Type0
[]
Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_t
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
acc: Hacl.Spec.Poly1305.Field32xN.felem5 w -> Type0
{ "end_col": 56, "end_line": 639, "start_col": 49, "start_line": 633 }
Prims.Tot
val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4')
val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) =
false
null
false
let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in let t1' = vec_add_mod t1 c5 in (t0', t1', t2, t3', t4')
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "total" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem_wide5", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "FStar.Pervasives.Native.Mktuple5", "Lib.IntVector.vec_t", "Lib.IntTypes.U64", "Lib.IntVector.vec_add_mod", "Hacl.Spec.Poly1305.Field32xN.felem5", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Poly1305.Field32xN.carry26", "Lib.IntVector.vec_smul_mod", "Lib.IntTypes.u64", "Hacl.Spec.Poly1305.Field32xN.carry26_wide", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_zero" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_wide_felem5_compact
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
inp: Hacl.Spec.Poly1305.Field32xN.felem_wide5 w -> Hacl.Spec.Poly1305.Field32xN.felem5 w
{ "end_col": 26, "end_line": 83, "start_col": 55, "start_line": 60 }
FStar.Pervasives.Lemma
val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime)
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f'
val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' =
false
null
true
let f0, f1, f2, f3, f4 = f in let f0', f1', f2', f3', f4' = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f'
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.tup64_5", "Hacl.Spec.Poly1305.Field32xN.tup64_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Lib.IntTypes.uint64", "Prims.op_AmpAmp", "Prims.op_BarBar", "Prims.op_disEquality", "Prims.int", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.op_LessThan", "Prims.op_Equality", "Lib.IntTypes.range_t", "Hacl.Poly1305.Field32xN.Lemmas1.lemma_subtract_p5_0", "Prims.bool", "Hacl.Poly1305.Field32xN.Lemmas1.lemma_subtract_p5_1", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Hacl.Spec.Poly1305.Field32xN.max26", "Prims.op_Subtraction", "Prims.pow2" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime)
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime)
[]
Hacl.Poly1305.Field32xN.Lemmas1.lemma_subtract_p5
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.tup64_5 {Hacl.Spec.Poly1305.Field32xN.tup64_fits5 f (1, 1, 1, 1, 1)} -> f': Hacl.Spec.Poly1305.Field32xN.tup64_5 -> FStar.Pervasives.Lemma (requires (let _ = f in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ f0 f1 f2 f3 f4 = _ in let _ = f' in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ f0' f1' f2' f3' f4' = _ in Lib.IntTypes.v f4 = 0x3ffffff && Lib.IntTypes.v f3 = 0x3ffffff && Lib.IntTypes.v f2 = 0x3ffffff && Lib.IntTypes.v f1 = 0x3ffffff && Lib.IntTypes.v f0 >= 0x3fffffb /\ Lib.IntTypes.v f0' = Lib.IntTypes.v f0 - 0x3fffffb && Lib.IntTypes.v f1' = Lib.IntTypes.v f1 - 0x3ffffff && Lib.IntTypes.v f2' = Lib.IntTypes.v f2 - 0x3ffffff && Lib.IntTypes.v f3' = Lib.IntTypes.v f3 - 0x3ffffff && Lib.IntTypes.v f4' = Lib.IntTypes.v f4 - 0x3ffffff \/ Lib.IntTypes.v f4 <> 0x3ffffff || Lib.IntTypes.v f3 <> 0x3ffffff || Lib.IntTypes.v f2 <> 0x3ffffff || Lib.IntTypes.v f1 <> 0x3ffffff || Lib.IntTypes.v f0 < 0x3fffffb /\ Lib.IntTypes.v f0' = Lib.IntTypes.v f0 && Lib.IntTypes.v f1' = Lib.IntTypes.v f1 && Lib.IntTypes.v f2' = Lib.IntTypes.v f2 && Lib.IntTypes.v f3' = Lib.IntTypes.v f3 && Lib.IntTypes.v f4' = Lib.IntTypes.v f4) <: Type0) <: Type0)) (ensures Hacl.Spec.Poly1305.Field32xN.as_nat5 f' == Hacl.Spec.Poly1305.Field32xN.as_nat5 f % Hacl.Spec.Poly1305.Vec.prime)
{ "end_col": 31, "end_line": 558, "start_col": 28, "start_line": 551 }
FStar.Pervasives.Lemma
val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9)
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_full_felem5_fits_lemma0 #w (f0, f1, f2, f3, f4) = let tmp0,c0 = carry26 f0 (zero w) in carry26_fits_lemma 1 8 f0 (zero w); let tmp1,c1 = carry26 f1 c0 in carry26_fits_lemma 1 8 f1 c0; let tmp2,c2 = carry26 f2 c1 in carry26_fits_lemma 1 8 f2 c1; let tmp3,c3 = carry26 f3 c2 in carry26_fits_lemma 1 8 f3 c2; let tmp4,c4 = carry26 f4 c3 in carry26_fits_lemma 1 8 f4 c3; assert (felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1)); assert (uint64xN_fits c4 9)
val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9) let carry_full_felem5_fits_lemma0 #w (f0, f1, f2, f3, f4) =
false
null
true
let tmp0, c0 = carry26 f0 (zero w) in carry26_fits_lemma 1 8 f0 (zero w); let tmp1, c1 = carry26 f1 c0 in carry26_fits_lemma 1 8 f1 c0; let tmp2, c2 = carry26 f2 c1 in carry26_fits_lemma 1 8 f2 c1; let tmp3, c3 = carry26 f3 c2 in carry26_fits_lemma 1 8 f3 c2; let tmp4, c4 = carry26 f4 c3 in carry26_fits_lemma 1 8 f4 c3; assert (felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1)); assert (uint64xN_fits c4 9)
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Spec.Poly1305.Field32xN.felem_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Prims._assert", "Hacl.Spec.Poly1305.Field32xN.uint64xN_fits", "Prims.unit", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_fits_lemma", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Poly1305.Field32xN.carry26", "Hacl.Spec.Poly1305.Field32xN.zero" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26) val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4)) let acc_inv_lemma #w acc cin = match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3 val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9)
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_fits_lemma0
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.felem5 w {Hacl.Spec.Poly1305.Field32xN.felem_fits5 f (8, 8, 8, 8, 8)} -> FStar.Pervasives.Lemma (ensures (let _ = f in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ f0 f1 f2 f3 f4 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f0 (Hacl.Spec.Poly1305.Field32xN.zero w) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp0 c0 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f1 c0 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp1 c1 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f2 c1 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp2 c2 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f3 c2 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp3 c3 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f4 c3 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp4 c4 = _ in Hacl.Spec.Poly1305.Field32xN.felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ Hacl.Spec.Poly1305.Field32xN.uint64xN_fits c4 9) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0))
{ "end_col": 29, "end_line": 705, "start_col": 59, "start_line": 693 }
FStar.Pervasives.Lemma
val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f
val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f =
false
null
true
let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i: nat{i < w}). uint_v (vec_v l1).[ i ] == uint_v (vec_v f).[ i ]); assert (forall (i: nat{i < w}). (vec_v l1).[ i ] == (vec_v f).[ i ]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Lib.IntVector.vecv_extensionality", "Lib.IntTypes.U64", "Prims.unit", "Prims._assert", "Prims.eq2", "Lib.IntVector.vec_v_t", "Lib.IntVector.vec_v", "Lib.Sequence.eq_intro", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.l_Forall", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.op_String_Access", "Prims.int", "Lib.IntTypes.range", "Lib.IntTypes.uint_v", "Lib.Sequence.lseq", "Lib.Sequence.map2", "Lib.IntTypes.op_Plus_Dot", "Hacl.Spec.Poly1305.Field32xN.zero", "Lib.IntVector.vec_t", "Lib.IntVector.vec_add_mod" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w))
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_zero_eq
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.uint64xN w -> FStar.Pervasives.Lemma (ensures Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_zero f == Hacl.Spec.Poly1305.Field32xN.carry26_wide f (Hacl.Spec.Poly1305.Field32xN.zero w))
{ "end_col": 26, "end_line": 34, "start_col": 31, "start_line": 27 }
FStar.Pervasives.Lemma
val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (acc_inv_t (carry_full_felem5 f))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_full_felem5_fits_lemma #w f = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_full_felem5_fits_lemma0 #w f; assert (felem_fits1 tmp0 1 /\ uint64xN_fits c4 9); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in acc_inv_lemma (tmp0, tmp1, tmp2, tmp3, tmp4) (vec_smul_mod c4 (u64 5))
val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (acc_inv_t (carry_full_felem5 f)) let carry_full_felem5_fits_lemma #w f =
false
null
true
let f0, f1, f2, f3, f4 = f in let tmp0, c0 = carry26 f0 (zero w) in let tmp1, c1 = carry26 f1 c0 in let tmp2, c2 = carry26 f2 c1 in let tmp3, c3 = carry26 f3 c2 in let tmp4, c4 = carry26 f4 c3 in carry_full_felem5_fits_lemma0 #w f; assert (felem_fits1 tmp0 1 /\ uint64xN_fits c4 9); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in acc_inv_lemma (tmp0, tmp1, tmp2, tmp3, tmp4) (vec_smul_mod c4 (u64 5))
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Spec.Poly1305.Field32xN.felem_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_lemma", "Lib.IntVector.vec_smul_mod", "Lib.IntTypes.U64", "Lib.IntTypes.u64", "Lib.IntVector.vec_t", "Lib.IntVector.vec_add_mod", "Prims.unit", "Prims._assert", "Prims.l_and", "Hacl.Spec.Poly1305.Field32xN.felem_fits1", "Hacl.Spec.Poly1305.Field32xN.uint64xN_fits", "Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_fits_lemma0", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Poly1305.Field32xN.carry26", "Hacl.Spec.Poly1305.Field32xN.zero" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26) val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4)) let acc_inv_lemma #w acc cin = match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3 val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9) let carry_full_felem5_fits_lemma0 #w (f0, f1, f2, f3, f4) = let tmp0,c0 = carry26 f0 (zero w) in carry26_fits_lemma 1 8 f0 (zero w); let tmp1,c1 = carry26 f1 c0 in carry26_fits_lemma 1 8 f1 c0; let tmp2,c2 = carry26 f2 c1 in carry26_fits_lemma 1 8 f2 c1; let tmp3,c3 = carry26 f3 c2 in carry26_fits_lemma 1 8 f3 c2; let tmp4,c4 = carry26 f4 c3 in carry26_fits_lemma 1 8 f4 c3; assert (felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1)); assert (uint64xN_fits c4 9) val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} ->
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (acc_inv_t (carry_full_felem5 f))
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_fits_lemma
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.felem5 w {Hacl.Spec.Poly1305.Field32xN.felem_fits5 f (8, 8, 8, 8, 8)} -> FStar.Pervasives.Lemma (ensures Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_t (Hacl.Spec.Poly1305.Field32xN.carry_full_felem5 f))
{ "end_col": 72, "end_line": 720, "start_col": 39, "start_line": 710 }
FStar.Pervasives.Lemma
val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime)
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime
val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' =
false
null
true
let f0, f1, f2, f3, f4 = f in let f0', f1', f2', f3', f4' = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.tup64_5", "Hacl.Spec.Poly1305.Field32xN.tup64_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Lib.IntTypes.uint64", "FStar.Math.Lemmas.modulo_lemma", "Hacl.Spec.Poly1305.Field32xN.as_nat5", "Hacl.Spec.Poly1305.Vec.prime", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Subtraction", "Prims.pow2", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "Prims.int", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Field32xN.pow104", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Hacl.Spec.Poly1305.Field32xN.pow26", "Hacl.Spec.Poly1305.Field32xN.pow52", "Hacl.Spec.Poly1305.Field32xN.pow78", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.Spec.Poly1305.Field32xN.max26" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime)
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime)
[]
Hacl.Poly1305.Field32xN.Lemmas1.lemma_subtract_p5_0
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.tup64_5 {Hacl.Spec.Poly1305.Field32xN.tup64_fits5 f (1, 1, 1, 1, 1)} -> f': Hacl.Spec.Poly1305.Field32xN.tup64_5 -> FStar.Pervasives.Lemma (requires (let _ = f in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ f0 f1 f2 f3 f4 = _ in let _ = f' in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ f0' f1' f2' f3' f4' = _ in Lib.IntTypes.v f4 <> 0x3ffffff || Lib.IntTypes.v f3 <> 0x3ffffff || Lib.IntTypes.v f2 <> 0x3ffffff || Lib.IntTypes.v f1 <> 0x3ffffff || Lib.IntTypes.v f0 < 0x3fffffb /\ Lib.IntTypes.v f0' = Lib.IntTypes.v f0 && Lib.IntTypes.v f1' = Lib.IntTypes.v f1 && Lib.IntTypes.v f2' = Lib.IntTypes.v f2 && Lib.IntTypes.v f3' = Lib.IntTypes.v f3 && Lib.IntTypes.v f4' = Lib.IntTypes.v f4) <: Type0) <: Type0)) (ensures Hacl.Spec.Poly1305.Field32xN.as_nat5 f' == Hacl.Spec.Poly1305.Field32xN.as_nat5 f % Hacl.Spec.Poly1305.Vec.prime)
{ "end_col": 51, "end_line": 495, "start_col": 30, "start_line": 484 }
FStar.Pervasives.Lemma
val carry_full_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (felem_fits5 (carry_full_felem5 f) (2, 1, 1, 1, 1) /\ feval5 (carry_full_felem5 f) == feval5 f)
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_full_felem5_lemma #w f = carry_full_felem5_eval_lemma f; carry_full_felem5_fits_lemma f
val carry_full_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (felem_fits5 (carry_full_felem5 f) (2, 1, 1, 1, 1) /\ feval5 (carry_full_felem5 f) == feval5 f) let carry_full_felem5_lemma #w f =
false
null
true
carry_full_felem5_eval_lemma f; carry_full_felem5_fits_lemma f
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Spec.Poly1305.Field32xN.felem_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_fits_lemma", "Prims.unit", "Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_eval_lemma" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26) val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4)) let acc_inv_lemma #w acc cin = match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3 val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9) let carry_full_felem5_fits_lemma0 #w (f0, f1, f2, f3, f4) = let tmp0,c0 = carry26 f0 (zero w) in carry26_fits_lemma 1 8 f0 (zero w); let tmp1,c1 = carry26 f1 c0 in carry26_fits_lemma 1 8 f1 c0; let tmp2,c2 = carry26 f2 c1 in carry26_fits_lemma 1 8 f2 c1; let tmp3,c3 = carry26 f3 c2 in carry26_fits_lemma 1 8 f3 c2; let tmp4,c4 = carry26 f4 c3 in carry26_fits_lemma 1 8 f4 c3; assert (felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1)); assert (uint64xN_fits c4 9) val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (acc_inv_t (carry_full_felem5 f)) let carry_full_felem5_fits_lemma #w f = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_full_felem5_fits_lemma0 #w f; assert (felem_fits1 tmp0 1 /\ uint64xN_fits c4 9); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in acc_inv_lemma (tmp0, tmp1, tmp2, tmp3, tmp4) (vec_smul_mod c4 (u64 5)) val carry_full_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in v ti0 == vc0 * pow2 26 + v t0 /\ v ti1 + vc0 == vc1 * pow2 26 + v t1 /\ v ti2 + vc1 == vc2 * pow2 26 + v t2 /\ v ti3 + vc2 == vc3 * pow2 26 + v t3 /\ v ti4 + vc3 == vc4 * pow2 26 + v t4)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_full_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 = let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v ti0 + v ti1 * pow26 + v ti2 * pow52 + v ti3 * pow78 + v ti4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_full_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_full_felem5_eval_lemma_i1 #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in carry26_eval_lemma 1 8 i0 (zero w); assert (v ti0 == vc0 * pow2 26 + v t0); carry26_eval_lemma 1 8 i1 c0; assert (v ti1 + vc0 == vc1 * pow2 26 + v t1); carry26_eval_lemma 1 8 i2 c1; assert (v ti2 + vc1 == vc2 * pow2 26 + v t2); carry26_eval_lemma 1 8 i3 c2; assert (v ti3 + vc2 == vc3 * pow2 26 + v t3); carry26_eval_lemma 1 8 i4 c3; assert (v ti4 + vc3 == vc4 * pow2 26 + v t4); carry_full_felem5_eval_lemma_i0 (ti0, ti1, ti2, ti3, ti4) (t0, t1, t2, t3, t4) vc0 vc1 vc2 vc3 vc4; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) val carry_full_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma ((feval5 (carry_full_felem5 #w inp)).[i] == (feval5 inp).[i]) let carry_full_felem5_eval_lemma_i #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc4 = (uint64xN_v c4).[i] in carry_full_felem5_fits_lemma0 #w inp; let cin = vec_smul_mod c4 (u64 5) in assert ((uint64xN_v cin).[i] == vc4 * 5); let tmp0' = vec_add_mod tmp0 cin in Math.Lemmas.small_mod ((uint64xN_v tmp0).[i] + vc4 * 5) (pow2 64); assert ((uint64xN_v tmp0').[i] == (uint64xN_v tmp0).[i] + vc4 * 5); let out = (tmp0', tmp1, tmp2, tmp3, tmp4) in let (o0, o1, o2, o3, o4) = as_tup64_i out i in assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_full_felem5_eval_lemma_i1 #w inp i; assert ((feval5 out).[i] == (feval5 inp).[i]) val carry_full_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_fits5 inp (8, 8, 8, 8, 8)) (ensures feval5 (carry_full_felem5 #w inp) == feval5 inp) let carry_full_felem5_eval_lemma #w inp = let o = carry_full_felem5 #w inp in FStar.Classical.forall_intro (carry_full_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val carry_full_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (felem_fits5 (carry_full_felem5 f) (2, 1, 1, 1, 1) /\ feval5 (carry_full_felem5 f) == feval5 f)
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_full_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (felem_fits5 (carry_full_felem5 f) (2, 1, 1, 1, 1) /\ feval5 (carry_full_felem5 f) == feval5 f)
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_lemma
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.felem5 w {Hacl.Spec.Poly1305.Field32xN.felem_fits5 f (8, 8, 8, 8, 8)} -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Poly1305.Field32xN.felem_fits5 (Hacl.Spec.Poly1305.Field32xN.carry_full_felem5 f) (2, 1, 1, 1, 1) /\ Hacl.Spec.Poly1305.Field32xN.feval5 (Hacl.Spec.Poly1305.Field32xN.carry_full_felem5 f) == Hacl.Spec.Poly1305.Field32xN.feval5 f)
{ "end_col": 32, "end_line": 879, "start_col": 2, "start_line": 878 }
FStar.Pervasives.Lemma
val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime)
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i)
val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i =
false
null
true
assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i)
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Spec.Poly1305.Field32xN.felem_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims._assert", "Prims.eq2", "Hacl.Spec.Poly1305.Field32xN.tup64_5", "Hacl.Poly1305.Field32xN.Lemmas1.subtract_p5_s", "Hacl.Spec.Poly1305.Field32xN.as_tup64_i", "Hacl.Spec.Poly1305.Field32xN.subtract_p5", "Prims.unit" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime)
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime)
[]
Hacl.Poly1305.Field32xN.Lemmas1.subtract_p5_felem5_lemma_i
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.felem5 w {Hacl.Spec.Poly1305.Field32xN.felem_fits5 f (1, 1, 1, 1, 1)} -> i: Prims.nat{i < w} -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Poly1305.Field32xN.tup64_fits5 (Hacl.Spec.Poly1305.Field32xN.as_tup64_i (Hacl.Spec.Poly1305.Field32xN.subtract_p5 f) i) (1, 1, 1, 1, 1) /\ Hacl.Spec.Poly1305.Field32xN.as_nat5 (Hacl.Spec.Poly1305.Field32xN.as_tup64_i (Hacl.Spec.Poly1305.Field32xN.subtract_p5 f) i) == Hacl.Spec.Poly1305.Field32xN.as_nat5 (Hacl.Spec.Poly1305.Field32xN.as_tup64_i f i) % Hacl.Spec.Poly1305.Vec.prime)
{ "end_col": 66, "end_line": 608, "start_col": 2, "start_line": 608 }
FStar.Pervasives.Lemma
val carry_reduce_lemma_i: #w:lanes -> l:uint64xN w -> cin:uint64xN w -> i:nat{i < w} -> Lemma (requires (uint64xN_v l).[i] <= 2 * max26 /\ (uint64xN_v cin).[i] <= 62 * max26) (ensures (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= 63 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_reduce_lemma_i #w l cin i = let li = (vec_v l).[i] in let cini = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v li + v cini) (pow2 64); let li' = li +! cini in let li0 = li' &. mask26 in let li1 = li' >>. 26ul in mod_mask_lemma li' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v li') 26 32; FStar.Math.Lemmas.pow2_minus 32 26
val carry_reduce_lemma_i: #w:lanes -> l:uint64xN w -> cin:uint64xN w -> i:nat{i < w} -> Lemma (requires (uint64xN_v l).[i] <= 2 * max26 /\ (uint64xN_v cin).[i] <= 62 * max26) (ensures (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= 63 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry_reduce_lemma_i #w l cin i =
false
null
true
let li = (vec_v l).[ i ] in let cini = (vec_v cin).[ i ] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v li + v cini) (pow2 64); let li' = li +! cini in let li0 = li' &. mask26 in let li1 = li' >>. 26ul in mod_mask_lemma li' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v li') 26 32; FStar.Math.Lemmas.pow2_minus 32 26
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Math.Lemmas.pow2_minus", "Prims.unit", "FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims._assert", "Prims.eq2", "Lib.IntTypes.range_t", "Lib.IntTypes.mod_mask", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.mod_mask_lemma", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Greater_Greater_Dot", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.op_Plus_Bang", "FStar.Math.Lemmas.modulo_lemma", "Prims.op_Addition", "Prims.pow2", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "Prims.int", "Prims.op_Subtraction", "Lib.IntTypes.range", "Lib.IntTypes.u64", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.IntVector.vec_v", "Lib.Sequence.op_String_Access", "Lib.IntTypes.uint_t" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26) val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4)) let acc_inv_lemma #w acc cin = match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3 val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9) let carry_full_felem5_fits_lemma0 #w (f0, f1, f2, f3, f4) = let tmp0,c0 = carry26 f0 (zero w) in carry26_fits_lemma 1 8 f0 (zero w); let tmp1,c1 = carry26 f1 c0 in carry26_fits_lemma 1 8 f1 c0; let tmp2,c2 = carry26 f2 c1 in carry26_fits_lemma 1 8 f2 c1; let tmp3,c3 = carry26 f3 c2 in carry26_fits_lemma 1 8 f3 c2; let tmp4,c4 = carry26 f4 c3 in carry26_fits_lemma 1 8 f4 c3; assert (felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1)); assert (uint64xN_fits c4 9) val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (acc_inv_t (carry_full_felem5 f)) let carry_full_felem5_fits_lemma #w f = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_full_felem5_fits_lemma0 #w f; assert (felem_fits1 tmp0 1 /\ uint64xN_fits c4 9); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in acc_inv_lemma (tmp0, tmp1, tmp2, tmp3, tmp4) (vec_smul_mod c4 (u64 5)) val carry_full_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in v ti0 == vc0 * pow2 26 + v t0 /\ v ti1 + vc0 == vc1 * pow2 26 + v t1 /\ v ti2 + vc1 == vc2 * pow2 26 + v t2 /\ v ti3 + vc2 == vc3 * pow2 26 + v t3 /\ v ti4 + vc3 == vc4 * pow2 26 + v t4)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_full_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 = let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v ti0 + v ti1 * pow26 + v ti2 * pow52 + v ti3 * pow78 + v ti4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_full_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_full_felem5_eval_lemma_i1 #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in carry26_eval_lemma 1 8 i0 (zero w); assert (v ti0 == vc0 * pow2 26 + v t0); carry26_eval_lemma 1 8 i1 c0; assert (v ti1 + vc0 == vc1 * pow2 26 + v t1); carry26_eval_lemma 1 8 i2 c1; assert (v ti2 + vc1 == vc2 * pow2 26 + v t2); carry26_eval_lemma 1 8 i3 c2; assert (v ti3 + vc2 == vc3 * pow2 26 + v t3); carry26_eval_lemma 1 8 i4 c3; assert (v ti4 + vc3 == vc4 * pow2 26 + v t4); carry_full_felem5_eval_lemma_i0 (ti0, ti1, ti2, ti3, ti4) (t0, t1, t2, t3, t4) vc0 vc1 vc2 vc3 vc4; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) val carry_full_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma ((feval5 (carry_full_felem5 #w inp)).[i] == (feval5 inp).[i]) let carry_full_felem5_eval_lemma_i #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc4 = (uint64xN_v c4).[i] in carry_full_felem5_fits_lemma0 #w inp; let cin = vec_smul_mod c4 (u64 5) in assert ((uint64xN_v cin).[i] == vc4 * 5); let tmp0' = vec_add_mod tmp0 cin in Math.Lemmas.small_mod ((uint64xN_v tmp0).[i] + vc4 * 5) (pow2 64); assert ((uint64xN_v tmp0').[i] == (uint64xN_v tmp0).[i] + vc4 * 5); let out = (tmp0', tmp1, tmp2, tmp3, tmp4) in let (o0, o1, o2, o3, o4) = as_tup64_i out i in assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_full_felem5_eval_lemma_i1 #w inp i; assert ((feval5 out).[i] == (feval5 inp).[i]) val carry_full_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_fits5 inp (8, 8, 8, 8, 8)) (ensures feval5 (carry_full_felem5 #w inp) == feval5 inp) let carry_full_felem5_eval_lemma #w inp = let o = carry_full_felem5 #w inp in FStar.Classical.forall_intro (carry_full_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val carry_full_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (felem_fits5 (carry_full_felem5 f) (2, 1, 1, 1, 1) /\ feval5 (carry_full_felem5 f) == feval5 f) let carry_full_felem5_lemma #w f = carry_full_felem5_eval_lemma f; carry_full_felem5_fits_lemma f val carry_reduce_lemma_i: #w:lanes -> l:uint64xN w -> cin:uint64xN w -> i:nat{i < w} -> Lemma (requires (uint64xN_v l).[i] <= 2 * max26 /\ (uint64xN_v cin).[i] <= 62 * max26) (ensures (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= 63 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]))
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_reduce_lemma_i: #w:lanes -> l:uint64xN w -> cin:uint64xN w -> i:nat{i < w} -> Lemma (requires (uint64xN_v l).[i] <= 2 * max26 /\ (uint64xN_v cin).[i] <= 62 * max26) (ensures (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= 63 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]))
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_reduce_lemma_i
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Hacl.Spec.Poly1305.Field32xN.uint64xN w -> cin: Hacl.Spec.Poly1305.Field32xN.uint64xN w -> i: Prims.nat{i < w} -> FStar.Pervasives.Lemma (requires (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l).[ i ] <= 2 * Hacl.Spec.Poly1305.Field32xN.max26 /\ (Hacl.Spec.Poly1305.Field32xN.uint64xN_v cin).[ i ] <= 62 * Hacl.Spec.Poly1305.Field32xN.max26) (ensures (let _ = Hacl.Spec.Poly1305.Field32xN.carry26 l cin in (let FStar.Pervasives.Native.Mktuple2 #_ #_ l0 l1 = _ in (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l0).[ i ] <= Hacl.Spec.Poly1305.Field32xN.max26 /\ (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l1).[ i ] <= 63 /\ (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l).[ i ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v cin).[ i ] == (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l1).[ i ] * Prims.pow2 26 + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l0).[ i ]) <: Type0))
{ "end_col": 36, "end_line": 909, "start_col": 37, "start_line": 897 }
Prims.Pure
val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime)
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4')
val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_s #w f i =
false
null
false
let f0, f1, f2, f3, f4 = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4')
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Spec.Poly1305.Field32xN.felem_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.uint64", "Prims.unit", "Hacl.Poly1305.Field32xN.Lemmas1.lemma_subtract_p5", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.u64", "Lib.IntTypes.logand_lemma", "Lib.IntTypes.gte_mask", "Lib.IntTypes.eq_mask", "Hacl.Spec.Poly1305.Field32xN.tup64_5", "Hacl.Spec.Poly1305.Field32xN.as_tup64_i" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime)
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime)
[]
Hacl.Poly1305.Field32xN.Lemmas1.subtract_p5_s
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.felem5 w {Hacl.Spec.Poly1305.Field32xN.felem_fits5 f (1, 1, 1, 1, 1)} -> i: Prims.nat{i < w} -> Prims.Pure Hacl.Spec.Poly1305.Field32xN.tup64_5
{ "end_col": 27, "end_line": 595, "start_col": 26, "start_line": 573 }
FStar.Pervasives.Lemma
val carry_reduce_felem5_lemma: #w:lanes -> f:felem5 w{acc_inv_t f} -> Lemma (felem_fits5 (carry_full_felem5 f) (1, 1, 1, 1, 1) /\ feval5 (carry_full_felem5 f) == feval5 f)
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_reduce_felem5_lemma #w f = carry_reduce_felem5_fits_lemma #w f; carry_full_felem5_eval_lemma f
val carry_reduce_felem5_lemma: #w:lanes -> f:felem5 w{acc_inv_t f} -> Lemma (felem_fits5 (carry_full_felem5 f) (1, 1, 1, 1, 1) /\ feval5 (carry_full_felem5 f) == feval5 f) let carry_reduce_felem5_lemma #w f =
false
null
true
carry_reduce_felem5_fits_lemma #w f; carry_full_felem5_eval_lemma f
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_t", "Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_eval_lemma", "Prims.unit", "Hacl.Poly1305.Field32xN.Lemmas1.carry_reduce_felem5_fits_lemma" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26) val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4)) let acc_inv_lemma #w acc cin = match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3 val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9) let carry_full_felem5_fits_lemma0 #w (f0, f1, f2, f3, f4) = let tmp0,c0 = carry26 f0 (zero w) in carry26_fits_lemma 1 8 f0 (zero w); let tmp1,c1 = carry26 f1 c0 in carry26_fits_lemma 1 8 f1 c0; let tmp2,c2 = carry26 f2 c1 in carry26_fits_lemma 1 8 f2 c1; let tmp3,c3 = carry26 f3 c2 in carry26_fits_lemma 1 8 f3 c2; let tmp4,c4 = carry26 f4 c3 in carry26_fits_lemma 1 8 f4 c3; assert (felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1)); assert (uint64xN_fits c4 9) val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (acc_inv_t (carry_full_felem5 f)) let carry_full_felem5_fits_lemma #w f = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_full_felem5_fits_lemma0 #w f; assert (felem_fits1 tmp0 1 /\ uint64xN_fits c4 9); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in acc_inv_lemma (tmp0, tmp1, tmp2, tmp3, tmp4) (vec_smul_mod c4 (u64 5)) val carry_full_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in v ti0 == vc0 * pow2 26 + v t0 /\ v ti1 + vc0 == vc1 * pow2 26 + v t1 /\ v ti2 + vc1 == vc2 * pow2 26 + v t2 /\ v ti3 + vc2 == vc3 * pow2 26 + v t3 /\ v ti4 + vc3 == vc4 * pow2 26 + v t4)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_full_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 = let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v ti0 + v ti1 * pow26 + v ti2 * pow52 + v ti3 * pow78 + v ti4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_full_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_full_felem5_eval_lemma_i1 #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in carry26_eval_lemma 1 8 i0 (zero w); assert (v ti0 == vc0 * pow2 26 + v t0); carry26_eval_lemma 1 8 i1 c0; assert (v ti1 + vc0 == vc1 * pow2 26 + v t1); carry26_eval_lemma 1 8 i2 c1; assert (v ti2 + vc1 == vc2 * pow2 26 + v t2); carry26_eval_lemma 1 8 i3 c2; assert (v ti3 + vc2 == vc3 * pow2 26 + v t3); carry26_eval_lemma 1 8 i4 c3; assert (v ti4 + vc3 == vc4 * pow2 26 + v t4); carry_full_felem5_eval_lemma_i0 (ti0, ti1, ti2, ti3, ti4) (t0, t1, t2, t3, t4) vc0 vc1 vc2 vc3 vc4; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) val carry_full_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma ((feval5 (carry_full_felem5 #w inp)).[i] == (feval5 inp).[i]) let carry_full_felem5_eval_lemma_i #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc4 = (uint64xN_v c4).[i] in carry_full_felem5_fits_lemma0 #w inp; let cin = vec_smul_mod c4 (u64 5) in assert ((uint64xN_v cin).[i] == vc4 * 5); let tmp0' = vec_add_mod tmp0 cin in Math.Lemmas.small_mod ((uint64xN_v tmp0).[i] + vc4 * 5) (pow2 64); assert ((uint64xN_v tmp0').[i] == (uint64xN_v tmp0).[i] + vc4 * 5); let out = (tmp0', tmp1, tmp2, tmp3, tmp4) in let (o0, o1, o2, o3, o4) = as_tup64_i out i in assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_full_felem5_eval_lemma_i1 #w inp i; assert ((feval5 out).[i] == (feval5 inp).[i]) val carry_full_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_fits5 inp (8, 8, 8, 8, 8)) (ensures feval5 (carry_full_felem5 #w inp) == feval5 inp) let carry_full_felem5_eval_lemma #w inp = let o = carry_full_felem5 #w inp in FStar.Classical.forall_intro (carry_full_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val carry_full_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (felem_fits5 (carry_full_felem5 f) (2, 1, 1, 1, 1) /\ feval5 (carry_full_felem5 f) == feval5 f) let carry_full_felem5_lemma #w f = carry_full_felem5_eval_lemma f; carry_full_felem5_fits_lemma f val carry_reduce_lemma_i: #w:lanes -> l:uint64xN w -> cin:uint64xN w -> i:nat{i < w} -> Lemma (requires (uint64xN_v l).[i] <= 2 * max26 /\ (uint64xN_v cin).[i] <= 62 * max26) (ensures (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= 63 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry_reduce_lemma_i #w l cin i = let li = (vec_v l).[i] in let cini = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v li + v cini) (pow2 64); let li' = li +! cini in let li0 = li' &. mask26 in let li1 = li' >>. 26ul in mod_mask_lemma li' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v li') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 #push-options "--z3rlimit 600" val carry_reduce_felem5_fits_lemma_i0: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v tmp0).[i] < pow2 26 else (uint64xN_v tmp0).[i] <= 46) /\ (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63)) let carry_reduce_felem5_fits_lemma_i0 #w f i = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in carry_reduce_lemma_i f0 (zero w) i; assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v tmp0).[i] < pow2 26 else (uint64xN_v tmp0).[i] <= 46); assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c0).[i] = 0 else (uint64xN_v c0).[i] <= 63); let tmp1,c1 = carry26 f1 c0 in carry_reduce_lemma_i f1 c0 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c1).[i] = 0 else (uint64xN_v c1).[i] <= 63); let tmp2,c2 = carry26 f2 c1 in carry_reduce_lemma_i f2 c1 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c2).[i] = 0 else (uint64xN_v c2).[i] <= 63); let tmp3,c3 = carry26 f3 c2 in carry_reduce_lemma_i f3 c2 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c3).[i] = 0 else (uint64xN_v c3).[i] <= 63); let tmp4,c4 = carry26 f4 c3 in carry_reduce_lemma_i f4 c3 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63); assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c0).[i] = 0 /\ (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63) val carry_reduce_felem5_fits_lemma_i1: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (uint64xN_v c4).[i] <= 63 /\ tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1)) let carry_reduce_felem5_fits_lemma_i1 #w f i = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in carry_reduce_lemma_i f0 (zero w) i; let tmp1,c1 = carry26 f1 c0 in carry_reduce_lemma_i f1 c0 i; let tmp2,c2 = carry26 f2 c1 in carry_reduce_lemma_i f2 c1 i; let tmp3,c3 = carry26 f3 c2 in carry_reduce_lemma_i f3 c2 i; let tmp4,c4 = carry26 f4 c3 in carry_reduce_lemma_i f4 c3 i; let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in assert (tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1)) val carry_reduce_felem5_fits_lemma_i: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (carry_full_felem5 f) i) (1, 1, 1, 1, 1)) let carry_reduce_felem5_fits_lemma_i #w f i = assert_norm (max26 == pow2 26 - 1); let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_reduce_felem5_fits_lemma_i1 #w f i; FStar.Math.Lemmas.modulo_lemma ((uint64xN_v c4).[i] * 5) (pow2 64); assert ((uint64xN_v (vec_smul_mod c4 (u64 5))).[i] == (uint64xN_v c4).[i] * 5); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in carry_reduce_felem5_fits_lemma_i0 #w f i; let res = (tmp0', tmp1, tmp2, tmp3, tmp4) in assert (tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1)) #pop-options #push-options "--z3rlimit 100" val carry_reduce_felem5_fits_lemma: #w:lanes -> f:felem5 w{acc_inv_t f} -> Lemma (felem_fits5 (carry_full_felem5 f) (1, 1, 1, 1, 1)) let carry_reduce_felem5_fits_lemma #w f = match w with | 1 -> carry_reduce_felem5_fits_lemma_i #w f 0 | 2 -> carry_reduce_felem5_fits_lemma_i #w f 0; carry_reduce_felem5_fits_lemma_i #w f 1 | 4 -> carry_reduce_felem5_fits_lemma_i #w f 0; carry_reduce_felem5_fits_lemma_i #w f 1; carry_reduce_felem5_fits_lemma_i #w f 2; carry_reduce_felem5_fits_lemma_i #w f 3 val carry_reduce_felem5_lemma: #w:lanes -> f:felem5 w{acc_inv_t f} -> Lemma (felem_fits5 (carry_full_felem5 f) (1, 1, 1, 1, 1) /\ feval5 (carry_full_felem5 f) == feval5 f)
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_reduce_felem5_lemma: #w:lanes -> f:felem5 w{acc_inv_t f} -> Lemma (felem_fits5 (carry_full_felem5 f) (1, 1, 1, 1, 1) /\ feval5 (carry_full_felem5 f) == feval5 f)
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_reduce_felem5_lemma
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.felem5 w {Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_t f} -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Poly1305.Field32xN.felem_fits5 (Hacl.Spec.Poly1305.Field32xN.carry_full_felem5 f) (1, 1, 1, 1, 1) /\ Hacl.Spec.Poly1305.Field32xN.feval5 (Hacl.Spec.Poly1305.Field32xN.carry_full_felem5 f) == Hacl.Spec.Poly1305.Field32xN.feval5 f)
{ "end_col": 32, "end_line": 1033, "start_col": 2, "start_line": 1032 }
FStar.Pervasives.Lemma
val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2
val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f =
false
null
true
let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Hacl.Spec.Poly1305.Field32xN.uint64xN_fits", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Field32xN.max26", "Lib.IntVector.vecv_extensionality", "Lib.IntTypes.U64", "Prims.unit", "Lib.Sequence.eq_intro", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Lib.IntVector.vec_v", "FStar.Classical.forall_intro", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.eq2", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Star_Dot", "Lib.IntTypes.u64", "Lib.Sequence.op_String_Access", "Lib.IntTypes.op_Plus_Dot", "Lib.IntTypes.op_Less_Less_Dot", "FStar.UInt32.__uint_to_t", "Hacl.Poly1305.Field32xN.Lemmas1.vec_smul_mod_five_i", "Lib.IntVector.vec_t", "Lib.IntVector.vec_add_mod", "Lib.IntVector.vec_shift_left", "Lib.Sequence.lseq", "Lib.Sequence.map", "Lib.IntTypes.mul_mod", "Lib.IntTypes.mk_int", "Prims.int", "Lib.IntTypes.range", "Lib.IntTypes.v", "Lib.IntVector.vec_smul_mod" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul))
[]
Hacl.Poly1305.Field32xN.Lemmas1.vec_smul_mod_five
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.uint64xN_fits f (4096 * Hacl.Spec.Poly1305.Field32xN.max26)} -> FStar.Pervasives.Lemma (ensures Lib.IntVector.vec_smul_mod f (Lib.IntTypes.u64 5) == Lib.IntVector.vec_add_mod f (Lib.IntVector.vec_shift_left f 2ul))
{ "end_col": 27, "end_line": 55, "start_col": 28, "start_line": 50 }
FStar.Pervasives.Lemma
val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul))
val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i =
false
null
true
let f = (vec_v f).[ i ] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul))
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Hacl.Spec.Poly1305.Field32xN.uint64xN_fits", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Field32xN.max26", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v_injective", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Plus_Dot", "Lib.IntTypes.op_Less_Less_Dot", "FStar.UInt32.__uint_to_t", "Prims.unit", "Lib.IntTypes.op_Star_Dot", "Lib.IntTypes.u64", "Prims._assert", "Prims.eq2", "Prims.int", "Lib.IntTypes.v", "Prims.op_Addition", "FStar.Math.Lemmas.small_mod", "Prims.pow2", "Prims.op_Modulus", "Lib.IntTypes.int_t", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.IntVector.vec_v", "Lib.Sequence.op_String_Access", "Lib.IntTypes.uint_t" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul))
[]
Hacl.Poly1305.Field32xN.Lemmas1.vec_smul_mod_five_i
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.uint64xN_fits f (4096 * Hacl.Spec.Poly1305.Field32xN.max26)} -> i: Prims.nat{i < w} -> FStar.Pervasives.Lemma (ensures Lib.IntTypes.u64 5 *. (Lib.IntVector.vec_v f).[ i ] == (Lib.IntVector.vec_v f).[ i ] +. ((Lib.IntVector.vec_v f).[ i ] <<. 2ul))
{ "end_col": 32, "end_line": 46, "start_col": 32, "start_line": 38 }
FStar.Pervasives.Lemma
val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31)
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3
val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp =
false
null
true
let x0, x1, x2, x3, x4 = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem_wide5", "Hacl.Spec.Poly1305.Field32xN.felem_wide_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_fits_lemma", "Prims.unit", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Poly1305.Field32xN.carry26_wide", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_fits_lemma", "Hacl.Spec.Poly1305.Field32xN.carry26", "Hacl.Spec.Poly1305.Field32xN.zero", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_zero_eq", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_zero" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31)
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31)
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_wide_felem5_fits_lemma0
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
inp: Hacl.Spec.Poly1305.Field32xN.felem_wide5 w {Hacl.Spec.Poly1305.Field32xN.felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> FStar.Pervasives.Lemma (ensures (let _ = inp in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ x0 x1 x2 x3 x4 = _ in let _ = Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_zero x0 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ t0 c0 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26_wide x1 c0 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ t1 c1 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26_wide x2 c1 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ t2 c2 = _ in let _ = Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_zero x3 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ t3 c3 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 t3 c2 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ t3' c6 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26_wide x4 c3 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ t4 c4 = _ in let t4' = Lib.IntVector.vec_add_mod t4 c6 in let tmp = t0, t1, t2, t3', t4' in Hacl.Spec.Poly1305.Field32xN.felem_fits5 tmp (1, 1, 1, 1, 2) /\ Hacl.Spec.Poly1305.Field32xN.felem_fits1 c4 31) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0))
{ "end_col": 38, "end_line": 268, "start_col": 42, "start_line": 253 }
FStar.Pervasives.Lemma
val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1)))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26)
val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i =
false
null
true
let i0, i1, i2, i3, i4 = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[ i ] == (vec_v i0).[ i ] +. (vec_v cin).[ i ]); assert ((uint64xN_v i0).[ i ] + (uint64xN_v cin).[ i ] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[ i ] + (uint64xN_v cin).[ i ]) (pow2 26)
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Spec.Poly1305.Field32xN.felem_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Hacl.Spec.Poly1305.Field32xN.uint64xN_fits", "Prims.b2t", "Prims.op_LessThan", "FStar.Math.Lemmas.euclidean_division_definition", "Prims.op_Addition", "Lib.Sequence.op_String_Access", "Hacl.Spec.Poly1305.Field32xN.uint64xN_v", "Prims.pow2", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "Prims.int", "Hacl.Spec.Poly1305.Field32xN.max26", "Prims.op_Subtraction", "Prims._assert", "Prims.op_LessThanOrEqual", "Prims.eq2", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.uint_t", "Lib.IntVector.vec_v", "Lib.IntTypes.op_Plus_Dot", "Lib.IntVector.vec_t", "Lib.IntVector.vec_add_mod" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1)))
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1)))
[]
Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_lemma_i
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
acc: Hacl.Spec.Poly1305.Field32xN.felem5 w {Hacl.Spec.Poly1305.Field32xN.felem_fits5 acc (1, 1, 1, 1, 1)} -> cin: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.uint64xN_fits cin 45} -> i: Prims.nat{i < w} -> FStar.Pervasives.Lemma (ensures (let _ = acc in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ i0 i1 i2 i3 i4 = _ in let i0' = Lib.IntVector.vec_add_mod i0 cin in let acc1 = i0', i1, i2, i3, i4 in (match (Hacl.Spec.Poly1305.Field32xN.uint64xN_v i0').[ i ] >= Prims.pow2 26 with | true -> Hacl.Spec.Poly1305.Field32xN.tup64_fits5 (Hacl.Spec.Poly1305.Field32xN.as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (Hacl.Spec.Poly1305.Field32xN.uint64xN_v i0').[ i ] % Prims.pow2 26 < 47 | _ -> Hacl.Spec.Poly1305.Field32xN.tup64_fits5 (Hacl.Spec.Poly1305.Field32xN.as_tup64_i acc1 i) (1, 1, 1, 1, 1)) <: Type0) <: Type0))
{ "end_col": 104, "end_line": 661, "start_col": 34, "start_line": 655 }
FStar.Pervasives.Lemma
val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5))
val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) let carry_wide_felem5_fits_lemma #w inp =
false
null
true
let x0, x1, x2, x3, x4 = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5))
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem_wide5", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_fits_lemma", "Lib.IntVector.vec_smul_mod", "Lib.IntTypes.U64", "Lib.IntTypes.u64", "Prims.unit", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Poly1305.Field32xN.carry26", "Hacl.Poly1305.Field32xN.Lemmas1.vec_smul_mod_five", "Hacl.Poly1305.Field32xN.Lemmas1.carry_wide_felem5_fits_lemma0", "Lib.IntVector.vec_t", "Lib.IntVector.vec_add_mod", "Hacl.Spec.Poly1305.Field32xN.carry26_wide", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_zero" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2))
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2))
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_wide_felem5_fits_lemma
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
inp: Hacl.Spec.Poly1305.Field32xN.felem_wide5 w -> FStar.Pervasives.Lemma (requires Hacl.Spec.Poly1305.Field32xN.felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures Hacl.Spec.Poly1305.Field32xN.felem_fits5 (Hacl.Spec.Poly1305.Field32xN.carry_wide_felem5 inp ) (1, 2, 1, 1, 2))
{ "end_col": 55, "end_line": 291, "start_col": 41, "start_line": 279 }
FStar.Pervasives.Lemma
val carry_reduce_felem5_fits_lemma_i1: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (uint64xN_v c4).[i] <= 63 /\ tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_reduce_felem5_fits_lemma_i1 #w f i = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in carry_reduce_lemma_i f0 (zero w) i; let tmp1,c1 = carry26 f1 c0 in carry_reduce_lemma_i f1 c0 i; let tmp2,c2 = carry26 f2 c1 in carry_reduce_lemma_i f2 c1 i; let tmp3,c3 = carry26 f3 c2 in carry_reduce_lemma_i f3 c2 i; let tmp4,c4 = carry26 f4 c3 in carry_reduce_lemma_i f4 c3 i; let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in assert (tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1))
val carry_reduce_felem5_fits_lemma_i1: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (uint64xN_v c4).[i] <= 63 /\ tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1)) let carry_reduce_felem5_fits_lemma_i1 #w f i =
false
null
true
let f0, f1, f2, f3, f4 = f in let tmp0, c0 = carry26 f0 (zero w) in carry_reduce_lemma_i f0 (zero w) i; let tmp1, c1 = carry26 f1 c0 in carry_reduce_lemma_i f1 c0 i; let tmp2, c2 = carry26 f2 c1 in carry_reduce_lemma_i f2 c1 i; let tmp3, c3 = carry26 f3 c2 in carry_reduce_lemma_i f3 c2 i; let tmp4, c4 = carry26 f4 c3 in carry_reduce_lemma_i f4 c3 i; let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in assert (tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1))
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_t", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Prims._assert", "Hacl.Spec.Poly1305.Field32xN.tup64_fits5", "Hacl.Spec.Poly1305.Field32xN.as_tup64_i", "FStar.Pervasives.Native.Mktuple5", "FStar.Pervasives.Native.tuple5", "Prims.unit", "Hacl.Poly1305.Field32xN.Lemmas1.carry_reduce_lemma_i", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Poly1305.Field32xN.carry26", "Hacl.Spec.Poly1305.Field32xN.zero" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26) val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4)) let acc_inv_lemma #w acc cin = match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3 val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9) let carry_full_felem5_fits_lemma0 #w (f0, f1, f2, f3, f4) = let tmp0,c0 = carry26 f0 (zero w) in carry26_fits_lemma 1 8 f0 (zero w); let tmp1,c1 = carry26 f1 c0 in carry26_fits_lemma 1 8 f1 c0; let tmp2,c2 = carry26 f2 c1 in carry26_fits_lemma 1 8 f2 c1; let tmp3,c3 = carry26 f3 c2 in carry26_fits_lemma 1 8 f3 c2; let tmp4,c4 = carry26 f4 c3 in carry26_fits_lemma 1 8 f4 c3; assert (felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1)); assert (uint64xN_fits c4 9) val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (acc_inv_t (carry_full_felem5 f)) let carry_full_felem5_fits_lemma #w f = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_full_felem5_fits_lemma0 #w f; assert (felem_fits1 tmp0 1 /\ uint64xN_fits c4 9); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in acc_inv_lemma (tmp0, tmp1, tmp2, tmp3, tmp4) (vec_smul_mod c4 (u64 5)) val carry_full_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in v ti0 == vc0 * pow2 26 + v t0 /\ v ti1 + vc0 == vc1 * pow2 26 + v t1 /\ v ti2 + vc1 == vc2 * pow2 26 + v t2 /\ v ti3 + vc2 == vc3 * pow2 26 + v t3 /\ v ti4 + vc3 == vc4 * pow2 26 + v t4)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_full_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 = let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v ti0 + v ti1 * pow26 + v ti2 * pow52 + v ti3 * pow78 + v ti4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_full_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_full_felem5_eval_lemma_i1 #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in carry26_eval_lemma 1 8 i0 (zero w); assert (v ti0 == vc0 * pow2 26 + v t0); carry26_eval_lemma 1 8 i1 c0; assert (v ti1 + vc0 == vc1 * pow2 26 + v t1); carry26_eval_lemma 1 8 i2 c1; assert (v ti2 + vc1 == vc2 * pow2 26 + v t2); carry26_eval_lemma 1 8 i3 c2; assert (v ti3 + vc2 == vc3 * pow2 26 + v t3); carry26_eval_lemma 1 8 i4 c3; assert (v ti4 + vc3 == vc4 * pow2 26 + v t4); carry_full_felem5_eval_lemma_i0 (ti0, ti1, ti2, ti3, ti4) (t0, t1, t2, t3, t4) vc0 vc1 vc2 vc3 vc4; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) val carry_full_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma ((feval5 (carry_full_felem5 #w inp)).[i] == (feval5 inp).[i]) let carry_full_felem5_eval_lemma_i #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc4 = (uint64xN_v c4).[i] in carry_full_felem5_fits_lemma0 #w inp; let cin = vec_smul_mod c4 (u64 5) in assert ((uint64xN_v cin).[i] == vc4 * 5); let tmp0' = vec_add_mod tmp0 cin in Math.Lemmas.small_mod ((uint64xN_v tmp0).[i] + vc4 * 5) (pow2 64); assert ((uint64xN_v tmp0').[i] == (uint64xN_v tmp0).[i] + vc4 * 5); let out = (tmp0', tmp1, tmp2, tmp3, tmp4) in let (o0, o1, o2, o3, o4) = as_tup64_i out i in assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_full_felem5_eval_lemma_i1 #w inp i; assert ((feval5 out).[i] == (feval5 inp).[i]) val carry_full_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_fits5 inp (8, 8, 8, 8, 8)) (ensures feval5 (carry_full_felem5 #w inp) == feval5 inp) let carry_full_felem5_eval_lemma #w inp = let o = carry_full_felem5 #w inp in FStar.Classical.forall_intro (carry_full_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val carry_full_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (felem_fits5 (carry_full_felem5 f) (2, 1, 1, 1, 1) /\ feval5 (carry_full_felem5 f) == feval5 f) let carry_full_felem5_lemma #w f = carry_full_felem5_eval_lemma f; carry_full_felem5_fits_lemma f val carry_reduce_lemma_i: #w:lanes -> l:uint64xN w -> cin:uint64xN w -> i:nat{i < w} -> Lemma (requires (uint64xN_v l).[i] <= 2 * max26 /\ (uint64xN_v cin).[i] <= 62 * max26) (ensures (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= 63 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry_reduce_lemma_i #w l cin i = let li = (vec_v l).[i] in let cini = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v li + v cini) (pow2 64); let li' = li +! cini in let li0 = li' &. mask26 in let li1 = li' >>. 26ul in mod_mask_lemma li' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v li') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 #push-options "--z3rlimit 600" val carry_reduce_felem5_fits_lemma_i0: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v tmp0).[i] < pow2 26 else (uint64xN_v tmp0).[i] <= 46) /\ (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63)) let carry_reduce_felem5_fits_lemma_i0 #w f i = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in carry_reduce_lemma_i f0 (zero w) i; assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v tmp0).[i] < pow2 26 else (uint64xN_v tmp0).[i] <= 46); assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c0).[i] = 0 else (uint64xN_v c0).[i] <= 63); let tmp1,c1 = carry26 f1 c0 in carry_reduce_lemma_i f1 c0 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c1).[i] = 0 else (uint64xN_v c1).[i] <= 63); let tmp2,c2 = carry26 f2 c1 in carry_reduce_lemma_i f2 c1 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c2).[i] = 0 else (uint64xN_v c2).[i] <= 63); let tmp3,c3 = carry26 f3 c2 in carry_reduce_lemma_i f3 c2 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c3).[i] = 0 else (uint64xN_v c3).[i] <= 63); let tmp4,c4 = carry26 f4 c3 in carry_reduce_lemma_i f4 c3 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63); assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c0).[i] = 0 /\ (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63) val carry_reduce_felem5_fits_lemma_i1: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (uint64xN_v c4).[i] <= 63 /\ tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1))
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 600, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_reduce_felem5_fits_lemma_i1: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (uint64xN_v c4).[i] <= 63 /\ tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1))
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_reduce_felem5_fits_lemma_i1
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.felem5 w {Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_t f} -> i: Prims.nat{i < w} -> FStar.Pervasives.Lemma (ensures (let _ = f in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ f0 f1 f2 f3 f4 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f0 (Hacl.Spec.Poly1305.Field32xN.zero w) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp0 c0 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f1 c0 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp1 c1 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f2 c1 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp2 c2 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f3 c2 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp3 c3 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f4 c3 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp4 c4 = _ in let res = tmp0, tmp1, tmp2, tmp3, tmp4 in (Hacl.Spec.Poly1305.Field32xN.uint64xN_v c4).[ i ] <= 63 /\ Hacl.Spec.Poly1305.Field32xN.tup64_fits5 (Hacl.Spec.Poly1305.Field32xN.as_tup64_i res i) (1, 1, 1, 1, 1)) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0))
{ "end_col": 57, "end_line": 977, "start_col": 46, "start_line": 964 }
FStar.Pervasives.Lemma
val carry_reduce_felem5_fits_lemma: #w:lanes -> f:felem5 w{acc_inv_t f} -> Lemma (felem_fits5 (carry_full_felem5 f) (1, 1, 1, 1, 1))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_reduce_felem5_fits_lemma #w f = match w with | 1 -> carry_reduce_felem5_fits_lemma_i #w f 0 | 2 -> carry_reduce_felem5_fits_lemma_i #w f 0; carry_reduce_felem5_fits_lemma_i #w f 1 | 4 -> carry_reduce_felem5_fits_lemma_i #w f 0; carry_reduce_felem5_fits_lemma_i #w f 1; carry_reduce_felem5_fits_lemma_i #w f 2; carry_reduce_felem5_fits_lemma_i #w f 3
val carry_reduce_felem5_fits_lemma: #w:lanes -> f:felem5 w{acc_inv_t f} -> Lemma (felem_fits5 (carry_full_felem5 f) (1, 1, 1, 1, 1)) let carry_reduce_felem5_fits_lemma #w f =
false
null
true
match w with | 1 -> carry_reduce_felem5_fits_lemma_i #w f 0 | 2 -> carry_reduce_felem5_fits_lemma_i #w f 0; carry_reduce_felem5_fits_lemma_i #w f 1 | 4 -> carry_reduce_felem5_fits_lemma_i #w f 0; carry_reduce_felem5_fits_lemma_i #w f 1; carry_reduce_felem5_fits_lemma_i #w f 2; carry_reduce_felem5_fits_lemma_i #w f 3
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_t", "Hacl.Poly1305.Field32xN.Lemmas1.carry_reduce_felem5_fits_lemma_i", "Prims.unit" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26) val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4)) let acc_inv_lemma #w acc cin = match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3 val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9) let carry_full_felem5_fits_lemma0 #w (f0, f1, f2, f3, f4) = let tmp0,c0 = carry26 f0 (zero w) in carry26_fits_lemma 1 8 f0 (zero w); let tmp1,c1 = carry26 f1 c0 in carry26_fits_lemma 1 8 f1 c0; let tmp2,c2 = carry26 f2 c1 in carry26_fits_lemma 1 8 f2 c1; let tmp3,c3 = carry26 f3 c2 in carry26_fits_lemma 1 8 f3 c2; let tmp4,c4 = carry26 f4 c3 in carry26_fits_lemma 1 8 f4 c3; assert (felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1)); assert (uint64xN_fits c4 9) val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (acc_inv_t (carry_full_felem5 f)) let carry_full_felem5_fits_lemma #w f = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_full_felem5_fits_lemma0 #w f; assert (felem_fits1 tmp0 1 /\ uint64xN_fits c4 9); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in acc_inv_lemma (tmp0, tmp1, tmp2, tmp3, tmp4) (vec_smul_mod c4 (u64 5)) val carry_full_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in v ti0 == vc0 * pow2 26 + v t0 /\ v ti1 + vc0 == vc1 * pow2 26 + v t1 /\ v ti2 + vc1 == vc2 * pow2 26 + v t2 /\ v ti3 + vc2 == vc3 * pow2 26 + v t3 /\ v ti4 + vc3 == vc4 * pow2 26 + v t4)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_full_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 = let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v ti0 + v ti1 * pow26 + v ti2 * pow52 + v ti3 * pow78 + v ti4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_full_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_full_felem5_eval_lemma_i1 #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in carry26_eval_lemma 1 8 i0 (zero w); assert (v ti0 == vc0 * pow2 26 + v t0); carry26_eval_lemma 1 8 i1 c0; assert (v ti1 + vc0 == vc1 * pow2 26 + v t1); carry26_eval_lemma 1 8 i2 c1; assert (v ti2 + vc1 == vc2 * pow2 26 + v t2); carry26_eval_lemma 1 8 i3 c2; assert (v ti3 + vc2 == vc3 * pow2 26 + v t3); carry26_eval_lemma 1 8 i4 c3; assert (v ti4 + vc3 == vc4 * pow2 26 + v t4); carry_full_felem5_eval_lemma_i0 (ti0, ti1, ti2, ti3, ti4) (t0, t1, t2, t3, t4) vc0 vc1 vc2 vc3 vc4; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) val carry_full_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma ((feval5 (carry_full_felem5 #w inp)).[i] == (feval5 inp).[i]) let carry_full_felem5_eval_lemma_i #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc4 = (uint64xN_v c4).[i] in carry_full_felem5_fits_lemma0 #w inp; let cin = vec_smul_mod c4 (u64 5) in assert ((uint64xN_v cin).[i] == vc4 * 5); let tmp0' = vec_add_mod tmp0 cin in Math.Lemmas.small_mod ((uint64xN_v tmp0).[i] + vc4 * 5) (pow2 64); assert ((uint64xN_v tmp0').[i] == (uint64xN_v tmp0).[i] + vc4 * 5); let out = (tmp0', tmp1, tmp2, tmp3, tmp4) in let (o0, o1, o2, o3, o4) = as_tup64_i out i in assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_full_felem5_eval_lemma_i1 #w inp i; assert ((feval5 out).[i] == (feval5 inp).[i]) val carry_full_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_fits5 inp (8, 8, 8, 8, 8)) (ensures feval5 (carry_full_felem5 #w inp) == feval5 inp) let carry_full_felem5_eval_lemma #w inp = let o = carry_full_felem5 #w inp in FStar.Classical.forall_intro (carry_full_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val carry_full_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (felem_fits5 (carry_full_felem5 f) (2, 1, 1, 1, 1) /\ feval5 (carry_full_felem5 f) == feval5 f) let carry_full_felem5_lemma #w f = carry_full_felem5_eval_lemma f; carry_full_felem5_fits_lemma f val carry_reduce_lemma_i: #w:lanes -> l:uint64xN w -> cin:uint64xN w -> i:nat{i < w} -> Lemma (requires (uint64xN_v l).[i] <= 2 * max26 /\ (uint64xN_v cin).[i] <= 62 * max26) (ensures (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= 63 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry_reduce_lemma_i #w l cin i = let li = (vec_v l).[i] in let cini = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v li + v cini) (pow2 64); let li' = li +! cini in let li0 = li' &. mask26 in let li1 = li' >>. 26ul in mod_mask_lemma li' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v li') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 #push-options "--z3rlimit 600" val carry_reduce_felem5_fits_lemma_i0: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v tmp0).[i] < pow2 26 else (uint64xN_v tmp0).[i] <= 46) /\ (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63)) let carry_reduce_felem5_fits_lemma_i0 #w f i = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in carry_reduce_lemma_i f0 (zero w) i; assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v tmp0).[i] < pow2 26 else (uint64xN_v tmp0).[i] <= 46); assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c0).[i] = 0 else (uint64xN_v c0).[i] <= 63); let tmp1,c1 = carry26 f1 c0 in carry_reduce_lemma_i f1 c0 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c1).[i] = 0 else (uint64xN_v c1).[i] <= 63); let tmp2,c2 = carry26 f2 c1 in carry_reduce_lemma_i f2 c1 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c2).[i] = 0 else (uint64xN_v c2).[i] <= 63); let tmp3,c3 = carry26 f3 c2 in carry_reduce_lemma_i f3 c2 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c3).[i] = 0 else (uint64xN_v c3).[i] <= 63); let tmp4,c4 = carry26 f4 c3 in carry_reduce_lemma_i f4 c3 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63); assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c0).[i] = 0 /\ (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63) val carry_reduce_felem5_fits_lemma_i1: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (uint64xN_v c4).[i] <= 63 /\ tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1)) let carry_reduce_felem5_fits_lemma_i1 #w f i = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in carry_reduce_lemma_i f0 (zero w) i; let tmp1,c1 = carry26 f1 c0 in carry_reduce_lemma_i f1 c0 i; let tmp2,c2 = carry26 f2 c1 in carry_reduce_lemma_i f2 c1 i; let tmp3,c3 = carry26 f3 c2 in carry_reduce_lemma_i f3 c2 i; let tmp4,c4 = carry26 f4 c3 in carry_reduce_lemma_i f4 c3 i; let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in assert (tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1)) val carry_reduce_felem5_fits_lemma_i: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (carry_full_felem5 f) i) (1, 1, 1, 1, 1)) let carry_reduce_felem5_fits_lemma_i #w f i = assert_norm (max26 == pow2 26 - 1); let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_reduce_felem5_fits_lemma_i1 #w f i; FStar.Math.Lemmas.modulo_lemma ((uint64xN_v c4).[i] * 5) (pow2 64); assert ((uint64xN_v (vec_smul_mod c4 (u64 5))).[i] == (uint64xN_v c4).[i] * 5); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in carry_reduce_felem5_fits_lemma_i0 #w f i; let res = (tmp0', tmp1, tmp2, tmp3, tmp4) in assert (tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1)) #pop-options #push-options "--z3rlimit 100" val carry_reduce_felem5_fits_lemma: #w:lanes -> f:felem5 w{acc_inv_t f} -> Lemma (felem_fits5 (carry_full_felem5 f) (1, 1, 1, 1, 1))
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_reduce_felem5_fits_lemma: #w:lanes -> f:felem5 w{acc_inv_t f} -> Lemma (felem_fits5 (carry_full_felem5 f) (1, 1, 1, 1, 1))
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_reduce_felem5_fits_lemma
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.felem5 w {Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_t f} -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Poly1305.Field32xN.felem_fits5 (Hacl.Spec.Poly1305.Field32xN.carry_full_felem5 f) (1, 1, 1, 1, 1))
{ "end_col": 43, "end_line": 1021, "start_col": 2, "start_line": 1011 }
FStar.Pervasives.Lemma
val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let acc_inv_lemma #w acc cin = match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3
val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4)) let acc_inv_lemma #w acc cin =
false
null
true
match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Spec.Poly1305.Field32xN.felem_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Hacl.Spec.Poly1305.Field32xN.uint64xN_fits", "Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_lemma_i", "Prims.unit" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26) val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4))
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4))
[]
Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_lemma
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
acc: Hacl.Spec.Poly1305.Field32xN.felem5 w {Hacl.Spec.Poly1305.Field32xN.felem_fits5 acc (1, 1, 1, 1, 1)} -> cin: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.uint64xN_fits cin 45} -> FStar.Pervasives.Lemma (ensures (let _ = acc in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ i0 i1 i2 i3 i4 = _ in let i0' = Lib.IntVector.vec_add_mod i0 cin in Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_t (i0', i1, i2, i3, i4)) <: Type0))
{ "end_col": 32, "end_line": 683, "start_col": 2, "start_line": 673 }
FStar.Pervasives.Lemma
val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3
val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin =
false
null
true
carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.scale64", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Hacl.Spec.Poly1305.Field32xN.felem_wide_fits1", "Hacl.Spec.Poly1305.Field32xN.uint64xN_fits", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Field32xN.max26", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_lemma_i", "Prims.unit", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_fits_lemma" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]))
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]))
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_eval_lemma
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.felem_wide_fits1 l m} -> cin: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.uint64xN_fits cin (4096 * Hacl.Spec.Poly1305.Field32xN.max26)} -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.Poly1305.Field32xN.carry26 l cin in (let FStar.Pervasives.Native.Mktuple2 #_ #_ l0 l1 = _ in Hacl.Spec.Poly1305.Field32xN.uint64xN_fits l1 ((m + 1) * Hacl.Spec.Poly1305.Field32xN.max26) /\ (forall (i: Prims.nat). i < w ==> (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l).[ i ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v cin).[ i ] == (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l1).[ i ] * Prims.pow2 26 + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l0).[ i ])) <: Type0))
{ "end_col": 38, "end_line": 160, "start_col": 2, "start_line": 149 }
FStar.Pervasives.Lemma
val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26)
val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i =
false
null
true
let l = (vec_v l).[ i ] in let cin = (vec_v cin).[ i ] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26)
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.scale64", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Hacl.Spec.Poly1305.Field32xN.felem_wide_fits1", "Hacl.Spec.Poly1305.Field32xN.uint64xN_fits", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Field32xN.max26", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Math.Lemmas.euclidean_division_definition", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.pow2", "Prims.unit", "FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1", "Prims._assert", "Prims.eq2", "Lib.IntTypes.range_t", "Lib.IntTypes.mod_mask", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.mod_mask_lemma", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Greater_Greater_Dot", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.op_Plus_Bang", "FStar.Math.Lemmas.modulo_lemma", "Prims.op_Addition", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "Prims.int", "Prims.op_Subtraction", "Lib.IntTypes.range", "Lib.IntTypes.u64", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.IntVector.vec_v", "Lib.Sequence.op_String_Access", "Lib.IntTypes.uint_t" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_lemma_i
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.felem_wide_fits1 l m} -> cin: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.uint64xN_fits cin (4096 * Hacl.Spec.Poly1305.Field32xN.max26)} -> i: Prims.nat{i < w} -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.Poly1305.Field32xN.carry26 l cin in (let FStar.Pervasives.Native.Mktuple2 #_ #_ l0 l1 = _ in (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l0).[ i ] <= Hacl.Spec.Poly1305.Field32xN.max26 /\ (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l1).[ i ] <= (m + 1) * Hacl.Spec.Poly1305.Field32xN.max26 /\ (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l).[ i ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v cin).[ i ] == (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l1).[ i ] * Prims.pow2 26 + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l0).[ i ]) <: Type0))
{ "end_col": 66, "end_line": 109, "start_col": 40, "start_line": 97 }
FStar.Pervasives.Lemma
val carry_full_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_full_felem5_eval_lemma_i1 #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in carry26_eval_lemma 1 8 i0 (zero w); assert (v ti0 == vc0 * pow2 26 + v t0); carry26_eval_lemma 1 8 i1 c0; assert (v ti1 + vc0 == vc1 * pow2 26 + v t1); carry26_eval_lemma 1 8 i2 c1; assert (v ti2 + vc1 == vc2 * pow2 26 + v t2); carry26_eval_lemma 1 8 i3 c2; assert (v ti3 + vc2 == vc3 * pow2 26 + v t3); carry26_eval_lemma 1 8 i4 c3; assert (v ti4 + vc3 == vc4 * pow2 26 + v t4); carry_full_felem5_eval_lemma_i0 (ti0, ti1, ti2, ti3, ti4) (t0, t1, t2, t3, t4) vc0 vc1 vc2 vc3 vc4; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)
val carry_full_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_full_felem5_eval_lemma_i1 #w inp i =
false
null
true
let i0, i1, i2, i3, i4 = inp in let tmp0, c0 = carry26 i0 (zero w) in let tmp1, c1 = carry26 i1 c0 in let tmp2, c2 = carry26 i2 c1 in let tmp3, c3 = carry26 i3 c2 in let tmp4, c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let t0, t1, t2, t3, t4 = as_tup64_i tmp i in let ti0, ti1, ti2, ti3, ti4 = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[ i ] in let vc1 = (uint64xN_v c1).[ i ] in let vc2 = (uint64xN_v c2).[ i ] in let vc3 = (uint64xN_v c3).[ i ] in let vc4 = (uint64xN_v c4).[ i ] in carry26_eval_lemma 1 8 i0 (zero w); assert (v ti0 == vc0 * pow2 26 + v t0); carry26_eval_lemma 1 8 i1 c0; assert (v ti1 + vc0 == vc1 * pow2 26 + v t1); carry26_eval_lemma 1 8 i2 c1; assert (v ti2 + vc1 == vc2 * pow2 26 + v t2); carry26_eval_lemma 1 8 i3 c2; assert (v ti3 + vc2 == vc3 * pow2 26 + v t3); carry26_eval_lemma 1 8 i4 c3; assert (v ti4 + vc3 == vc4 * pow2 26 + v t4); carry_full_felem5_eval_lemma_i0 (ti0, ti1, ti2, ti3, ti4) (t0, t1, t2, t3, t4) vc0 vc1 vc2 vc3 vc4; assert ((feval5 inp).[ i ] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem_wide5", "Hacl.Spec.Poly1305.Field32xN.felem_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Lib.IntTypes.uint64", "Prims._assert", "Prims.eq2", "Prims.int", "Lib.Sequence.op_String_Access", "Hacl.Spec.Poly1305.Vec.pfelem", "Hacl.Spec.Poly1305.Field32xN.feval5", "Prims.op_Modulus", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Field32xN.pow26", "Hacl.Spec.Poly1305.Field32xN.pow52", "Hacl.Spec.Poly1305.Field32xN.pow78", "Hacl.Spec.Poly1305.Field32xN.pow104", "Hacl.Spec.Poly1305.Vec.prime", "Prims.unit", "Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_eval_lemma_i0", "Prims.pow2", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_eval_lemma", "Hacl.Spec.Poly1305.Field32xN.zero", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Hacl.Spec.Poly1305.Field32xN.uint64xN_v", "Hacl.Spec.Poly1305.Field32xN.tup64_5", "Hacl.Spec.Poly1305.Field32xN.as_tup64_i", "FStar.Pervasives.Native.tuple5", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Poly1305.Field32xN.carry26" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26) val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4)) let acc_inv_lemma #w acc cin = match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3 val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9) let carry_full_felem5_fits_lemma0 #w (f0, f1, f2, f3, f4) = let tmp0,c0 = carry26 f0 (zero w) in carry26_fits_lemma 1 8 f0 (zero w); let tmp1,c1 = carry26 f1 c0 in carry26_fits_lemma 1 8 f1 c0; let tmp2,c2 = carry26 f2 c1 in carry26_fits_lemma 1 8 f2 c1; let tmp3,c3 = carry26 f3 c2 in carry26_fits_lemma 1 8 f3 c2; let tmp4,c4 = carry26 f4 c3 in carry26_fits_lemma 1 8 f4 c3; assert (felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1)); assert (uint64xN_fits c4 9) val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (acc_inv_t (carry_full_felem5 f)) let carry_full_felem5_fits_lemma #w f = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_full_felem5_fits_lemma0 #w f; assert (felem_fits1 tmp0 1 /\ uint64xN_fits c4 9); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in acc_inv_lemma (tmp0, tmp1, tmp2, tmp3, tmp4) (vec_smul_mod c4 (u64 5)) val carry_full_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in v ti0 == vc0 * pow2 26 + v t0 /\ v ti1 + vc0 == vc1 * pow2 26 + v t1 /\ v ti2 + vc1 == vc2 * pow2 26 + v t2 /\ v ti3 + vc2 == vc3 * pow2 26 + v t3 /\ v ti4 + vc3 == vc4 * pow2 26 + v t4)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_full_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 = let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v ti0 + v ti1 * pow26 + v ti2 * pow52 + v ti3 * pow78 + v ti4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_full_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_full_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_eval_lemma_i1
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
inp: Hacl.Spec.Poly1305.Field32xN.felem_wide5 w {Hacl.Spec.Poly1305.Field32xN.felem_fits5 inp (8, 8, 8, 8, 8)} -> i: Prims.nat{i < w} -> FStar.Pervasives.Lemma (ensures (let _ = inp in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ i0 i1 i2 i3 i4 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 i0 (Hacl.Spec.Poly1305.Field32xN.zero w) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp0 c0 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 i1 c0 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp1 c1 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 i2 c1 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp2 c2 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 i3 c2 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp3 c3 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 i4 c3 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp4 c4 = _ in let tmp = tmp0, tmp1, tmp2, tmp3, tmp4 in let _ = Hacl.Spec.Poly1305.Field32xN.as_tup64_i tmp i in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ t0 t1 t2 t3 t4 = _ in let vc4 = (Hacl.Spec.Poly1305.Field32xN.uint64xN_v c4).[ i ] in (Hacl.Spec.Poly1305.Field32xN.feval5 inp).[ i ] == (Lib.IntTypes.v t0 + vc4 * 5 + Lib.IntTypes.v t1 * Hacl.Spec.Poly1305.Field32xN.pow26 + Lib.IntTypes.v t2 * Hacl.Spec.Poly1305.Field32xN.pow52 + Lib.IntTypes.v t3 * Hacl.Spec.Poly1305.Field32xN.pow78 + Lib.IntTypes.v t4 * Hacl.Spec.Poly1305.Field32xN.pow104) % Hacl.Spec.Poly1305.Vec.prime) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0))
{ "end_col": 89, "end_line": 822, "start_col": 46, "start_line": 792 }
FStar.Pervasives.Lemma
val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0])
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3
val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f =
false
null
true
match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Spec.Poly1305.Field32xN.felem_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Hacl.Poly1305.Field32xN.Lemmas1.subtract_p5_felem5_lemma_i", "Prims.unit" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0])
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0])
[]
Hacl.Poly1305.Field32xN.Lemmas1.subtract_p5_felem5_lemma
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.felem5 w {Hacl.Spec.Poly1305.Field32xN.felem_fits5 f (1, 1, 1, 1, 1)} -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Poly1305.Field32xN.felem_fits5 (Hacl.Spec.Poly1305.Field32xN.subtract_p5 f) (1, 1, 1, 1, 1) /\ (Hacl.Spec.Poly1305.Field32xN.fas_nat5 (Hacl.Spec.Poly1305.Field32xN.subtract_p5 f)).[ 0 ] == (Hacl.Spec.Poly1305.Field32xN.feval5 f).[ 0 ])
{ "end_col": 37, "end_line": 629, "start_col": 2, "start_line": 619 }
FStar.Pervasives.Lemma
val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26
val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i =
false
null
true
let l = (vec_v l).[ i ] in let cin = (vec_v cin).[ i ] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.scale64", "Hacl.Spec.Poly1305.Field32xN.scale32", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Hacl.Spec.Poly1305.Field32xN.felem_fits1", "Hacl.Spec.Poly1305.Field32xN.uint64xN_fits", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Field32xN.max26", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Math.Lemmas.pow2_minus", "Prims.unit", "FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims._assert", "Prims.eq2", "Lib.IntTypes.range_t", "Lib.IntTypes.mod_mask", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.mod_mask_lemma", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Greater_Greater_Dot", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.op_Plus_Bang", "FStar.Math.Lemmas.modulo_lemma", "Prims.op_Addition", "Prims.pow2", "FStar.Pervasives.assert_norm", "Prims.op_Equality", "Prims.int", "Prims.op_Subtraction", "Lib.IntTypes.range", "Lib.IntTypes.u64", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.IntVector.vec_v", "Lib.Sequence.op_String_Access", "Lib.IntTypes.uint_t" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry26_lemma_i
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Hacl.Spec.Poly1305.Field32xN.scale64 -> ml: Hacl.Spec.Poly1305.Field32xN.scale32 -> l: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.felem_fits1 l ml} -> cin: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.uint64xN_fits cin (m * Hacl.Spec.Poly1305.Field32xN.max26)} -> i: Prims.nat{i < w} -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.Poly1305.Field32xN.carry26 l cin in (let FStar.Pervasives.Native.Mktuple2 #_ #_ l0 l1 = _ in (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l0).[ i ] <= Hacl.Spec.Poly1305.Field32xN.max26 /\ (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l1).[ i ] < m + ml /\ (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l).[ i ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v cin).[ i ] == (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l1).[ i ] * Prims.pow2 26 + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l0).[ i ]) <: Type0))
{ "end_col": 36, "end_line": 186, "start_col": 37, "start_line": 174 }
FStar.Pervasives.Lemma
val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3
val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin =
false
null
true
match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.scale64", "Hacl.Spec.Poly1305.Field32xN.scale32", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Hacl.Spec.Poly1305.Field32xN.felem_fits1", "Hacl.Spec.Poly1305.Field32xN.uint64xN_fits", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Field32xN.max26", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_lemma_i", "Prims.unit" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml))
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml))
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry26_fits_lemma
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Hacl.Spec.Poly1305.Field32xN.scale64 -> ml: Hacl.Spec.Poly1305.Field32xN.scale32 -> l: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.felem_fits1 l ml} -> cin: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.uint64xN_fits cin (m * Hacl.Spec.Poly1305.Field32xN.max26)} -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.Poly1305.Field32xN.carry26 l cin in (let FStar.Pervasives.Native.Mktuple2 #_ #_ l0 l1 = _ in Hacl.Spec.Poly1305.Field32xN.felem_fits1 l0 1 /\ Hacl.Spec.Poly1305.Field32xN.uint64xN_fits l1 (m + ml)) <: Type0))
{ "end_col": 35, "end_line": 210, "start_col": 2, "start_line": 200 }
FStar.Pervasives.Lemma
val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3
val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin =
false
null
true
match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.scale64", "Hacl.Spec.Poly1305.Field32xN.scale32", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Hacl.Spec.Poly1305.Field32xN.felem_fits1", "Hacl.Spec.Poly1305.Field32xN.uint64xN_fits", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Field32xN.max26", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_lemma_i", "Prims.unit" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]))
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]))
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry26_eval_lemma
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Hacl.Spec.Poly1305.Field32xN.scale64 -> ml: Hacl.Spec.Poly1305.Field32xN.scale32 -> l: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.felem_fits1 l ml} -> cin: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.uint64xN_fits cin (m * Hacl.Spec.Poly1305.Field32xN.max26)} -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.Poly1305.Field32xN.carry26 l cin in (let FStar.Pervasives.Native.Mktuple2 #_ #_ l0 l1 = _ in Hacl.Spec.Poly1305.Field32xN.felem_fits1 l0 1 /\ Hacl.Spec.Poly1305.Field32xN.uint64xN_fits l1 (m + ml) /\ (forall (i: Prims.nat). i < w ==> (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l).[ i ] + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v cin).[ i ] == (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l1).[ i ] * Prims.pow2 26 + (Hacl.Spec.Poly1305.Field32xN.uint64xN_v l0).[ i ])) <: Type0))
{ "end_col": 35, "end_line": 236, "start_col": 2, "start_line": 226 }
FStar.Pervasives.Lemma
val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime)
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime
val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' =
false
null
true
let f0, f1, f2, f3, f4 = f in let f0', f1', f2', f3', f4' = f' in assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc ( == ) { as_nat5 f' % prime; ( == ) { () } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; ( == ) { () } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; ( == ) { (assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; ( == ) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; ( == ) { () } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.tup64_5", "Hacl.Spec.Poly1305.Field32xN.tup64_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Lib.IntTypes.uint64", "FStar.Math.Lemmas.modulo_lemma", "Hacl.Spec.Poly1305.Field32xN.as_nat5", "Hacl.Spec.Poly1305.Vec.prime", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Calc.calc_finish", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Field32xN.pow26", "Hacl.Spec.Poly1305.Field32xN.pow52", "Hacl.Spec.Poly1305.Field32xN.pow78", "Hacl.Spec.Poly1305.Field32xN.pow104", "Prims.op_Subtraction", "Prims.pow2", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "FStar.Math.Lemmas.lemma_mod_sub", "Prims.op_LessThan" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime)
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime)
[]
Hacl.Poly1305.Field32xN.Lemmas1.lemma_subtract_p5_1
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.tup64_5 {Hacl.Spec.Poly1305.Field32xN.tup64_fits5 f (1, 1, 1, 1, 1)} -> f': Hacl.Spec.Poly1305.Field32xN.tup64_5 -> FStar.Pervasives.Lemma (requires (let _ = f in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ f0 f1 f2 f3 f4 = _ in let _ = f' in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ f0' f1' f2' f3' f4' = _ in Lib.IntTypes.v f4 = 0x3ffffff && Lib.IntTypes.v f3 = 0x3ffffff && Lib.IntTypes.v f2 = 0x3ffffff && Lib.IntTypes.v f1 = 0x3ffffff && Lib.IntTypes.v f0 >= 0x3fffffb /\ Lib.IntTypes.v f0' = Lib.IntTypes.v f0 - 0x3fffffb && Lib.IntTypes.v f1' = Lib.IntTypes.v f1 - 0x3ffffff && Lib.IntTypes.v f2' = Lib.IntTypes.v f2 - 0x3ffffff && Lib.IntTypes.v f3' = Lib.IntTypes.v f3 - 0x3ffffff && Lib.IntTypes.v f4' = Lib.IntTypes.v f4 - 0x3ffffff) <: Type0) <: Type0)) (ensures Hacl.Spec.Poly1305.Field32xN.as_nat5 f' == Hacl.Spec.Poly1305.Field32xN.as_nat5 f % Hacl.Spec.Poly1305.Vec.prime)
{ "end_col": 51, "end_line": 535, "start_col": 30, "start_line": 509 }
FStar.Pervasives.Lemma
val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3
val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) let carry26_wide_fits_lemma #w #m l cin =
false
null
true
match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.scale64", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Hacl.Spec.Poly1305.Field32xN.felem_wide_fits1", "Hacl.Spec.Poly1305.Field32xN.uint64xN_fits", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Field32xN.max26", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_lemma_i", "Prims.unit" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100"
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26))
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_fits_lemma
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
l: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.felem_wide_fits1 l m} -> cin: Hacl.Spec.Poly1305.Field32xN.uint64xN w {Hacl.Spec.Poly1305.Field32xN.uint64xN_fits cin (4096 * Hacl.Spec.Poly1305.Field32xN.max26)} -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.Poly1305.Field32xN.carry26 l cin in (let FStar.Pervasives.Native.Mktuple2 #_ #_ l0 l1 = _ in Hacl.Spec.Poly1305.Field32xN.felem_fits1 l0 1 /\ Hacl.Spec.Poly1305.Field32xN.uint64xN_fits l1 ((m + 1) * Hacl.Spec.Poly1305.Field32xN.max26)) <: Type0))
{ "end_col": 38, "end_line": 133, "start_col": 2, "start_line": 123 }
FStar.Pervasives.Lemma
val carry_reduce_felem5_fits_lemma_i: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (carry_full_felem5 f) i) (1, 1, 1, 1, 1))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_reduce_felem5_fits_lemma_i #w f i = assert_norm (max26 == pow2 26 - 1); let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_reduce_felem5_fits_lemma_i1 #w f i; FStar.Math.Lemmas.modulo_lemma ((uint64xN_v c4).[i] * 5) (pow2 64); assert ((uint64xN_v (vec_smul_mod c4 (u64 5))).[i] == (uint64xN_v c4).[i] * 5); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in carry_reduce_felem5_fits_lemma_i0 #w f i; let res = (tmp0', tmp1, tmp2, tmp3, tmp4) in assert (tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1))
val carry_reduce_felem5_fits_lemma_i: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (carry_full_felem5 f) i) (1, 1, 1, 1, 1)) let carry_reduce_felem5_fits_lemma_i #w f i =
false
null
true
assert_norm (max26 == pow2 26 - 1); let f0, f1, f2, f3, f4 = f in let tmp0, c0 = carry26 f0 (zero w) in let tmp1, c1 = carry26 f1 c0 in let tmp2, c2 = carry26 f2 c1 in let tmp3, c3 = carry26 f3 c2 in let tmp4, c4 = carry26 f4 c3 in carry_reduce_felem5_fits_lemma_i1 #w f i; FStar.Math.Lemmas.modulo_lemma ((uint64xN_v c4).[ i ] * 5) (pow2 64); assert ((uint64xN_v (vec_smul_mod c4 (u64 5))).[ i ] == (uint64xN_v c4).[ i ] * 5); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in carry_reduce_felem5_fits_lemma_i0 #w f i; let res = (tmp0', tmp1, tmp2, tmp3, tmp4) in assert (tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1))
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_t", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Prims._assert", "Hacl.Spec.Poly1305.Field32xN.tup64_fits5", "Hacl.Spec.Poly1305.Field32xN.as_tup64_i", "FStar.Pervasives.Native.Mktuple5", "FStar.Pervasives.Native.tuple5", "Prims.unit", "Hacl.Poly1305.Field32xN.Lemmas1.carry_reduce_felem5_fits_lemma_i0", "Lib.IntVector.vec_t", "Lib.IntTypes.U64", "Lib.IntVector.vec_add_mod", "Lib.IntVector.vec_smul_mod", "Lib.IntTypes.u64", "Prims.eq2", "Prims.int", "Lib.Sequence.op_String_Access", "Hacl.Spec.Poly1305.Field32xN.uint64xN_v", "FStar.Mul.op_Star", "FStar.Math.Lemmas.modulo_lemma", "Prims.pow2", "Hacl.Poly1305.Field32xN.Lemmas1.carry_reduce_felem5_fits_lemma_i1", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Poly1305.Field32xN.carry26", "Hacl.Spec.Poly1305.Field32xN.zero", "FStar.Pervasives.assert_norm", "Hacl.Spec.Poly1305.Field32xN.max26", "Prims.op_Subtraction" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26) val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4)) let acc_inv_lemma #w acc cin = match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3 val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9) let carry_full_felem5_fits_lemma0 #w (f0, f1, f2, f3, f4) = let tmp0,c0 = carry26 f0 (zero w) in carry26_fits_lemma 1 8 f0 (zero w); let tmp1,c1 = carry26 f1 c0 in carry26_fits_lemma 1 8 f1 c0; let tmp2,c2 = carry26 f2 c1 in carry26_fits_lemma 1 8 f2 c1; let tmp3,c3 = carry26 f3 c2 in carry26_fits_lemma 1 8 f3 c2; let tmp4,c4 = carry26 f4 c3 in carry26_fits_lemma 1 8 f4 c3; assert (felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1)); assert (uint64xN_fits c4 9) val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (acc_inv_t (carry_full_felem5 f)) let carry_full_felem5_fits_lemma #w f = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_full_felem5_fits_lemma0 #w f; assert (felem_fits1 tmp0 1 /\ uint64xN_fits c4 9); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in acc_inv_lemma (tmp0, tmp1, tmp2, tmp3, tmp4) (vec_smul_mod c4 (u64 5)) val carry_full_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in v ti0 == vc0 * pow2 26 + v t0 /\ v ti1 + vc0 == vc1 * pow2 26 + v t1 /\ v ti2 + vc1 == vc2 * pow2 26 + v t2 /\ v ti3 + vc2 == vc3 * pow2 26 + v t3 /\ v ti4 + vc3 == vc4 * pow2 26 + v t4)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_full_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 = let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v ti0 + v ti1 * pow26 + v ti2 * pow52 + v ti3 * pow78 + v ti4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_full_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_full_felem5_eval_lemma_i1 #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in carry26_eval_lemma 1 8 i0 (zero w); assert (v ti0 == vc0 * pow2 26 + v t0); carry26_eval_lemma 1 8 i1 c0; assert (v ti1 + vc0 == vc1 * pow2 26 + v t1); carry26_eval_lemma 1 8 i2 c1; assert (v ti2 + vc1 == vc2 * pow2 26 + v t2); carry26_eval_lemma 1 8 i3 c2; assert (v ti3 + vc2 == vc3 * pow2 26 + v t3); carry26_eval_lemma 1 8 i4 c3; assert (v ti4 + vc3 == vc4 * pow2 26 + v t4); carry_full_felem5_eval_lemma_i0 (ti0, ti1, ti2, ti3, ti4) (t0, t1, t2, t3, t4) vc0 vc1 vc2 vc3 vc4; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) val carry_full_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma ((feval5 (carry_full_felem5 #w inp)).[i] == (feval5 inp).[i]) let carry_full_felem5_eval_lemma_i #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc4 = (uint64xN_v c4).[i] in carry_full_felem5_fits_lemma0 #w inp; let cin = vec_smul_mod c4 (u64 5) in assert ((uint64xN_v cin).[i] == vc4 * 5); let tmp0' = vec_add_mod tmp0 cin in Math.Lemmas.small_mod ((uint64xN_v tmp0).[i] + vc4 * 5) (pow2 64); assert ((uint64xN_v tmp0').[i] == (uint64xN_v tmp0).[i] + vc4 * 5); let out = (tmp0', tmp1, tmp2, tmp3, tmp4) in let (o0, o1, o2, o3, o4) = as_tup64_i out i in assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_full_felem5_eval_lemma_i1 #w inp i; assert ((feval5 out).[i] == (feval5 inp).[i]) val carry_full_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_fits5 inp (8, 8, 8, 8, 8)) (ensures feval5 (carry_full_felem5 #w inp) == feval5 inp) let carry_full_felem5_eval_lemma #w inp = let o = carry_full_felem5 #w inp in FStar.Classical.forall_intro (carry_full_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val carry_full_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (felem_fits5 (carry_full_felem5 f) (2, 1, 1, 1, 1) /\ feval5 (carry_full_felem5 f) == feval5 f) let carry_full_felem5_lemma #w f = carry_full_felem5_eval_lemma f; carry_full_felem5_fits_lemma f val carry_reduce_lemma_i: #w:lanes -> l:uint64xN w -> cin:uint64xN w -> i:nat{i < w} -> Lemma (requires (uint64xN_v l).[i] <= 2 * max26 /\ (uint64xN_v cin).[i] <= 62 * max26) (ensures (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= 63 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry_reduce_lemma_i #w l cin i = let li = (vec_v l).[i] in let cini = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v li + v cini) (pow2 64); let li' = li +! cini in let li0 = li' &. mask26 in let li1 = li' >>. 26ul in mod_mask_lemma li' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v li') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 #push-options "--z3rlimit 600" val carry_reduce_felem5_fits_lemma_i0: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v tmp0).[i] < pow2 26 else (uint64xN_v tmp0).[i] <= 46) /\ (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63)) let carry_reduce_felem5_fits_lemma_i0 #w f i = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in carry_reduce_lemma_i f0 (zero w) i; assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v tmp0).[i] < pow2 26 else (uint64xN_v tmp0).[i] <= 46); assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c0).[i] = 0 else (uint64xN_v c0).[i] <= 63); let tmp1,c1 = carry26 f1 c0 in carry_reduce_lemma_i f1 c0 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c1).[i] = 0 else (uint64xN_v c1).[i] <= 63); let tmp2,c2 = carry26 f2 c1 in carry_reduce_lemma_i f2 c1 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c2).[i] = 0 else (uint64xN_v c2).[i] <= 63); let tmp3,c3 = carry26 f3 c2 in carry_reduce_lemma_i f3 c2 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c3).[i] = 0 else (uint64xN_v c3).[i] <= 63); let tmp4,c4 = carry26 f4 c3 in carry_reduce_lemma_i f4 c3 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63); assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c0).[i] = 0 /\ (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63) val carry_reduce_felem5_fits_lemma_i1: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (uint64xN_v c4).[i] <= 63 /\ tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1)) let carry_reduce_felem5_fits_lemma_i1 #w f i = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in carry_reduce_lemma_i f0 (zero w) i; let tmp1,c1 = carry26 f1 c0 in carry_reduce_lemma_i f1 c0 i; let tmp2,c2 = carry26 f2 c1 in carry_reduce_lemma_i f2 c1 i; let tmp3,c3 = carry26 f3 c2 in carry_reduce_lemma_i f3 c2 i; let tmp4,c4 = carry26 f4 c3 in carry_reduce_lemma_i f4 c3 i; let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in assert (tup64_fits5 (as_tup64_i res i) (1, 1, 1, 1, 1)) val carry_reduce_felem5_fits_lemma_i: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (carry_full_felem5 f) i) (1, 1, 1, 1, 1))
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 600, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_reduce_felem5_fits_lemma_i: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (carry_full_felem5 f) i) (1, 1, 1, 1, 1))
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_reduce_felem5_fits_lemma_i
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.felem5 w {Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_t f} -> i: Prims.nat{i < w} -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Poly1305.Field32xN.tup64_fits5 (Hacl.Spec.Poly1305.Field32xN.as_tup64_i (Hacl.Spec.Poly1305.Field32xN.carry_full_felem5 f) i) (1, 1, 1, 1, 1))
{ "end_col": 57, "end_line": 1001, "start_col": 2, "start_line": 987 }
FStar.Pervasives.Lemma
val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i])
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4
val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) let carry_wide_felem5_eval_lemma_i #w inp i =
false
null
true
let x0, x1, x2, x3, x4 = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[ i ] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[ i ] + (uint64xN_v c4).[ i ] * 5 == (uint64xN_v c5).[ i ] * pow2 26 + (uint64xN_v tmp0').[ i ]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[ i ] + (uint64xN_v c5).[ i ]) (pow2 64); assert ((uint64xN_v tmp1').[ i ] == (uint64xN_v tmp1).[ i ] + (uint64xN_v c5).[ i ]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let o0, o1, o2, o3, o4 = as_tup64_i out i in let t0, t1, t2, t3, t4 = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[ i ] in let vc5 = (uint64xN_v c5).[ i ] in calc ( == ) { (feval5 out).[ i ]; ( == ) { () } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; ( == ) { () } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 ) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[ i ] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[ i ] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[ i ] == (feval5 inp).[ i ]); vec_smul_mod_five c4
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem_wide5", "Hacl.Spec.Poly1305.Field32xN.felem_wide_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Lib.IntTypes.uint64", "Hacl.Poly1305.Field32xN.Lemmas1.vec_smul_mod_five", "Prims.unit", "Prims._assert", "Prims.eq2", "Hacl.Spec.Poly1305.Vec.pfelem", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Hacl.Spec.Poly1305.Field32xN.feval5", "Lib.Sequence.op_String_Access", "Prims.int", "Prims.op_Modulus", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Field32xN.pow26", "Hacl.Spec.Poly1305.Field32xN.pow52", "Hacl.Spec.Poly1305.Field32xN.pow78", "Hacl.Spec.Poly1305.Field32xN.pow104", "Hacl.Spec.Poly1305.Vec.prime", "Hacl.Poly1305.Field32xN.Lemmas1.carry_wide_felem5_eval_lemma_i1", "FStar.Math.Lemmas.distributivity_add_left", "FStar.Calc.calc_finish", "Prims.op_Subtraction", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Hacl.Spec.Poly1305.Field32xN.uint64xN_v", "Hacl.Spec.Poly1305.Field32xN.tup64_5", "Hacl.Spec.Poly1305.Field32xN.as_tup64_i", "FStar.Pervasives.Native.tuple5", "FStar.Math.Lemmas.small_mod", "Prims.pow2", "Lib.IntVector.vec_t", "Lib.IntVector.vec_add_mod", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_eval_lemma", "Lib.IntVector.vec_smul_mod", "Lib.IntTypes.u64", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Poly1305.Field32xN.carry26", "Hacl.Poly1305.Field32xN.Lemmas1.carry_wide_felem5_fits_lemma0", "Hacl.Spec.Poly1305.Field32xN.carry26_wide", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_zero" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i])
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i])
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_wide_felem5_eval_lemma_i
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
inp: Hacl.Spec.Poly1305.Field32xN.felem_wide5 w {Hacl.Spec.Poly1305.Field32xN.felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i: Prims.nat{i < w} -> FStar.Pervasives.Lemma (ensures (Hacl.Spec.Poly1305.Field32xN.feval5 (Hacl.Spec.Poly1305.Field32xN.carry_wide_felem5 inp)).[ i ] == (Hacl.Spec.Poly1305.Field32xN.feval5 inp).[ i ])
{ "end_col": 22, "end_line": 456, "start_col": 45, "start_line": 418 }
FStar.Pervasives.Lemma
val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime)
val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i =
false
null
true
let x0, x1, x2, x3, x4 = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let t0, t1, t2, t3, t4 = as_tup64_i tmp i in let t0, t1, t2, t3', t4' = as_tup64_i tmp' i in let xi0, xi1, xi2, xi3, xi4 = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[ i ] in let vc1 = (uint64xN_v c1).[ i ] in let vc2 = (uint64xN_v c2).[ i ] in let vc3 = (uint64xN_v c3).[ i ] in let vc4 = (uint64xN_v c4).[ i ] in let vc6 = (uint64xN_v c6).[ i ] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[ i ] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime)
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem_wide5", "Hacl.Spec.Poly1305.Field32xN.felem_wide_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Lib.IntTypes.uint64", "Prims._assert", "Prims.eq2", "Prims.int", "Lib.Sequence.op_String_Access", "Hacl.Spec.Poly1305.Vec.pfelem", "Hacl.Spec.Poly1305.Field32xN.feval5", "Prims.op_Modulus", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Field32xN.pow26", "Hacl.Spec.Poly1305.Field32xN.pow52", "Hacl.Spec.Poly1305.Field32xN.pow78", "Hacl.Spec.Poly1305.Field32xN.pow104", "Hacl.Spec.Poly1305.Vec.prime", "Prims.unit", "Hacl.Poly1305.Field32xN.Lemmas1.carry_wide_felem5_eval_lemma_i0", "FStar.Math.Lemmas.small_mod", "Prims.pow2", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_fits_lemma", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_eval_lemma", "Hacl.Spec.Poly1305.Field32xN.zero", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_zero_eq", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Hacl.Spec.Poly1305.Field32xN.uint64xN_v", "Hacl.Spec.Poly1305.Field32xN.tup64_5", "Hacl.Spec.Poly1305.Field32xN.as_tup64_i", "FStar.Pervasives.Native.tuple5", "Lib.IntVector.vec_t", "Lib.IntVector.vec_add_mod", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Poly1305.Field32xN.carry26_wide", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_fits_lemma", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_eval_lemma", "Hacl.Spec.Poly1305.Field32xN.carry26", "Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_zero" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_wide_felem5_eval_lemma_i1
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
inp: Hacl.Spec.Poly1305.Field32xN.felem_wide5 w {Hacl.Spec.Poly1305.Field32xN.felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i: Prims.nat{i < w} -> FStar.Pervasives.Lemma (ensures (let _ = inp in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ x0 x1 x2 x3 x4 = _ in let _ = Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_zero x0 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ t0 c0 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26_wide x1 c0 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ t1 c1 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26_wide x2 c1 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ t2 c2 = _ in let _ = Hacl.Poly1305.Field32xN.Lemmas1.carry26_wide_zero x3 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ t3 c3 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 t3 c2 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ t3' c6 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26_wide x4 c3 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ t4 c4 = _ in let t4' = Lib.IntVector.vec_add_mod t4 c6 in let tmp = t0, t1, t2, t3', t4' in let _ = Hacl.Spec.Poly1305.Field32xN.as_tup64_i tmp i in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ t0 t1 t2 t3 t4 = _ in let vc4 = (Hacl.Spec.Poly1305.Field32xN.uint64xN_v c4).[ i ] in (Hacl.Spec.Poly1305.Field32xN.feval5 inp).[ i ] == (Lib.IntTypes.v t0 + vc4 * 5 + Lib.IntTypes.v t1 * Hacl.Spec.Poly1305.Field32xN.pow26 + Lib.IntTypes.v t2 * Hacl.Spec.Poly1305.Field32xN.pow52 + Lib.IntTypes.v t3 * Hacl.Spec.Poly1305.Field32xN.pow78 + Lib.IntTypes.v t4 * Hacl.Spec.Poly1305.Field32xN.pow104) % Hacl.Spec.Poly1305.Vec.prime) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0))
{ "end_col": 118, "end_line": 408, "start_col": 46, "start_line": 363 }
FStar.Pervasives.Lemma
val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime)
val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 =
false
null
true
let t0, t1, t2, t3, t4 = tmp in let xi0, xi1, xi2, xi3, xi4 = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc ( == ) { as_nat5 inp % prime; ( == ) { () } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; ( == ) { () } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; ( == ) { (assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)) } (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; ( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; ( == ) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; ( == ) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; ( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime)
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.tup64_5", "Prims.nat", "Lib.IntTypes.uint64", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Hacl.Spec.Poly1305.Field32xN.as_nat5", "Hacl.Spec.Poly1305.Vec.prime", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.unit", "FStar.Calc.calc_finish", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Prims.pow2", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.Spec.Poly1305.Field32xN.pow26", "Hacl.Spec.Poly1305.Field32xN.pow52", "Hacl.Spec.Poly1305.Field32xN.pow78", "Hacl.Spec.Poly1305.Field32xN.pow104", "Prims.op_Subtraction", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "FStar.Math.Lemmas.lemma_mod_plus_distr_r", "FStar.Math.Lemmas.lemma_mod_mul_distr_r", "Hacl.Poly1305.Field32xN.Lemmas1.lemma_prime" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime))
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime))
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_wide_felem5_eval_lemma_i0
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
inp: Hacl.Spec.Poly1305.Field32xN.tup64_5 -> tmp: Hacl.Spec.Poly1305.Field32xN.tup64_5 -> vc0: Prims.nat -> vc1: Prims.nat -> vc2: Prims.nat -> vc3: Prims.nat -> vc4: Prims.nat -> vc6: Prims.nat -> FStar.Pervasives.Lemma (requires (let _ = tmp in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ t0 t1 t2 t3 t4 = _ in let _ = inp in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ xi0 xi1 xi2 xi3 xi4 = _ in Lib.IntTypes.v xi0 == vc0 * Prims.pow2 26 + Lib.IntTypes.v t0 /\ Lib.IntTypes.v xi1 + vc0 == vc1 * Prims.pow2 26 + Lib.IntTypes.v t1 /\ Lib.IntTypes.v xi2 + vc1 == vc2 * Prims.pow2 26 + Lib.IntTypes.v t2 /\ Lib.IntTypes.v xi3 + vc2 == vc3 * Prims.pow2 26 + vc6 * Prims.pow2 26 + Lib.IntTypes.v t3 /\ Lib.IntTypes.v xi4 + vc3 == vc4 * Prims.pow2 26 + Lib.IntTypes.v t4 - vc6) <: Type0) <: Type0)) (ensures (let _ = tmp in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ t0 t1 t2 t3 t4 = _ in let _ = inp in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ _ = _ in Hacl.Spec.Poly1305.Field32xN.as_nat5 inp % Hacl.Spec.Poly1305.Vec.prime == (Lib.IntTypes.v t0 + vc4 * 5 + Lib.IntTypes.v t1 * Hacl.Spec.Poly1305.Field32xN.pow26 + Lib.IntTypes.v t2 * Hacl.Spec.Poly1305.Field32xN.pow52 + Lib.IntTypes.v t3 * Hacl.Spec.Poly1305.Field32xN.pow78 + Lib.IntTypes.v t4 * Hacl.Spec.Poly1305.Field32xN.pow104) % Hacl.Spec.Poly1305.Vec.prime) <: Type0) <: Type0))
{ "end_col": 59, "end_line": 343, "start_col": 69, "start_line": 313 }
FStar.Pervasives.Lemma
val carry_full_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in v ti0 == vc0 * pow2 26 + v t0 /\ v ti1 + vc0 == vc1 * pow2 26 + v t1 /\ v ti2 + vc1 == vc2 * pow2 26 + v t2 /\ v ti3 + vc2 == vc3 * pow2 26 + v t3 /\ v ti4 + vc3 == vc4 * pow2 26 + v t4)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_full_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 = let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v ti0 + v ti1 * pow26 + v ti2 * pow52 + v ti3 * pow78 + v ti4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime)
val carry_full_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in v ti0 == vc0 * pow2 26 + v t0 /\ v ti1 + vc0 == vc1 * pow2 26 + v t1 /\ v ti2 + vc1 == vc2 * pow2 26 + v t2 /\ v ti3 + vc2 == vc3 * pow2 26 + v t3 /\ v ti4 + vc3 == vc4 * pow2 26 + v t4)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_full_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 =
false
null
true
let t0, t1, t2, t3, t4 = tmp in let ti0, ti1, ti2, ti3, ti4 = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc ( == ) { as_nat5 inp % prime; ( == ) { () } (v ti0 + v ti1 * pow26 + v ti2 * pow52 + v ti3 * pow78 + v ti4 * pow104) % prime; ( == ) { () } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc3) * pow104) % prime; ( == ) { (assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)) } (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; ( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; ( == ) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; ( == ) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; ( == ) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime)
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.tup64_5", "Prims.nat", "Lib.IntTypes.uint64", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Hacl.Spec.Poly1305.Field32xN.as_nat5", "Hacl.Spec.Poly1305.Vec.prime", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.unit", "FStar.Calc.calc_finish", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Prims.pow2", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Hacl.Spec.Poly1305.Field32xN.pow26", "Hacl.Spec.Poly1305.Field32xN.pow52", "Hacl.Spec.Poly1305.Field32xN.pow78", "Hacl.Spec.Poly1305.Field32xN.pow104", "Prims.op_Subtraction", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "FStar.Math.Lemmas.lemma_mod_plus_distr_r", "FStar.Math.Lemmas.lemma_mod_mul_distr_r", "Hacl.Poly1305.Field32xN.Lemmas1.lemma_prime" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26) val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4)) let acc_inv_lemma #w acc cin = match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3 val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9) let carry_full_felem5_fits_lemma0 #w (f0, f1, f2, f3, f4) = let tmp0,c0 = carry26 f0 (zero w) in carry26_fits_lemma 1 8 f0 (zero w); let tmp1,c1 = carry26 f1 c0 in carry26_fits_lemma 1 8 f1 c0; let tmp2,c2 = carry26 f2 c1 in carry26_fits_lemma 1 8 f2 c1; let tmp3,c3 = carry26 f3 c2 in carry26_fits_lemma 1 8 f3 c2; let tmp4,c4 = carry26 f4 c3 in carry26_fits_lemma 1 8 f4 c3; assert (felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1)); assert (uint64xN_fits c4 9) val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (acc_inv_t (carry_full_felem5 f)) let carry_full_felem5_fits_lemma #w f = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_full_felem5_fits_lemma0 #w f; assert (felem_fits1 tmp0 1 /\ uint64xN_fits c4 9); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in acc_inv_lemma (tmp0, tmp1, tmp2, tmp3, tmp4) (vec_smul_mod c4 (u64 5)) val carry_full_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in v ti0 == vc0 * pow2 26 + v t0 /\ v ti1 + vc0 == vc1 * pow2 26 + v t1 /\ v ti2 + vc1 == vc2 * pow2 26 + v t2 /\ v ti3 + vc2 == vc3 * pow2 26 + v t3 /\ v ti4 + vc3 == vc4 * pow2 26 + v t4)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime))
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_full_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in v ti0 == vc0 * pow2 26 + v t0 /\ v ti1 + vc0 == vc1 * pow2 26 + v t1 /\ v ti2 + vc1 == vc2 * pow2 26 + v t2 /\ v ti3 + vc2 == vc3 * pow2 26 + v t3 /\ v ti4 + vc3 == vc4 * pow2 26 + v t4)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime))
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_eval_lemma_i0
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
inp: Hacl.Spec.Poly1305.Field32xN.tup64_5 -> tmp: Hacl.Spec.Poly1305.Field32xN.tup64_5 -> vc0: Prims.nat -> vc1: Prims.nat -> vc2: Prims.nat -> vc3: Prims.nat -> vc4: Prims.nat -> FStar.Pervasives.Lemma (requires (let _ = tmp in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ t0 t1 t2 t3 t4 = _ in let _ = inp in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ ti0 ti1 ti2 ti3 ti4 = _ in Lib.IntTypes.v ti0 == vc0 * Prims.pow2 26 + Lib.IntTypes.v t0 /\ Lib.IntTypes.v ti1 + vc0 == vc1 * Prims.pow2 26 + Lib.IntTypes.v t1 /\ Lib.IntTypes.v ti2 + vc1 == vc2 * Prims.pow2 26 + Lib.IntTypes.v t2 /\ Lib.IntTypes.v ti3 + vc2 == vc3 * Prims.pow2 26 + Lib.IntTypes.v t3 /\ Lib.IntTypes.v ti4 + vc3 == vc4 * Prims.pow2 26 + Lib.IntTypes.v t4) <: Type0) <: Type0)) (ensures (let _ = tmp in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ t0 t1 t2 t3 t4 = _ in let _ = inp in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ _ = _ in Hacl.Spec.Poly1305.Field32xN.as_nat5 inp % Hacl.Spec.Poly1305.Vec.prime == (Lib.IntTypes.v t0 + vc4 * 5 + Lib.IntTypes.v t1 * Hacl.Spec.Poly1305.Field32xN.pow26 + Lib.IntTypes.v t2 * Hacl.Spec.Poly1305.Field32xN.pow52 + Lib.IntTypes.v t3 * Hacl.Spec.Poly1305.Field32xN.pow78 + Lib.IntTypes.v t4 * Hacl.Spec.Poly1305.Field32xN.pow104) % Hacl.Spec.Poly1305.Vec.prime) <: Type0) <: Type0))
{ "end_col": 59, "end_line": 772, "start_col": 65, "start_line": 742 }
FStar.Pervasives.Lemma
val carry_reduce_felem5_fits_lemma_i0: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v tmp0).[i] < pow2 26 else (uint64xN_v tmp0).[i] <= 46) /\ (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63))
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_reduce_felem5_fits_lemma_i0 #w f i = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in carry_reduce_lemma_i f0 (zero w) i; assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v tmp0).[i] < pow2 26 else (uint64xN_v tmp0).[i] <= 46); assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c0).[i] = 0 else (uint64xN_v c0).[i] <= 63); let tmp1,c1 = carry26 f1 c0 in carry_reduce_lemma_i f1 c0 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c1).[i] = 0 else (uint64xN_v c1).[i] <= 63); let tmp2,c2 = carry26 f2 c1 in carry_reduce_lemma_i f2 c1 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c2).[i] = 0 else (uint64xN_v c2).[i] <= 63); let tmp3,c3 = carry26 f3 c2 in carry_reduce_lemma_i f3 c2 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c3).[i] = 0 else (uint64xN_v c3).[i] <= 63); let tmp4,c4 = carry26 f4 c3 in carry_reduce_lemma_i f4 c3 i; assert (if (uint64xN_v c0).[i] = 0 then (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63); assert (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c0).[i] = 0 /\ (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63)
val carry_reduce_felem5_fits_lemma_i0: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v tmp0).[i] < pow2 26 else (uint64xN_v tmp0).[i] <= 46) /\ (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63)) let carry_reduce_felem5_fits_lemma_i0 #w f i =
false
null
true
let f0, f1, f2, f3, f4 = f in let tmp0, c0 = carry26 f0 (zero w) in carry_reduce_lemma_i f0 (zero w) i; assert (if (uint64xN_v f0).[ i ] < pow2 26 then (uint64xN_v tmp0).[ i ] < pow2 26 else (uint64xN_v tmp0).[ i ] <= 46); assert (if (uint64xN_v f0).[ i ] < pow2 26 then (uint64xN_v c0).[ i ] = 0 else (uint64xN_v c0).[ i ] <= 63); let tmp1, c1 = carry26 f1 c0 in carry_reduce_lemma_i f1 c0 i; assert (if (uint64xN_v c0).[ i ] = 0 then (uint64xN_v c1).[ i ] = 0 else (uint64xN_v c1).[ i ] <= 63 ); let tmp2, c2 = carry26 f2 c1 in carry_reduce_lemma_i f2 c1 i; assert (if (uint64xN_v c0).[ i ] = 0 then (uint64xN_v c2).[ i ] = 0 else (uint64xN_v c2).[ i ] <= 63 ); let tmp3, c3 = carry26 f3 c2 in carry_reduce_lemma_i f3 c2 i; assert (if (uint64xN_v c0).[ i ] = 0 then (uint64xN_v c3).[ i ] = 0 else (uint64xN_v c3).[ i ] <= 63 ); let tmp4, c4 = carry26 f4 c3 in carry_reduce_lemma_i f4 c3 i; assert (if (uint64xN_v c0).[ i ] = 0 then (uint64xN_v c4).[ i ] = 0 else (uint64xN_v c4).[ i ] <= 63 ); assert (if (uint64xN_v f0).[ i ] < pow2 26 then (uint64xN_v c0).[ i ] = 0 /\ (uint64xN_v c4).[ i ] = 0 else (uint64xN_v c4).[ i ] <= 63)
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem5", "Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_t", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Prims._assert", "Lib.Sequence.op_String_Access", "Hacl.Spec.Poly1305.Field32xN.uint64xN_v", "Prims.pow2", "Prims.l_and", "Prims.op_Equality", "Prims.int", "Prims.bool", "Prims.op_LessThanOrEqual", "Prims.unit", "Hacl.Poly1305.Field32xN.Lemmas1.carry_reduce_lemma_i", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Poly1305.Field32xN.carry26", "Hacl.Spec.Poly1305.Field32xN.zero" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26) val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4)) let acc_inv_lemma #w acc cin = match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3 val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9) let carry_full_felem5_fits_lemma0 #w (f0, f1, f2, f3, f4) = let tmp0,c0 = carry26 f0 (zero w) in carry26_fits_lemma 1 8 f0 (zero w); let tmp1,c1 = carry26 f1 c0 in carry26_fits_lemma 1 8 f1 c0; let tmp2,c2 = carry26 f2 c1 in carry26_fits_lemma 1 8 f2 c1; let tmp3,c3 = carry26 f3 c2 in carry26_fits_lemma 1 8 f3 c2; let tmp4,c4 = carry26 f4 c3 in carry26_fits_lemma 1 8 f4 c3; assert (felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1)); assert (uint64xN_fits c4 9) val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (acc_inv_t (carry_full_felem5 f)) let carry_full_felem5_fits_lemma #w f = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_full_felem5_fits_lemma0 #w f; assert (felem_fits1 tmp0 1 /\ uint64xN_fits c4 9); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in acc_inv_lemma (tmp0, tmp1, tmp2, tmp3, tmp4) (vec_smul_mod c4 (u64 5)) val carry_full_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in v ti0 == vc0 * pow2 26 + v t0 /\ v ti1 + vc0 == vc1 * pow2 26 + v t1 /\ v ti2 + vc1 == vc2 * pow2 26 + v t2 /\ v ti3 + vc2 == vc3 * pow2 26 + v t3 /\ v ti4 + vc3 == vc4 * pow2 26 + v t4)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_full_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 = let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v ti0 + v ti1 * pow26 + v ti2 * pow52 + v ti3 * pow78 + v ti4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_full_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_full_felem5_eval_lemma_i1 #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in carry26_eval_lemma 1 8 i0 (zero w); assert (v ti0 == vc0 * pow2 26 + v t0); carry26_eval_lemma 1 8 i1 c0; assert (v ti1 + vc0 == vc1 * pow2 26 + v t1); carry26_eval_lemma 1 8 i2 c1; assert (v ti2 + vc1 == vc2 * pow2 26 + v t2); carry26_eval_lemma 1 8 i3 c2; assert (v ti3 + vc2 == vc3 * pow2 26 + v t3); carry26_eval_lemma 1 8 i4 c3; assert (v ti4 + vc3 == vc4 * pow2 26 + v t4); carry_full_felem5_eval_lemma_i0 (ti0, ti1, ti2, ti3, ti4) (t0, t1, t2, t3, t4) vc0 vc1 vc2 vc3 vc4; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) val carry_full_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma ((feval5 (carry_full_felem5 #w inp)).[i] == (feval5 inp).[i]) let carry_full_felem5_eval_lemma_i #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc4 = (uint64xN_v c4).[i] in carry_full_felem5_fits_lemma0 #w inp; let cin = vec_smul_mod c4 (u64 5) in assert ((uint64xN_v cin).[i] == vc4 * 5); let tmp0' = vec_add_mod tmp0 cin in Math.Lemmas.small_mod ((uint64xN_v tmp0).[i] + vc4 * 5) (pow2 64); assert ((uint64xN_v tmp0').[i] == (uint64xN_v tmp0).[i] + vc4 * 5); let out = (tmp0', tmp1, tmp2, tmp3, tmp4) in let (o0, o1, o2, o3, o4) = as_tup64_i out i in assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_full_felem5_eval_lemma_i1 #w inp i; assert ((feval5 out).[i] == (feval5 inp).[i]) val carry_full_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_fits5 inp (8, 8, 8, 8, 8)) (ensures feval5 (carry_full_felem5 #w inp) == feval5 inp) let carry_full_felem5_eval_lemma #w inp = let o = carry_full_felem5 #w inp in FStar.Classical.forall_intro (carry_full_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val carry_full_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (felem_fits5 (carry_full_felem5 f) (2, 1, 1, 1, 1) /\ feval5 (carry_full_felem5 f) == feval5 f) let carry_full_felem5_lemma #w f = carry_full_felem5_eval_lemma f; carry_full_felem5_fits_lemma f val carry_reduce_lemma_i: #w:lanes -> l:uint64xN w -> cin:uint64xN w -> i:nat{i < w} -> Lemma (requires (uint64xN_v l).[i] <= 2 * max26 /\ (uint64xN_v cin).[i] <= 62 * max26) (ensures (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= 63 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry_reduce_lemma_i #w l cin i = let li = (vec_v l).[i] in let cini = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v li + v cini) (pow2 64); let li' = li +! cini in let li0 = li' &. mask26 in let li1 = li' >>. 26ul in mod_mask_lemma li' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v li') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 #push-options "--z3rlimit 600" val carry_reduce_felem5_fits_lemma_i0: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v tmp0).[i] < pow2 26 else (uint64xN_v tmp0).[i] <= 46) /\ (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63))
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 600, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_reduce_felem5_fits_lemma_i0: #w:lanes -> f:felem5 w{acc_inv_t f} -> i:nat{i < w} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in let res = (tmp0, tmp1, tmp2, tmp3, tmp4) in (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v tmp0).[i] < pow2 26 else (uint64xN_v tmp0).[i] <= 46) /\ (if (uint64xN_v f0).[i] < pow2 26 then (uint64xN_v c4).[i] = 0 else (uint64xN_v c4).[i] <= 63))
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_reduce_felem5_fits_lemma_i0
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.Poly1305.Field32xN.felem5 w {Hacl.Poly1305.Field32xN.Lemmas1.acc_inv_t f} -> i: Prims.nat{i < w} -> FStar.Pervasives.Lemma (ensures (let _ = f in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ f0 f1 f2 f3 f4 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f0 (Hacl.Spec.Poly1305.Field32xN.zero w) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp0 c0 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f1 c0 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp1 c1 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f2 c1 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp2 c2 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f3 c2 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp3 c3 = _ in let _ = Hacl.Spec.Poly1305.Field32xN.carry26 f4 c3 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ tmp4 c4 = _ in let res = tmp0, tmp1, tmp2, tmp3, tmp4 in (match (Hacl.Spec.Poly1305.Field32xN.uint64xN_v f0).[ i ] < Prims.pow2 26 with | true -> (Hacl.Spec.Poly1305.Field32xN.uint64xN_v tmp0).[ i ] < Prims.pow2 26 | _ -> (Hacl.Spec.Poly1305.Field32xN.uint64xN_v tmp0).[ i ] <= 46) /\ (match (Hacl.Spec.Poly1305.Field32xN.uint64xN_v f0).[ i ] < Prims.pow2 26 with | true -> (Hacl.Spec.Poly1305.Field32xN.uint64xN_v c4).[ i ] = 0 | _ -> (Hacl.Spec.Poly1305.Field32xN.uint64xN_v c4).[ i ] <= 63)) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0) <: Type0))
{ "end_col": 130, "end_line": 946, "start_col": 46, "start_line": 928 }
FStar.Pervasives.Lemma
val carry_full_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma ((feval5 (carry_full_felem5 #w inp)).[i] == (feval5 inp).[i])
[ { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Poly1305.Vec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Calc", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntVector", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Poly1305.Field32xN", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let carry_full_felem5_eval_lemma_i #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc4 = (uint64xN_v c4).[i] in carry_full_felem5_fits_lemma0 #w inp; let cin = vec_smul_mod c4 (u64 5) in assert ((uint64xN_v cin).[i] == vc4 * 5); let tmp0' = vec_add_mod tmp0 cin in Math.Lemmas.small_mod ((uint64xN_v tmp0).[i] + vc4 * 5) (pow2 64); assert ((uint64xN_v tmp0').[i] == (uint64xN_v tmp0).[i] + vc4 * 5); let out = (tmp0', tmp1, tmp2, tmp3, tmp4) in let (o0, o1, o2, o3, o4) = as_tup64_i out i in assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_full_felem5_eval_lemma_i1 #w inp i; assert ((feval5 out).[i] == (feval5 inp).[i])
val carry_full_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma ((feval5 (carry_full_felem5 #w inp)).[i] == (feval5 inp).[i]) let carry_full_felem5_eval_lemma_i #w inp i =
false
null
true
let i0, i1, i2, i3, i4 = inp in let tmp0, c0 = carry26 i0 (zero w) in let tmp1, c1 = carry26 i1 c0 in let tmp2, c2 = carry26 i2 c1 in let tmp3, c3 = carry26 i3 c2 in let tmp4, c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let t0, t1, t2, t3, t4 = as_tup64_i tmp i in let ti0, ti1, ti2, ti3, ti4 = as_tup64_i inp i in let vc4 = (uint64xN_v c4).[ i ] in carry_full_felem5_fits_lemma0 #w inp; let cin = vec_smul_mod c4 (u64 5) in assert ((uint64xN_v cin).[ i ] == vc4 * 5); let tmp0' = vec_add_mod tmp0 cin in Math.Lemmas.small_mod ((uint64xN_v tmp0).[ i ] + vc4 * 5) (pow2 64); assert ((uint64xN_v tmp0').[ i ] == (uint64xN_v tmp0).[ i ] + vc4 * 5); let out = (tmp0', tmp1, tmp2, tmp3, tmp4) in let o0, o1, o2, o3, o4 = as_tup64_i out i in assert ((feval5 out).[ i ] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_full_felem5_eval_lemma_i1 #w inp i; assert ((feval5 out).[ i ] == (feval5 inp).[ i ])
{ "checked_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.Poly1305.Vec.fst.checked", "Hacl.Spec.Poly1305.Field32xN.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Poly1305.Field32xN.Lemmas1.fst" }
[ "lemma" ]
[ "Hacl.Spec.Poly1305.Field32xN.lanes", "Hacl.Spec.Poly1305.Field32xN.felem_wide5", "Hacl.Spec.Poly1305.Field32xN.felem_fits5", "FStar.Pervasives.Native.Mktuple5", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Poly1305.Field32xN.uint64xN", "Lib.IntTypes.uint64", "Prims._assert", "Prims.eq2", "Hacl.Spec.Poly1305.Vec.pfelem", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Hacl.Spec.Poly1305.Field32xN.feval5", "Lib.Sequence.op_String_Access", "Prims.unit", "Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_eval_lemma_i1", "Prims.int", "Prims.op_Modulus", "Prims.op_Addition", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Mul.op_Star", "Hacl.Spec.Poly1305.Field32xN.pow26", "Hacl.Spec.Poly1305.Field32xN.pow52", "Hacl.Spec.Poly1305.Field32xN.pow78", "Hacl.Spec.Poly1305.Field32xN.pow104", "Hacl.Spec.Poly1305.Vec.prime", "Hacl.Spec.Poly1305.Field32xN.tup64_5", "Hacl.Spec.Poly1305.Field32xN.as_tup64_i", "FStar.Pervasives.Native.tuple5", "Hacl.Spec.Poly1305.Field32xN.uint64xN_v", "FStar.Math.Lemmas.small_mod", "Prims.pow2", "Lib.IntVector.vec_t", "Lib.IntVector.vec_add_mod", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntVector.vec_v", "Lib.Sequence.map", "Lib.IntTypes.mul_mod", "Lib.IntTypes.mk_int", "Lib.IntTypes.range", "Lib.IntVector.vec_smul_mod", "Lib.IntTypes.u64", "Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_fits_lemma0", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Poly1305.Field32xN.carry26", "Hacl.Spec.Poly1305.Field32xN.zero" ]
[]
module Hacl.Poly1305.Field32xN.Lemmas1 open Lib.IntTypes open Lib.IntVector open Lib.Sequence open FStar.Mul open FStar.Calc open Hacl.Spec.Poly1305.Vec include Hacl.Spec.Poly1305.Field32xN #set-options "--z3rlimit 50 --using_facts_from '* -FStar.Seq' --max_fuel 0 --max_ifuel 0" val lemma_prime: unit -> Lemma (pow2 130 % prime = 5) let lemma_prime () = assert_norm (pow2 130 % prime = 5 % prime); assert_norm (5 < prime); FStar.Math.Lemmas.modulo_lemma 5 prime noextract val carry26_wide_zero: #w:lanes -> l:uint64xN w -> uint64xN w & uint64xN w let carry26_wide_zero #w l = (vec_and l (mask26 w), vec_shift_right l 26ul) val carry26_wide_zero_eq: #w:lanes -> f:uint64xN w -> Lemma (carry26_wide_zero f == carry26_wide f (zero w)) let carry26_wide_zero_eq #w f = let l1 = vec_add_mod f (zero w) in assert (vec_v l1 == map2 ( +. ) (vec_v f) (vec_v (zero w))); assert (forall (i:nat{i < w}). uint_v (vec_v l1).[i] == uint_v (vec_v f).[i]); assert (forall (i:nat{i < w}). (vec_v l1).[i] == (vec_v f).[i]); eq_intro (vec_v l1) (vec_v f); assert (vec_v l1 == vec_v f); vecv_extensionality l1 f val vec_smul_mod_five_i: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> i:nat{i < w} -> Lemma (u64 5 *. (vec_v f).[i] == (vec_v f).[i] +. ((vec_v f).[i] <<. 2ul)) let vec_smul_mod_five_i #w f i = let f = (vec_v f).[i] in assert (v (f <<. 2ul) == (v f * pow2 2) % pow2 64); Math.Lemmas.small_mod (v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (v f + v f * pow2 2) (pow2 64); Math.Lemmas.small_mod (5 * v f) (pow2 64); assert (5 * v f == v f + v f * 4); v_injective (u64 5 *. f); v_injective (f +. (f <<. 2ul)) val vec_smul_mod_five: #w:lanes -> f:uint64xN w{uint64xN_fits f (4096 * max26)} -> Lemma (vec_smul_mod f (u64 5) == vec_add_mod f (vec_shift_left f 2ul)) let vec_smul_mod_five #w f = let r1 = vec_smul_mod f (u64 5) in let r2 = vec_add_mod f (vec_shift_left f 2ul) in Classical.forall_intro (vec_smul_mod_five_i #w f); eq_intro (vec_v r1) (vec_v r2); vecv_extensionality r1 r2 noextract val carry_wide_felem5_compact: #w:lanes -> inp:felem_wide5 w -> felem5 w let carry_wide_felem5_compact #w (x0, x1, x2, x3, x4) = // m_i <= 4096, x_i <= m_i * max26 * max26 // felem_wide_fits5 (x0, x1, x2, x3, x4) (m0, m1, m2, m3, m4) let t0, c0 = carry26_wide_zero x0 in // t0 <= max26 /\ c0 <= (m0 + 1) * max26 let t1, c1 = carry26_wide x1 c0 in // t1 <= max26 /\ c1 <= (m1 + 1) * max26 let t2, c2 = carry26_wide x2 c1 in // t2 <= max26 /\ c2 <= (m2 + 1) * max26 let t3, c3 = carry26_wide_zero x3 in // t3 <= max26 /\ c3 <= (m3 + 1) * max26 let t3', c6 = carry26 t3 c2 in // t3' <= max26 /\ c6 <= m2 + 2 let t4, c4 = carry26_wide x4 c3 in // t4 <= max26 /\ c4 <= (m4 + 1) * max26 let t4' = vec_add_mod t4 c6 in // t4' <= 2 * max26 let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in // t0' <= max26 /\ c5 <= 5 * (m4 + 1) + 1 let t1' = vec_add_mod t1 c5 in // t1' <= 2 * max26 (t0', t1', t2, t3', t4') // felem_fits5 (t0', t1', t2, t3', t4') (1, 2, 1, 1, 2) val carry26_wide_lemma_i: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] <= (m + 1) * max26 /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_wide_lemma_i #w #m l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.euclidean_division_definition (v l') (pow2 26) val carry26_wide_fits_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26)) #push-options "--z3rlimit 100" let carry26_wide_fits_lemma #w #m l cin = match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 #pop-options val carry26_wide_eval_lemma: #w:lanes -> #m:scale64 -> l:uint64xN w{felem_wide_fits1 l m} -> cin:uint64xN w{uint64xN_fits cin (4096 * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in //felem_fits1 l0 1 /\ uint64xN_fits l1 ((m + 1) * max26) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_wide_eval_lemma #w #m l cin = carry26_wide_fits_lemma #w #m l cin; match w with | 1 -> carry26_wide_lemma_i #w #m l cin 0 | 2 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1 | 4 -> carry26_wide_lemma_i #w #m l cin 0; carry26_wide_lemma_i #w #m l cin 1; carry26_wide_lemma_i #w #m l cin 2; carry26_wide_lemma_i #w #m l cin 3 val carry26_lemma_i: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> i:nat{i < w} -> Lemma (let (l0, l1) = carry26 #w l cin in (uint64xN_v l0).[i] <= max26 /\ (uint64xN_v l1).[i] < m + ml /\ (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i]) let carry26_lemma_i #w m ml l cin i = let l = (vec_v l).[i] in let cin = (vec_v cin).[i] in let mask26 = u64 0x3ffffff in assert_norm (0x3ffffff = pow2 26 - 1); FStar.Math.Lemmas.modulo_lemma (v l + v cin) (pow2 64); let l' = l +! cin in let l0 = l' &. mask26 in let l1 = l' >>. 26ul in mod_mask_lemma l' 26ul; assert (v (mod_mask #U64 #SEC 26ul) == v mask26); FStar.Math.Lemmas.pow2_modulo_modulo_lemma_1 (v l') 26 32; FStar.Math.Lemmas.pow2_minus 32 26 val carry26_fits_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml)) let carry26_fits_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry26_eval_lemma: #w:lanes -> m:scale64 -> ml:scale32 -> l:uint64xN w{felem_fits1 l ml} -> cin:uint64xN w{uint64xN_fits cin (m * max26)} -> Lemma (let (l0, l1) = carry26 #w l cin in felem_fits1 l0 1 /\ uint64xN_fits l1 (m + ml) /\ (forall (i:nat). i < w ==> (uint64xN_v l).[i] + (uint64xN_v cin).[i] == (uint64xN_v l1).[i] * pow2 26 + (uint64xN_v l0).[i])) let carry26_eval_lemma #w m ml l cin = match w with | 1 -> carry26_lemma_i #w m ml l cin 0 | 2 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1 | 4 -> carry26_lemma_i #w m ml l cin 0; carry26_lemma_i #w m ml l cin 1; carry26_lemma_i #w m ml l cin 2; carry26_lemma_i #w m ml l cin 3 val carry_wide_felem5_fits_lemma0: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in felem_fits5 tmp (1, 1, 1, 1, 2) /\ felem_fits1 c4 31) let carry_wide_felem5_fits_lemma0 #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in carry26_wide_zero_eq x0; carry26_wide_fits_lemma #w #126 x0 (zero w); let t1, c1 = carry26_wide x1 c0 in carry26_wide_fits_lemma #w #102 x1 c0; let t2, c2 = carry26_wide x2 c1 in carry26_wide_fits_lemma #w #78 x2 c1; let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in carry26_wide_fits_lemma #w #30 x4 c3 val carry_wide_felem5_fits_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures felem_fits5 (carry_wide_felem5 inp) (1, 2, 1, 1, 2)) #push-options "--z3rlimit 200" let carry_wide_felem5_fits_lemma #w inp = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in carry_wide_felem5_fits_lemma0 #w inp; vec_smul_mod_five c4; let t0', c5 = carry26 t0 (vec_smul_mod c4 (u64 5)) in carry26_fits_lemma 155 1 t0 (vec_smul_mod c4 (u64 5)) #pop-options val carry_wide_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> vc6:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in v xi0 == vc0 * pow2 26 + v t0 /\ v xi1 + vc0 == vc1 * pow2 26 + v t1 /\ v xi2 + vc1 == vc2 * pow2 26 + v t2 /\ v xi3 + vc2 == vc3 * pow2 26 + vc6 * pow2 26 + v t3 /\ v xi4 + vc3 == vc4 * pow2 26 + v t4 - vc6)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_wide_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 vc6 = let (t0, t1, t2, t3, t4) = tmp in let (xi0, xi1, xi2, xi3, xi4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v xi0 + v xi1 * pow26 + v xi2 * pow52 + v xi3 * pow78 + v xi4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + vc6 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc6 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_wide_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma (let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in let t3', c6 = carry26 t3 c2 in let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_wide_felem5_eval_lemma_i1 #w inp i = let (x0, x1, x2, x3, x4) = inp in let t0, c0 = carry26_wide_zero x0 in let t1, c1 = carry26_wide x1 c0 in let t2, c2 = carry26_wide x2 c1 in let t3, c3 = carry26_wide_zero x3 in carry26_wide_zero_eq x3; carry26_wide_fits_lemma #w #54 x3 (zero w); let t3', c6 = carry26 t3 c2 in carry26_eval_lemma 79 1 t3 c2; carry26_fits_lemma 79 1 t3 c2; let t4, c4 = carry26_wide x4 c3 in let t4' = vec_add_mod t4 c6 in let tmp = (t0, t1, t2, t3, t4) in let tmp' = (t0, t1, t2, t3', t4') in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (t0, t1, t2, t3', t4') = as_tup64_i tmp' i in let (xi0, xi1, xi2, xi3, xi4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in let vc6 = (uint64xN_v c6).[i] in carry26_wide_zero_eq x0; carry26_wide_eval_lemma #w #126 x0 (zero w); assert (v xi0 == vc0 * pow2 26 + v t0); carry26_wide_eval_lemma #w #102 x1 c0; assert (v xi1 + vc0 == vc1 * pow2 26 + v t1); carry26_wide_eval_lemma #w #78 x2 c1; assert (v xi2 + vc1 == vc2 * pow2 26 + v t2); carry26_wide_zero_eq x3; carry26_wide_eval_lemma #w #54 x3 (zero w); assert (v xi3 == vc3 * pow2 26 + v t3); assert (v t3 + vc2 == vc6 * pow2 26 + v t3'); carry26_wide_eval_lemma #w #30 x4 c3; assert (v xi4 + vc3 == vc4 * pow2 26 + v t4); carry26_wide_fits_lemma #w #30 x4 c3; Math.Lemmas.small_mod (v t4 + vc6) (pow2 64); assert (v t4' == v t4 + vc6); carry_wide_felem5_eval_lemma_i0 (xi0, xi1, xi2, xi3, xi4) (t0, t1, t2, t3', t4') vc0 vc1 vc2 vc3 vc4 vc6; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3' * pow78 + v t4' * pow104) % prime) val carry_wide_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_wide_fits5 inp (126, 102, 78, 54, 30)} -> i:nat{i < w} -> Lemma ((feval5 (carry_wide_felem5 #w inp)).[i] == (feval5 inp).[i]) #push-options "--z3rlimit 100" let carry_wide_felem5_eval_lemma_i #w inp i = let (x0, x1, x2, x3, x4) = inp in let tmp0, c0 = carry26_wide_zero x0 in let tmp1, c1 = carry26_wide x1 c0 in let tmp2, c2 = carry26_wide x2 c1 in let tmp3, c3 = carry26_wide_zero x3 in let tmp3', c6 = carry26 tmp3 c2 in let tmp4, c4 = carry26_wide x4 c3 in let tmp4' = vec_add_mod tmp4 c6 in carry_wide_felem5_fits_lemma0 #w inp; Math.Lemmas.small_mod ((uint64xN_v c4).[i] * 5) (pow2 64); let tmp0', c5 = carry26 tmp0 (vec_smul_mod c4 (u64 5)) in carry26_eval_lemma 155 1 tmp0 (vec_smul_mod c4 (u64 5)); assert ((uint64xN_v tmp0).[i] + (uint64xN_v c4).[i] * 5 == (uint64xN_v c5).[i] * pow2 26 + (uint64xN_v tmp0').[i]); let tmp1' = vec_add_mod tmp1 c5 in Math.Lemmas.small_mod ((uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]) (pow2 64); assert ((uint64xN_v tmp1').[i] == (uint64xN_v tmp1).[i] + (uint64xN_v c5).[i]); let out = (tmp0', tmp1', tmp2, tmp3', tmp4') in let tmp = (tmp0, tmp1, tmp2, tmp3', tmp4') in let (o0, o1, o2, o3, o4) = as_tup64_i out i in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in let vc5 = (uint64xN_v c5).[i] in calc (==) { (feval5 out).[i]; (==) { } (v o0 + v o1 * pow26 + v o2 * pow52 + v o3 * pow78 + v o4 * pow104) % prime; (==) { } (v t0 + vc4 * 5 + (v t1 + vc5) * pow26 - vc5 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime; }; Math.Lemmas.distributivity_add_left (v t1) vc5 pow26; assert ((feval5 out).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); carry_wide_felem5_eval_lemma_i1 #w inp i; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime); assert ((feval5 out).[i] == (feval5 inp).[i]); vec_smul_mod_five c4 #pop-options val carry_wide_felem5_eval_lemma: #w:lanes -> inp:felem_wide5 w -> Lemma (requires felem_wide_fits5 inp (126, 102, 78, 54, 30)) (ensures feval5 (carry_wide_felem5 #w inp) == feval5 inp) let carry_wide_felem5_eval_lemma #w inp = let o = carry_wide_felem5 #w inp in FStar.Classical.forall_intro (carry_wide_felem5_eval_lemma_i #w inp); eq_intro (feval5 o) (feval5 inp) val lemma_subtract_p5_0: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_0 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = max26); assert_norm (0x3fffffb = max26 - 4); assert (as_nat5 f == v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104); assert (as_nat5 f <= pow26 - 5 + (pow2 26 - 1) * pow26 + (pow2 26 - 1) * pow52 + (pow2 26 - 1) * pow78 + (pow2 26 - 1) * pow104); assert_norm (pow2 26 * pow104 = pow2 130); assert (as_nat5 f < pow2 130 - 5); assert (as_nat5 f == as_nat5 f'); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5_1: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in (v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5_1 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in //assert_norm (max26 = pow2 26 - 1); assert_norm (0x3ffffff = pow2 26 - 1); assert_norm (0x3fffffb = pow2 26 - 5); assert (as_nat5 f' < prime); calc (==) { as_nat5 f' % prime; (==) { } (v f0' + v f1' * pow26 + v f2' * pow52 + v f3' * pow78 + v f4' * pow104) % prime; (==) { } (v f0 - (pow2 26 - 5) + (v f1 - (pow2 26 - 1)) * pow26 + (v f2 - (pow2 26 - 1)) * pow52 + (v f3 - (pow2 26 - 1)) * pow78 + (v f4 - (pow2 26 - 1)) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130) } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104 - prime) % prime; (==) { FStar.Math.Lemmas.lemma_mod_sub (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) prime 1 } (v f0 + v f1 * pow26 + v f2 * pow52 + v f3 * pow78 + v f4 * pow104) % prime; (==) { } as_nat5 f % prime; }; assert (as_nat5 f' % prime == as_nat5 f % prime); FStar.Math.Lemmas.modulo_lemma (as_nat5 f') prime val lemma_subtract_p5: f:tup64_5{tup64_fits5 f (1, 1, 1, 1, 1)} -> f':tup64_5 -> Lemma (requires (let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in ((v f4 = 0x3ffffff && v f3 = 0x3ffffff && v f2 = 0x3ffffff && v f1 = 0x3ffffff && v f0 >= 0x3fffffb) /\ (v f0' = v f0 - 0x3fffffb && v f1' = v f1 - 0x3ffffff && v f2' = v f2 - 0x3ffffff && v f3' = v f3 - 0x3ffffff && v f4' = v f4 - 0x3ffffff)) \/ ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) /\ (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)))) (ensures as_nat5 f' == as_nat5 f % prime) let lemma_subtract_p5 f f' = let (f0, f1, f2, f3, f4) = f in let (f0', f1', f2', f3', f4') = f' in assert_norm (max26 = pow2 26 - 1); if ((v f4 <> 0x3ffffff || v f3 <> 0x3ffffff || v f2 <> 0x3ffffff || v f1 <> 0x3ffffff || v f0 < 0x3fffffb) && (v f0' = v f0 && v f1' = v f1 && v f2' = v f2 && v f3' = v f3 && v f4' = v f4)) then lemma_subtract_p5_0 f f' else lemma_subtract_p5_1 f f' noextract val subtract_p5_s: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Pure tup64_5 (requires True) (ensures fun out -> tup64_fits5 out (1, 1, 1, 1, 1) /\ as_nat5 out == as_nat5 (as_tup64_i f i) % prime) #push-options "--z3rlimit 100" let subtract_p5_s #w f i = let (f0, f1, f2, f3, f4) = as_tup64_i f i in let mask0 = eq_mask f4 (u64 0x3ffffff) in let mask1 = mask0 &. eq_mask f3 (u64 0x3ffffff) in let mask2 = mask1 &. eq_mask f2 (u64 0x3ffffff) in let mask3 = mask2 &. eq_mask f1 (u64 0x3ffffff) in let mask4 = mask3 &. gte_mask f0 (u64 0x3fffffb) in let p0 = mask4 &. u64 0x3fffffb in logand_lemma mask4 (u64 0x3fffffb); let p1 = mask4 &. u64 0x3ffffff in logand_lemma mask4 (u64 0x3ffffff); let p2 = mask4 &. u64 0x3ffffff in let p3 = mask4 &. u64 0x3ffffff in let p4 = mask4 &. u64 0x3ffffff in let f0' = f0 -. p0 in let f1' = f1 -. p1 in let f2' = f2 -. p2 in let f3' = f3 -. p3 in let f4' = f4 -. p4 in lemma_subtract_p5 (f0, f1, f2, f3, f4) (f0', f1', f2', f3', f4'); (f0', f1', f2', f3', f4') #pop-options #push-options "--max_ifuel 1" val subtract_p5_felem5_lemma_i: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> i:nat{i < w} -> Lemma (tup64_fits5 (as_tup64_i (subtract_p5 #w f) i) (1, 1, 1, 1, 1) /\ as_nat5 (as_tup64_i (subtract_p5 #w f) i) == as_nat5 (as_tup64_i f i) % prime) let subtract_p5_felem5_lemma_i #w f i = assert (subtract_p5_s #w f i == as_tup64_i (subtract_p5 #w f) i) #pop-options val subtract_p5_felem5_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (1, 1, 1, 1, 1)} -> Lemma (felem_fits5 (subtract_p5 f) (1, 1, 1, 1, 1) /\ (fas_nat5 (subtract_p5 f)).[0] == (feval5 f).[0]) let subtract_p5_felem5_lemma #w f = match w with | 1 -> subtract_p5_felem5_lemma_i #w f 0 | 2 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1 | 4 -> subtract_p5_felem5_lemma_i #w f 0; subtract_p5_felem5_lemma_i #w f 1; subtract_p5_felem5_lemma_i #w f 2; subtract_p5_felem5_lemma_i #w f 3 noextract let acc_inv_t (#w:lanes) (acc:felem5 w) : Type0 = let (o0, o1, o2, o3, o4) = acc in forall (i:nat). i < w ==> (if uint_v (vec_v o0).[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc i) (2, 1, 1, 1, 1) /\ uint_v (vec_v o0).[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc i) (1, 1, 1, 1, 1)) val acc_inv_lemma_i: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in let acc1 = (i0', i1, i2, i3, i4) in (if (uint64xN_v i0').[i] >= pow2 26 then tup64_fits5 (as_tup64_i acc1 i) (2, 1, 1, 1, 1) /\ (uint64xN_v i0').[i] % pow2 26 < 47 else tup64_fits5 (as_tup64_i acc1 i) (1, 1, 1, 1, 1))) let acc_inv_lemma_i #w acc cin i = let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in assert ((vec_v i0').[i] == (vec_v i0).[i] +. (vec_v cin).[i]); assert ((uint64xN_v i0).[i] + (uint64xN_v cin).[i] <= max26 + 46); assert_norm (max26 = pow2 26 - 1); FStar.Math.Lemmas.euclidean_division_definition ((uint64xN_v i0).[i] + (uint64xN_v cin).[i]) (pow2 26) val acc_inv_lemma: #w:lanes -> acc:felem5 w{felem_fits5 acc (1, 1, 1, 1, 1)} -> cin:uint64xN w{uint64xN_fits cin 45} -> Lemma (let (i0, i1, i2, i3, i4) = acc in let i0' = vec_add_mod i0 cin in acc_inv_t (i0', i1, i2, i3, i4)) let acc_inv_lemma #w acc cin = match w with | 1 -> acc_inv_lemma_i #w acc cin 0 | 2 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1 | 4 -> acc_inv_lemma_i #w acc cin 0; acc_inv_lemma_i #w acc cin 1; acc_inv_lemma_i #w acc cin 2; acc_inv_lemma_i #w acc cin 3 val carry_full_felem5_fits_lemma0: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1) /\ uint64xN_fits c4 9) let carry_full_felem5_fits_lemma0 #w (f0, f1, f2, f3, f4) = let tmp0,c0 = carry26 f0 (zero w) in carry26_fits_lemma 1 8 f0 (zero w); let tmp1,c1 = carry26 f1 c0 in carry26_fits_lemma 1 8 f1 c0; let tmp2,c2 = carry26 f2 c1 in carry26_fits_lemma 1 8 f2 c1; let tmp3,c3 = carry26 f3 c2 in carry26_fits_lemma 1 8 f3 c2; let tmp4,c4 = carry26 f4 c3 in carry26_fits_lemma 1 8 f4 c3; assert (felem_fits5 (tmp0, tmp1, tmp2, tmp3, tmp4) (1, 1, 1, 1, 1)); assert (uint64xN_fits c4 9) val carry_full_felem5_fits_lemma: #w:lanes -> f:felem5 w{felem_fits5 f (8, 8, 8, 8, 8)} -> Lemma (acc_inv_t (carry_full_felem5 f)) let carry_full_felem5_fits_lemma #w f = let (f0, f1, f2, f3, f4) = f in let tmp0,c0 = carry26 f0 (zero w) in let tmp1,c1 = carry26 f1 c0 in let tmp2,c2 = carry26 f2 c1 in let tmp3,c3 = carry26 f3 c2 in let tmp4,c4 = carry26 f4 c3 in carry_full_felem5_fits_lemma0 #w f; assert (felem_fits1 tmp0 1 /\ uint64xN_fits c4 9); let tmp0' = vec_add_mod tmp0 (vec_smul_mod c4 (u64 5)) in acc_inv_lemma (tmp0, tmp1, tmp2, tmp3, tmp4) (vec_smul_mod c4 (u64 5)) val carry_full_felem5_eval_lemma_i0: inp:tup64_5 -> tmp:tup64_5 -> vc0:nat -> vc1:nat -> vc2:nat -> vc3:nat -> vc4:nat -> Lemma (requires (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in v ti0 == vc0 * pow2 26 + v t0 /\ v ti1 + vc0 == vc1 * pow2 26 + v t1 /\ v ti2 + vc1 == vc2 * pow2 26 + v t2 /\ v ti3 + vc2 == vc3 * pow2 26 + v t3 /\ v ti4 + vc3 == vc4 * pow2 26 + v t4)) (ensures (let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in as_nat5 inp % prime == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime)) let carry_full_felem5_eval_lemma_i0 inp tmp vc0 vc1 vc2 vc3 vc4 = let (t0, t1, t2, t3, t4) = tmp in let (ti0, ti1, ti2, ti3, ti4) = inp in let tmp_n = v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 in calc (==) { as_nat5 inp % prime; (==) { } (v ti0 + v ti1 * pow26 + v ti2 * pow52 + v ti3 * pow78 + v ti4 * pow104) % prime; (==) { } (vc0 * pow2 26 + v t0 + (vc1 * pow2 26 + v t1 - vc0) * pow26 + (vc2 * pow2 26 + v t2 - vc1) * pow52 + (vc3 * pow2 26 + v t3 - vc2) * pow78 + (vc4 * pow2 26 + v t4 - vc3) * pow104) % prime; (==) { assert_norm (pow2 26 * pow26 = pow52); assert_norm (pow2 26 * pow52 = pow78); assert_norm (pow2 26 * pow78 = pow104); assert_norm (pow2 26 * pow104 = pow2 130)} (v t0 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104 + vc4 * pow2 130) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * pow2 130) prime } (tmp_n + (vc4 * pow2 130 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_mul_distr_r (vc4) (pow2 130) prime } (tmp_n + (vc4 * (pow2 130 % prime) % prime)) % prime; (==) { lemma_prime () } (tmp_n + (vc4 * 5 % prime)) % prime; (==) { FStar.Math.Lemmas.lemma_mod_plus_distr_r tmp_n (vc4 * 5) prime } (tmp_n + vc4 * 5) % prime; }; assert (as_nat5 inp % prime == (tmp_n + vc4 * 5) % prime) val carry_full_felem5_eval_lemma_i1: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma (let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let vc4 = (uint64xN_v c4).[i] in (feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) let carry_full_felem5_eval_lemma_i1 #w inp i = let (i0, i1, i2, i3, i4) = inp in let tmp0,c0 = carry26 i0 (zero w) in let tmp1,c1 = carry26 i1 c0 in let tmp2,c2 = carry26 i2 c1 in let tmp3,c3 = carry26 i3 c2 in let tmp4,c4 = carry26 i4 c3 in let tmp = (tmp0, tmp1, tmp2, tmp3, tmp4) in let (t0, t1, t2, t3, t4) = as_tup64_i tmp i in let (ti0, ti1, ti2, ti3, ti4) = as_tup64_i inp i in let vc0 = (uint64xN_v c0).[i] in let vc1 = (uint64xN_v c1).[i] in let vc2 = (uint64xN_v c2).[i] in let vc3 = (uint64xN_v c3).[i] in let vc4 = (uint64xN_v c4).[i] in carry26_eval_lemma 1 8 i0 (zero w); assert (v ti0 == vc0 * pow2 26 + v t0); carry26_eval_lemma 1 8 i1 c0; assert (v ti1 + vc0 == vc1 * pow2 26 + v t1); carry26_eval_lemma 1 8 i2 c1; assert (v ti2 + vc1 == vc2 * pow2 26 + v t2); carry26_eval_lemma 1 8 i3 c2; assert (v ti3 + vc2 == vc3 * pow2 26 + v t3); carry26_eval_lemma 1 8 i4 c3; assert (v ti4 + vc3 == vc4 * pow2 26 + v t4); carry_full_felem5_eval_lemma_i0 (ti0, ti1, ti2, ti3, ti4) (t0, t1, t2, t3, t4) vc0 vc1 vc2 vc3 vc4; assert ((feval5 inp).[i] == (v t0 + vc4 * 5 + v t1 * pow26 + v t2 * pow52 + v t3 * pow78 + v t4 * pow104) % prime) val carry_full_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma ((feval5 (carry_full_felem5 #w inp)).[i] == (feval5 inp).[i])
false
false
Hacl.Poly1305.Field32xN.Lemmas1.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val carry_full_felem5_eval_lemma_i: #w:lanes -> inp:felem_wide5 w{felem_fits5 inp (8, 8, 8, 8, 8)} -> i:nat{i < w} -> Lemma ((feval5 (carry_full_felem5 #w inp)).[i] == (feval5 inp).[i])
[]
Hacl.Poly1305.Field32xN.Lemmas1.carry_full_felem5_eval_lemma_i
{ "file_name": "code/poly1305/Hacl.Poly1305.Field32xN.Lemmas1.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
inp: Hacl.Spec.Poly1305.Field32xN.felem_wide5 w {Hacl.Spec.Poly1305.Field32xN.felem_fits5 inp (8, 8, 8, 8, 8)} -> i: Prims.nat{i < w} -> FStar.Pervasives.Lemma (ensures (Hacl.Spec.Poly1305.Field32xN.feval5 (Hacl.Spec.Poly1305.Field32xN.carry_full_felem5 inp)).[ i ] == (Hacl.Spec.Poly1305.Field32xN.feval5 inp).[ i ])
{ "end_col": 47, "end_line": 855, "start_col": 45, "start_line": 831 }
Prims.GTot
[ { "abbrev": true, "full_module": "Hacl.Spec.P256.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fmont_as_nat (h:mem) (a:felem) = SM.from_mont (as_nat h a)
let fmont_as_nat (h: mem) (a: felem) =
false
null
false
SM.from_mont (as_nat h a)
{ "checked_file": "Hacl.Impl.P256.Field.fsti.checked", "dependencies": [ "Spec.P256.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.P256.Montgomery.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.P256.Field.fsti" }
[ "sometrivial" ]
[ "FStar.Monotonic.HyperStack.mem", "Hacl.Impl.P256.Bignum.felem", "Hacl.Spec.P256.Montgomery.from_mont", "Hacl.Impl.P256.Bignum.as_nat", "Spec.P256.PointOps.felem" ]
[]
module Hacl.Impl.P256.Field open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum module S = Spec.P256 module SM = Hacl.Spec.P256.Montgomery #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
false
false
Hacl.Impl.P256.Field.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fmont_as_nat : h: FStar.Monotonic.HyperStack.mem -> a: Hacl.Impl.P256.Bignum.felem -> Prims.GTot Spec.P256.PointOps.felem
[]
Hacl.Impl.P256.Field.fmont_as_nat
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.Field.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: FStar.Monotonic.HyperStack.mem -> a: Hacl.Impl.P256.Bignum.felem -> Prims.GTot Spec.P256.PointOps.felem
{ "end_col": 62, "end_line": 18, "start_col": 37, "start_line": 18 }
Prims.Tot
val blake2b_update_key:Impl.blake2_update_key_st Spec.Blake2B Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2b_update_key : Impl.blake2_update_key_st Spec.Blake2B Core.M32 = Impl.blake2_update_key #Spec.Blake2B #Core.M32 blake2b_update_block
val blake2b_update_key:Impl.blake2_update_key_st Spec.Blake2B Core.M32 let blake2b_update_key:Impl.blake2_update_key_st Spec.Blake2B Core.M32 =
false
null
false
Impl.blake2_update_key #Spec.Blake2B #Core.M32 blake2b_update_block
{ "checked_file": "Hacl.Blake2b_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2b_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_update_key", "Spec.Blake2.Blake2B", "Hacl.Impl.Blake2.Core.M32", "Hacl.Blake2b_32.blake2b_update_block" ]
[]
module Hacl.Blake2b_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) private let blake2b_update_block : Impl.blake2_update_block_st Spec.Blake2B Core.M32 = Impl.blake2_update_block #Spec.Blake2B #Core.M32 let blake2b_init : Impl.blake2_init_st Spec.Blake2B Core.M32 = Impl.blake2_init #Spec.Blake2B #Core.M32
false
false
Hacl.Blake2b_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2b_update_key:Impl.blake2_update_key_st Spec.Blake2B Core.M32
[]
Hacl.Blake2b_32.blake2b_update_key
{ "file_name": "code/blake2/Hacl.Blake2b_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_update_key_st Spec.Blake2.Blake2B Hacl.Impl.Blake2.Core.M32
{ "end_col": 69, "end_line": 16, "start_col": 2, "start_line": 16 }
Prims.Tot
val blake2b_malloc:Impl.blake2_malloc_st Spec.Blake2B Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2b_malloc : Impl.blake2_malloc_st Spec.Blake2B Core.M32 = Impl.blake2_malloc Spec.Blake2B Core.M32
val blake2b_malloc:Impl.blake2_malloc_st Spec.Blake2B Core.M32 let blake2b_malloc:Impl.blake2_malloc_st Spec.Blake2B Core.M32 =
false
null
false
Impl.blake2_malloc Spec.Blake2B Core.M32
{ "checked_file": "Hacl.Blake2b_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2b_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_malloc", "Spec.Blake2.Blake2B", "Hacl.Impl.Blake2.Core.M32" ]
[]
module Hacl.Blake2b_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) private let blake2b_update_block : Impl.blake2_update_block_st Spec.Blake2B Core.M32 = Impl.blake2_update_block #Spec.Blake2B #Core.M32 let blake2b_init : Impl.blake2_init_st Spec.Blake2B Core.M32 = Impl.blake2_init #Spec.Blake2B #Core.M32 let blake2b_update_key : Impl.blake2_update_key_st Spec.Blake2B Core.M32 = Impl.blake2_update_key #Spec.Blake2B #Core.M32 blake2b_update_block let blake2b_update_multi : Impl.blake2_update_multi_st Spec.Blake2B Core.M32 = Impl.blake2_update_multi #Spec.Blake2B #Core.M32 blake2b_update_block let blake2b_update_last : Impl.blake2_update_last_st Spec.Blake2B Core.M32 = Impl.blake2_update_last #Spec.Blake2B #Core.M32 blake2b_update_block private let blake2b_update_blocks : Impl.blake2_update_blocks_st Spec.Blake2B Core.M32 = Impl.blake2_update_blocks #Spec.Blake2B #Core.M32 blake2b_update_multi blake2b_update_last [@CInline] private let blake2b_update : Impl.blake2_update_st Spec.Blake2B Core.M32 = Impl.blake2_update #Spec.Blake2B #Core.M32 blake2b_update_key blake2b_update_blocks let blake2b_finish : Impl.blake2_finish_st Spec.Blake2B Core.M32 = Impl.blake2_finish #Spec.Blake2B #Core.M32 (* The one-shot hash *) [@@ Comment "Write the BLAKE2b digest of message `d` using key `k` into `output`. @param nn Length of the to-be-generated digest with 1 <= `nn` <= 64. @param output Pointer to `nn` bytes of memory where the digest is written to. @param ll Length of the input message. @param d Pointer to `ll` bytes of memory where the input message is read from. @param kk Length of the key. Can be 0. @param k Pointer to `kk` bytes of memory where the key is read from."] let blake2b : Impl.blake2_st Spec.Blake2B Core.M32 = Impl.blake2 #Spec.Blake2B #Core.M32 blake2b_init blake2b_update blake2b_finish
false
false
Hacl.Blake2b_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2b_malloc:Impl.blake2_malloc_st Spec.Blake2B Core.M32
[]
Hacl.Blake2b_32.blake2b_malloc
{ "file_name": "code/blake2/Hacl.Blake2b_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_malloc_st Spec.Blake2.Blake2B Hacl.Impl.Blake2.Core.M32
{ "end_col": 42, "end_line": 50, "start_col": 2, "start_line": 50 }
Prims.Tot
val blake2b_update_multi:Impl.blake2_update_multi_st Spec.Blake2B Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2b_update_multi : Impl.blake2_update_multi_st Spec.Blake2B Core.M32 = Impl.blake2_update_multi #Spec.Blake2B #Core.M32 blake2b_update_block
val blake2b_update_multi:Impl.blake2_update_multi_st Spec.Blake2B Core.M32 let blake2b_update_multi:Impl.blake2_update_multi_st Spec.Blake2B Core.M32 =
false
null
false
Impl.blake2_update_multi #Spec.Blake2B #Core.M32 blake2b_update_block
{ "checked_file": "Hacl.Blake2b_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2b_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_update_multi", "Spec.Blake2.Blake2B", "Hacl.Impl.Blake2.Core.M32", "Hacl.Blake2b_32.blake2b_update_block" ]
[]
module Hacl.Blake2b_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) private let blake2b_update_block : Impl.blake2_update_block_st Spec.Blake2B Core.M32 = Impl.blake2_update_block #Spec.Blake2B #Core.M32 let blake2b_init : Impl.blake2_init_st Spec.Blake2B Core.M32 = Impl.blake2_init #Spec.Blake2B #Core.M32 let blake2b_update_key : Impl.blake2_update_key_st Spec.Blake2B Core.M32 = Impl.blake2_update_key #Spec.Blake2B #Core.M32 blake2b_update_block
false
false
Hacl.Blake2b_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2b_update_multi:Impl.blake2_update_multi_st Spec.Blake2B Core.M32
[]
Hacl.Blake2b_32.blake2b_update_multi
{ "file_name": "code/blake2/Hacl.Blake2b_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_update_multi_st Spec.Blake2.Blake2B Hacl.Impl.Blake2.Core.M32
{ "end_col": 71, "end_line": 19, "start_col": 2, "start_line": 19 }
Prims.Tot
val blake2b_update_block:Impl.blake2_update_block_st Spec.Blake2B Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2b_update_block : Impl.blake2_update_block_st Spec.Blake2B Core.M32 = Impl.blake2_update_block #Spec.Blake2B #Core.M32
val blake2b_update_block:Impl.blake2_update_block_st Spec.Blake2B Core.M32 let blake2b_update_block:Impl.blake2_update_block_st Spec.Blake2B Core.M32 =
false
null
false
Impl.blake2_update_block #Spec.Blake2B #Core.M32
{ "checked_file": "Hacl.Blake2b_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2b_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_update_block", "Spec.Blake2.Blake2B", "Hacl.Impl.Blake2.Core.M32" ]
[]
module Hacl.Blake2b_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) private
false
false
Hacl.Blake2b_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2b_update_block:Impl.blake2_update_block_st Spec.Blake2B Core.M32
[]
Hacl.Blake2b_32.blake2b_update_block
{ "file_name": "code/blake2/Hacl.Blake2b_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_update_block_st Spec.Blake2.Blake2B Hacl.Impl.Blake2.Core.M32
{ "end_col": 50, "end_line": 10, "start_col": 2, "start_line": 10 }
Prims.Tot
val blake2b_update:Impl.blake2_update_st Spec.Blake2B Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2b_update : Impl.blake2_update_st Spec.Blake2B Core.M32 = Impl.blake2_update #Spec.Blake2B #Core.M32 blake2b_update_key blake2b_update_blocks
val blake2b_update:Impl.blake2_update_st Spec.Blake2B Core.M32 let blake2b_update:Impl.blake2_update_st Spec.Blake2B Core.M32 =
false
null
false
Impl.blake2_update #Spec.Blake2B #Core.M32 blake2b_update_key blake2b_update_blocks
{ "checked_file": "Hacl.Blake2b_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2b_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_update", "Spec.Blake2.Blake2B", "Hacl.Impl.Blake2.Core.M32", "Hacl.Blake2b_32.blake2b_update_key", "Hacl.Blake2b_32.blake2b_update_blocks" ]
[]
module Hacl.Blake2b_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) private let blake2b_update_block : Impl.blake2_update_block_st Spec.Blake2B Core.M32 = Impl.blake2_update_block #Spec.Blake2B #Core.M32 let blake2b_init : Impl.blake2_init_st Spec.Blake2B Core.M32 = Impl.blake2_init #Spec.Blake2B #Core.M32 let blake2b_update_key : Impl.blake2_update_key_st Spec.Blake2B Core.M32 = Impl.blake2_update_key #Spec.Blake2B #Core.M32 blake2b_update_block let blake2b_update_multi : Impl.blake2_update_multi_st Spec.Blake2B Core.M32 = Impl.blake2_update_multi #Spec.Blake2B #Core.M32 blake2b_update_block let blake2b_update_last : Impl.blake2_update_last_st Spec.Blake2B Core.M32 = Impl.blake2_update_last #Spec.Blake2B #Core.M32 blake2b_update_block private let blake2b_update_blocks : Impl.blake2_update_blocks_st Spec.Blake2B Core.M32 = Impl.blake2_update_blocks #Spec.Blake2B #Core.M32 blake2b_update_multi blake2b_update_last [@CInline] private
false
false
Hacl.Blake2b_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2b_update:Impl.blake2_update_st Spec.Blake2B Core.M32
[]
Hacl.Blake2b_32.blake2b_update
{ "file_name": "code/blake2/Hacl.Blake2b_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_update_st Spec.Blake2.Blake2B Hacl.Impl.Blake2.Core.M32
{ "end_col": 85, "end_line": 31, "start_col": 2, "start_line": 31 }
Prims.Tot
val blake2b_update_last:Impl.blake2_update_last_st Spec.Blake2B Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2b_update_last : Impl.blake2_update_last_st Spec.Blake2B Core.M32 = Impl.blake2_update_last #Spec.Blake2B #Core.M32 blake2b_update_block
val blake2b_update_last:Impl.blake2_update_last_st Spec.Blake2B Core.M32 let blake2b_update_last:Impl.blake2_update_last_st Spec.Blake2B Core.M32 =
false
null
false
Impl.blake2_update_last #Spec.Blake2B #Core.M32 blake2b_update_block
{ "checked_file": "Hacl.Blake2b_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2b_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_update_last", "Spec.Blake2.Blake2B", "Hacl.Impl.Blake2.Core.M32", "Hacl.Blake2b_32.blake2b_update_block" ]
[]
module Hacl.Blake2b_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) private let blake2b_update_block : Impl.blake2_update_block_st Spec.Blake2B Core.M32 = Impl.blake2_update_block #Spec.Blake2B #Core.M32 let blake2b_init : Impl.blake2_init_st Spec.Blake2B Core.M32 = Impl.blake2_init #Spec.Blake2B #Core.M32 let blake2b_update_key : Impl.blake2_update_key_st Spec.Blake2B Core.M32 = Impl.blake2_update_key #Spec.Blake2B #Core.M32 blake2b_update_block let blake2b_update_multi : Impl.blake2_update_multi_st Spec.Blake2B Core.M32 = Impl.blake2_update_multi #Spec.Blake2B #Core.M32 blake2b_update_block
false
false
Hacl.Blake2b_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2b_update_last:Impl.blake2_update_last_st Spec.Blake2B Core.M32
[]
Hacl.Blake2b_32.blake2b_update_last
{ "file_name": "code/blake2/Hacl.Blake2b_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_update_last_st Spec.Blake2.Blake2B Hacl.Impl.Blake2.Core.M32
{ "end_col": 70, "end_line": 22, "start_col": 2, "start_line": 22 }
Prims.Tot
val blake2b_finish:Impl.blake2_finish_st Spec.Blake2B Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2b_finish : Impl.blake2_finish_st Spec.Blake2B Core.M32 = Impl.blake2_finish #Spec.Blake2B #Core.M32
val blake2b_finish:Impl.blake2_finish_st Spec.Blake2B Core.M32 let blake2b_finish:Impl.blake2_finish_st Spec.Blake2B Core.M32 =
false
null
false
Impl.blake2_finish #Spec.Blake2B #Core.M32
{ "checked_file": "Hacl.Blake2b_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2b_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_finish", "Spec.Blake2.Blake2B", "Hacl.Impl.Blake2.Core.M32" ]
[]
module Hacl.Blake2b_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) private let blake2b_update_block : Impl.blake2_update_block_st Spec.Blake2B Core.M32 = Impl.blake2_update_block #Spec.Blake2B #Core.M32 let blake2b_init : Impl.blake2_init_st Spec.Blake2B Core.M32 = Impl.blake2_init #Spec.Blake2B #Core.M32 let blake2b_update_key : Impl.blake2_update_key_st Spec.Blake2B Core.M32 = Impl.blake2_update_key #Spec.Blake2B #Core.M32 blake2b_update_block let blake2b_update_multi : Impl.blake2_update_multi_st Spec.Blake2B Core.M32 = Impl.blake2_update_multi #Spec.Blake2B #Core.M32 blake2b_update_block let blake2b_update_last : Impl.blake2_update_last_st Spec.Blake2B Core.M32 = Impl.blake2_update_last #Spec.Blake2B #Core.M32 blake2b_update_block private let blake2b_update_blocks : Impl.blake2_update_blocks_st Spec.Blake2B Core.M32 = Impl.blake2_update_blocks #Spec.Blake2B #Core.M32 blake2b_update_multi blake2b_update_last [@CInline] private let blake2b_update : Impl.blake2_update_st Spec.Blake2B Core.M32 = Impl.blake2_update #Spec.Blake2B #Core.M32 blake2b_update_key blake2b_update_blocks
false
false
Hacl.Blake2b_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2b_finish:Impl.blake2_finish_st Spec.Blake2B Core.M32
[]
Hacl.Blake2b_32.blake2b_finish
{ "file_name": "code/blake2/Hacl.Blake2b_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_finish_st Spec.Blake2.Blake2B Hacl.Impl.Blake2.Core.M32
{ "end_col": 44, "end_line": 34, "start_col": 2, "start_line": 34 }
Prims.Tot
val blake2b_update_blocks:Impl.blake2_update_blocks_st Spec.Blake2B Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2b_update_blocks : Impl.blake2_update_blocks_st Spec.Blake2B Core.M32 = Impl.blake2_update_blocks #Spec.Blake2B #Core.M32 blake2b_update_multi blake2b_update_last
val blake2b_update_blocks:Impl.blake2_update_blocks_st Spec.Blake2B Core.M32 let blake2b_update_blocks:Impl.blake2_update_blocks_st Spec.Blake2B Core.M32 =
false
null
false
Impl.blake2_update_blocks #Spec.Blake2B #Core.M32 blake2b_update_multi blake2b_update_last
{ "checked_file": "Hacl.Blake2b_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2b_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_update_blocks", "Spec.Blake2.Blake2B", "Hacl.Impl.Blake2.Core.M32", "Hacl.Blake2b_32.blake2b_update_multi", "Hacl.Blake2b_32.blake2b_update_last" ]
[]
module Hacl.Blake2b_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) private let blake2b_update_block : Impl.blake2_update_block_st Spec.Blake2B Core.M32 = Impl.blake2_update_block #Spec.Blake2B #Core.M32 let blake2b_init : Impl.blake2_init_st Spec.Blake2B Core.M32 = Impl.blake2_init #Spec.Blake2B #Core.M32 let blake2b_update_key : Impl.blake2_update_key_st Spec.Blake2B Core.M32 = Impl.blake2_update_key #Spec.Blake2B #Core.M32 blake2b_update_block let blake2b_update_multi : Impl.blake2_update_multi_st Spec.Blake2B Core.M32 = Impl.blake2_update_multi #Spec.Blake2B #Core.M32 blake2b_update_block let blake2b_update_last : Impl.blake2_update_last_st Spec.Blake2B Core.M32 = Impl.blake2_update_last #Spec.Blake2B #Core.M32 blake2b_update_block private
false
false
Hacl.Blake2b_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2b_update_blocks:Impl.blake2_update_blocks_st Spec.Blake2B Core.M32
[]
Hacl.Blake2b_32.blake2b_update_blocks
{ "file_name": "code/blake2/Hacl.Blake2b_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_update_blocks_st Spec.Blake2.Blake2B Hacl.Impl.Blake2.Core.M32
{ "end_col": 92, "end_line": 26, "start_col": 2, "start_line": 26 }
Prims.Tot
val blake2b_init:Impl.blake2_init_st Spec.Blake2B Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2b_init : Impl.blake2_init_st Spec.Blake2B Core.M32 = Impl.blake2_init #Spec.Blake2B #Core.M32
val blake2b_init:Impl.blake2_init_st Spec.Blake2B Core.M32 let blake2b_init:Impl.blake2_init_st Spec.Blake2B Core.M32 =
false
null
false
Impl.blake2_init #Spec.Blake2B #Core.M32
{ "checked_file": "Hacl.Blake2b_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2b_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_init", "Spec.Blake2.Blake2B", "Hacl.Impl.Blake2.Core.M32" ]
[]
module Hacl.Blake2b_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) private let blake2b_update_block : Impl.blake2_update_block_st Spec.Blake2B Core.M32 = Impl.blake2_update_block #Spec.Blake2B #Core.M32
false
false
Hacl.Blake2b_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2b_init:Impl.blake2_init_st Spec.Blake2B Core.M32
[]
Hacl.Blake2b_32.blake2b_init
{ "file_name": "code/blake2/Hacl.Blake2b_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_init_st Spec.Blake2.Blake2B Hacl.Impl.Blake2.Core.M32
{ "end_col": 42, "end_line": 13, "start_col": 2, "start_line": 13 }
Prims.Tot
val blake2b:Impl.blake2_st Spec.Blake2B Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2b : Impl.blake2_st Spec.Blake2B Core.M32 = Impl.blake2 #Spec.Blake2B #Core.M32 blake2b_init blake2b_update blake2b_finish
val blake2b:Impl.blake2_st Spec.Blake2B Core.M32 let blake2b:Impl.blake2_st Spec.Blake2B Core.M32 =
true
null
false
Impl.blake2 #Spec.Blake2B #Core.M32 blake2b_init blake2b_update blake2b_finish
{ "checked_file": "Hacl.Blake2b_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2b_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2", "Spec.Blake2.Blake2B", "Hacl.Impl.Blake2.Core.M32", "Hacl.Blake2b_32.blake2b_init", "Hacl.Blake2b_32.blake2b_update", "Hacl.Blake2b_32.blake2b_finish" ]
[]
module Hacl.Blake2b_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) private let blake2b_update_block : Impl.blake2_update_block_st Spec.Blake2B Core.M32 = Impl.blake2_update_block #Spec.Blake2B #Core.M32 let blake2b_init : Impl.blake2_init_st Spec.Blake2B Core.M32 = Impl.blake2_init #Spec.Blake2B #Core.M32 let blake2b_update_key : Impl.blake2_update_key_st Spec.Blake2B Core.M32 = Impl.blake2_update_key #Spec.Blake2B #Core.M32 blake2b_update_block let blake2b_update_multi : Impl.blake2_update_multi_st Spec.Blake2B Core.M32 = Impl.blake2_update_multi #Spec.Blake2B #Core.M32 blake2b_update_block let blake2b_update_last : Impl.blake2_update_last_st Spec.Blake2B Core.M32 = Impl.blake2_update_last #Spec.Blake2B #Core.M32 blake2b_update_block private let blake2b_update_blocks : Impl.blake2_update_blocks_st Spec.Blake2B Core.M32 = Impl.blake2_update_blocks #Spec.Blake2B #Core.M32 blake2b_update_multi blake2b_update_last [@CInline] private let blake2b_update : Impl.blake2_update_st Spec.Blake2B Core.M32 = Impl.blake2_update #Spec.Blake2B #Core.M32 blake2b_update_key blake2b_update_blocks let blake2b_finish : Impl.blake2_finish_st Spec.Blake2B Core.M32 = Impl.blake2_finish #Spec.Blake2B #Core.M32 (* The one-shot hash *) [@@ Comment "Write the BLAKE2b digest of message `d` using key `k` into `output`. @param nn Length of the to-be-generated digest with 1 <= `nn` <= 64. @param output Pointer to `nn` bytes of memory where the digest is written to. @param ll Length of the input message. @param d Pointer to `ll` bytes of memory where the input message is read from. @param kk Length of the key. Can be 0. @param k Pointer to `kk` bytes of memory where the key is read from."]
false
false
Hacl.Blake2b_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2b:Impl.blake2_st Spec.Blake2B Core.M32
[]
Hacl.Blake2b_32.blake2b
{ "file_name": "code/blake2/Hacl.Blake2b_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_st Spec.Blake2.Blake2B Hacl.Impl.Blake2.Core.M32
{ "end_col": 80, "end_line": 47, "start_col": 2, "start_line": 47 }
Prims.Tot
val raise_frame_preserving_upd (#a: _) (#p: pcm a) (#x #y: a) (f: frame_preserving_upd p x y) : frame_preserving_upd (raise p) (raise_val x) (raise_val y)
[ { "abbrev": false, "full_module": "FStar.Classical.Sugar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let raise_frame_preserving_upd #a (#p:pcm a) (#x #y:a) (f:frame_preserving_upd p x y) : frame_preserving_upd (raise p) (raise_val x) (raise_val y) = fun v -> let u = f (downgrade_val v) in let v_new = raise_val u in assert (forall frame. composable p y frame ==> composable (raise p) (raise_val y) (raise_val frame)); assert (forall frame. composable (raise p) (raise_val x) frame ==> composable p x (downgrade_val frame)); v_new
val raise_frame_preserving_upd (#a: _) (#p: pcm a) (#x #y: a) (f: frame_preserving_upd p x y) : frame_preserving_upd (raise p) (raise_val x) (raise_val y) let raise_frame_preserving_upd #a (#p: pcm a) (#x: a) (#y: a) (f: frame_preserving_upd p x y) : frame_preserving_upd (raise p) (raise_val x) (raise_val y) =
false
null
false
fun v -> let u = f (downgrade_val v) in let v_new = raise_val u in assert (forall frame. composable p y frame ==> composable (raise p) (raise_val y) (raise_val frame)); assert (forall frame. composable (raise p) (raise_val x) frame ==> composable p x (downgrade_val frame)); v_new
{ "checked_file": "FStar.Universe.PCM.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Universe.PCM.fst" }
[ "total" ]
[ "FStar.PCM.pcm", "FStar.PCM.frame_preserving_upd", "FStar.Universe.raise_t", "Prims.l_and", "FStar.PCM.__proj__Mkpcm__item__refine", "FStar.Universe.PCM.raise", "FStar.PCM.compatible", "FStar.Universe.raise_val", "Prims.unit", "Prims._assert", "Prims.l_Forall", "Prims.l_imp", "FStar.PCM.composable", "FStar.Universe.downgrade_val", "Prims.eq2", "FStar.PCM.op" ]
[]
(* Copyright 2021 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. Author: N. Swamy *) module FStar.Universe.PCM (* Lift a PCM to a higher universe, including its frame-preserving updates *) open FStar.PCM open FStar.Universe open FStar.Classical.Sugar let raise (#a:Type) (p:pcm a) : pcm (raise_t u#a u#b a) = { p = { composable = (fun x y -> p.p.composable (downgrade_val x) (downgrade_val y)); op = (fun x y -> raise_val (p.p.op (downgrade_val x) (downgrade_val y))); one = raise_val p.p.one; }; comm = (fun x y -> p.comm (downgrade_val x) (downgrade_val y)); assoc = (fun x y z -> p.assoc (downgrade_val x) (downgrade_val y) (downgrade_val z)); assoc_r = (fun x y z -> p.assoc_r (downgrade_val x) (downgrade_val y) (downgrade_val z)); is_unit = (fun x -> p.is_unit (downgrade_val x)); refine = (fun x -> p.refine (downgrade_val x)); } let raise_frame_preserving_upd #a (#p:pcm a) (#x #y:a) (f:frame_preserving_upd p x y)
false
false
FStar.Universe.PCM.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val raise_frame_preserving_upd (#a: _) (#p: pcm a) (#x #y: a) (f: frame_preserving_upd p x y) : frame_preserving_upd (raise p) (raise_val x) (raise_val y)
[]
FStar.Universe.PCM.raise_frame_preserving_upd
{ "file_name": "ulib/experimental/FStar.Universe.PCM.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: FStar.PCM.frame_preserving_upd p x y -> FStar.PCM.frame_preserving_upd (FStar.Universe.PCM.raise p) (FStar.Universe.raise_val x) (FStar.Universe.raise_val y)
{ "end_col": 11, "end_line": 46, "start_col": 4, "start_line": 41 }
Prims.Tot
val raise (#a: Type) (p: pcm a) : pcm (raise_t u#a u#b a)
[ { "abbrev": false, "full_module": "FStar.Classical.Sugar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let raise (#a:Type) (p:pcm a) : pcm (raise_t u#a u#b a) = { p = { composable = (fun x y -> p.p.composable (downgrade_val x) (downgrade_val y)); op = (fun x y -> raise_val (p.p.op (downgrade_val x) (downgrade_val y))); one = raise_val p.p.one; }; comm = (fun x y -> p.comm (downgrade_val x) (downgrade_val y)); assoc = (fun x y z -> p.assoc (downgrade_val x) (downgrade_val y) (downgrade_val z)); assoc_r = (fun x y z -> p.assoc_r (downgrade_val x) (downgrade_val y) (downgrade_val z)); is_unit = (fun x -> p.is_unit (downgrade_val x)); refine = (fun x -> p.refine (downgrade_val x)); }
val raise (#a: Type) (p: pcm a) : pcm (raise_t u#a u#b a) let raise (#a: Type) (p: pcm a) : pcm (raise_t u#a u#b a) =
false
null
false
{ p = { composable = (fun x y -> p.p.composable (downgrade_val x) (downgrade_val y)); op = (fun x y -> raise_val (p.p.op (downgrade_val x) (downgrade_val y))); one = raise_val p.p.one }; comm = (fun x y -> p.comm (downgrade_val x) (downgrade_val y)); assoc = (fun x y z -> p.assoc (downgrade_val x) (downgrade_val y) (downgrade_val z)); assoc_r = (fun x y z -> p.assoc_r (downgrade_val x) (downgrade_val y) (downgrade_val z)); is_unit = (fun x -> p.is_unit (downgrade_val x)); refine = (fun x -> p.refine (downgrade_val x)) }
{ "checked_file": "FStar.Universe.PCM.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Universe.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": false, "source_file": "FStar.Universe.PCM.fst" }
[ "total" ]
[ "FStar.PCM.pcm", "FStar.PCM.Mkpcm", "FStar.Universe.raise_t", "FStar.PCM.Mkpcm'", "FStar.PCM.__proj__Mkpcm'__item__composable", "FStar.PCM.__proj__Mkpcm__item__p", "FStar.Universe.downgrade_val", "Prims.prop", "FStar.Universe.raise_val", "FStar.PCM.__proj__Mkpcm'__item__op", "FStar.PCM.__proj__Mkpcm'__item__one", "FStar.PCM.__proj__Mkpcm__item__comm", "Prims.unit", "Prims.l_and", "FStar.PCM.__proj__Mkpcm__item__assoc", "FStar.PCM.__proj__Mkpcm__item__assoc_r", "FStar.PCM.__proj__Mkpcm__item__is_unit", "FStar.PCM.__proj__Mkpcm__item__refine" ]
[]
(* Copyright 2021 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. Author: N. Swamy *) module FStar.Universe.PCM (* Lift a PCM to a higher universe, including its frame-preserving updates *) open FStar.PCM open FStar.Universe open FStar.Classical.Sugar let raise (#a:Type) (p:pcm a) : pcm (raise_t u#a u#b a)
false
false
FStar.Universe.PCM.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val raise (#a: Type) (p: pcm a) : pcm (raise_t u#a u#b a)
[]
FStar.Universe.PCM.raise
{ "file_name": "ulib/experimental/FStar.Universe.PCM.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
p: FStar.PCM.pcm a -> FStar.PCM.pcm (FStar.Universe.raise_t a)
{ "end_col": 53, "end_line": 36, "start_col": 6, "start_line": 27 }
Prims.Tot
val shift_gf128_key_1 (h: poly) : poly
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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 } ]
false
let shift_gf128_key_1 (h:poly) : poly = shift_key_1 128 gf128_modulus_low_terms h
val shift_gf128_key_1 (h: poly) : poly let shift_gf128_key_1 (h: poly) : poly =
false
null
false
shift_key_1 128 gf128_modulus_low_terms h
{ "checked_file": "Vale.AES.OptPublic.fst.checked", "dependencies": [ "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Vale.AES.OptPublic.fst" }
[ "total" ]
[ "Vale.Math.Poly2_s.poly", "Vale.AES.GF128.shift_key_1", "Vale.AES.GF128_s.gf128_modulus_low_terms" ]
[]
module Vale.AES.OptPublic open FStar.Mul open FStar.Seq open Vale.Def.Types_s open Vale.Math.Poly2_s open Vale.Math.Poly2.Bits_s open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Def.Words_s
false
true
Vale.AES.OptPublic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val shift_gf128_key_1 (h: poly) : poly
[]
Vale.AES.OptPublic.shift_gf128_key_1
{ "file_name": "vale/code/crypto/aes/Vale.AES.OptPublic.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.Math.Poly2_s.poly -> Vale.Math.Poly2_s.poly
{ "end_col": 43, "end_line": 13, "start_col": 2, "start_line": 13 }
Prims.Tot
val gf128_power (h: poly) (n: nat) : poly
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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 } ]
false
let gf128_power (h:poly) (n:nat) : poly = shift_gf128_key_1 (g_power h n)
val gf128_power (h: poly) (n: nat) : poly let gf128_power (h: poly) (n: nat) : poly =
false
null
false
shift_gf128_key_1 (g_power h n)
{ "checked_file": "Vale.AES.OptPublic.fst.checked", "dependencies": [ "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Vale.AES.OptPublic.fst" }
[ "total" ]
[ "Vale.Math.Poly2_s.poly", "Prims.nat", "Vale.AES.OptPublic.shift_gf128_key_1", "Vale.AES.OptPublic.g_power" ]
[]
module Vale.AES.OptPublic open FStar.Mul open FStar.Seq open Vale.Def.Types_s open Vale.Math.Poly2_s open Vale.Math.Poly2.Bits_s open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Def.Words_s let shift_gf128_key_1 (h:poly) : poly = shift_key_1 128 gf128_modulus_low_terms h let rec g_power (a:poly) (n:nat) : poly = if n = 0 then zero else // arbitrary value for n = 0 if n = 1 then a else a *~ g_power a (n - 1)
false
true
Vale.AES.OptPublic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gf128_power (h: poly) (n: nat) : poly
[]
Vale.AES.OptPublic.gf128_power
{ "file_name": "vale/code/crypto/aes/Vale.AES.OptPublic.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h: Vale.Math.Poly2_s.poly -> n: Prims.nat -> Vale.Math.Poly2_s.poly
{ "end_col": 73, "end_line": 20, "start_col": 42, "start_line": 20 }
FStar.Pervasives.Lemma
val lemma_of_quad32_inj (q q': quad32) : Lemma (requires of_quad32 q == of_quad32 q') (ensures q == q')
[ { "abbrev": false, "full_module": "FStar.UInt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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 } ]
false
let lemma_of_quad32_inj (q q':quad32) : Lemma (requires of_quad32 q == of_quad32 q') (ensures q == q') = lemma_to_of_quad32 q; lemma_to_of_quad32 q'
val lemma_of_quad32_inj (q q': quad32) : Lemma (requires of_quad32 q == of_quad32 q') (ensures q == q') let lemma_of_quad32_inj (q q': quad32) : Lemma (requires of_quad32 q == of_quad32 q') (ensures q == q') =
false
null
true
lemma_to_of_quad32 q; lemma_to_of_quad32 q'
{ "checked_file": "Vale.AES.OptPublic.fst.checked", "dependencies": [ "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Vale.AES.OptPublic.fst" }
[ "lemma" ]
[ "Vale.Def.Types_s.quad32", "Vale.Math.Poly2.Bits.lemma_to_of_quad32", "Prims.unit", "Prims.eq2", "Vale.Math.Poly2_s.poly", "Vale.Math.Poly2.Bits_s.of_quad32", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Vale.AES.OptPublic open FStar.Mul open FStar.Seq open Vale.Def.Types_s open Vale.Math.Poly2_s open Vale.Math.Poly2.Bits_s open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Def.Words_s let shift_gf128_key_1 (h:poly) : poly = shift_key_1 128 gf128_modulus_low_terms h let rec g_power (a:poly) (n:nat) : poly = if n = 0 then zero else // arbitrary value for n = 0 if n = 1 then a else a *~ g_power a (n - 1) let gf128_power (h:poly) (n:nat) : poly = shift_gf128_key_1 (g_power h n) let hkeys_reqs_pub (hkeys:seq quad32) (h_BE:quad32) : Vale.Def.Prop_s.prop0 = let h = of_quad32 (reverse_bytes_quad32 (reverse_bytes_quad32 h_BE)) in length hkeys >= 8 /\ of_quad32 (index hkeys 0) == gf128_power h 1 /\ of_quad32 (index hkeys 1) == gf128_power h 2 /\ index hkeys 2 == h_BE /\ of_quad32 (index hkeys 3) == gf128_power h 3 /\ of_quad32 (index hkeys 4) == gf128_power h 4 /\ index hkeys 5 == Mkfour 0 0 0 0 /\ // Not needed but we want injectivity of_quad32 (index hkeys 6) == gf128_power h 5 /\ of_quad32 (index hkeys 7) == gf128_power h 6 #set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" open FStar.List.Tot open Vale.Math.Poly2.Bits let get_hkeys_reqs h_BE = let h = of_quad32 (reverse_bytes_quad32 (reverse_bytes_quad32 h_BE)) in let l = [to_quad32 (gf128_power h 1); to_quad32 (gf128_power h 2); h_BE; to_quad32 (gf128_power h 3); to_quad32 (gf128_power h 4); Mkfour 0 0 0 0; to_quad32 (gf128_power h 5); to_quad32 (gf128_power h 6)] in assert_norm (length l = 8); let s = Seq.seq_of_list l in Seq.lemma_seq_of_list_induction l; Seq.lemma_seq_of_list_induction (tl l); Seq.lemma_seq_of_list_induction (tl (tl l)); Seq.lemma_seq_of_list_induction (tl (tl (tl l))); Seq.lemma_seq_of_list_induction (tl (tl (tl (tl l)))); Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl l))))); Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl (tl l)))))); Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl (tl (tl l))))))); Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl (tl (tl (tl l)))))))); lemma_of_to_quad32 (gf128_power h 1); lemma_of_to_quad32 (gf128_power h 2); lemma_of_to_quad32 (gf128_power h 3); lemma_of_to_quad32 (gf128_power h 4); lemma_of_to_quad32 (gf128_power h 5); lemma_of_to_quad32 (gf128_power h 6); assert (hkeys_reqs_pub s h_BE); s open FStar.UInt let lemma_of_quad32_inj (q q':quad32) : Lemma (requires of_quad32 q == of_quad32 q')
false
false
Vale.AES.OptPublic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "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": 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" }
null
val lemma_of_quad32_inj (q q': quad32) : Lemma (requires of_quad32 q == of_quad32 q') (ensures q == q')
[]
Vale.AES.OptPublic.lemma_of_quad32_inj
{ "file_name": "vale/code/crypto/aes/Vale.AES.OptPublic.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: Vale.Def.Types_s.quad32 -> q': Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.Math.Poly2.Bits_s.of_quad32 q == Vale.Math.Poly2.Bits_s.of_quad32 q') (ensures q == q')
{ "end_col": 47, "end_line": 75, "start_col": 4, "start_line": 75 }
Prims.Tot
val g_power (a: poly) (n: nat) : poly
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "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 } ]
false
let rec g_power (a:poly) (n:nat) : poly = if n = 0 then zero else // arbitrary value for n = 0 if n = 1 then a else a *~ g_power a (n - 1)
val g_power (a: poly) (n: nat) : poly let rec g_power (a: poly) (n: nat) : poly =
false
null
false
if n = 0 then zero else if n = 1 then a else a *~ g_power a (n - 1)
{ "checked_file": "Vale.AES.OptPublic.fst.checked", "dependencies": [ "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Vale.AES.OptPublic.fst" }
[ "total" ]
[ "Vale.Math.Poly2_s.poly", "Prims.nat", "Prims.op_Equality", "Prims.int", "Vale.Math.Poly2_s.zero", "Prims.bool", "Vale.AES.GF128.op_Star_Tilde", "Vale.AES.OptPublic.g_power", "Prims.op_Subtraction" ]
[]
module Vale.AES.OptPublic open FStar.Mul open FStar.Seq open Vale.Def.Types_s open Vale.Math.Poly2_s open Vale.Math.Poly2.Bits_s open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Def.Words_s let shift_gf128_key_1 (h:poly) : poly = shift_key_1 128 gf128_modulus_low_terms h
false
true
Vale.AES.OptPublic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val g_power (a: poly) (n: nat) : poly
[ "recursion" ]
Vale.AES.OptPublic.g_power
{ "file_name": "vale/code/crypto/aes/Vale.AES.OptPublic.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Vale.Math.Poly2_s.poly -> n: Prims.nat -> Vale.Math.Poly2_s.poly
{ "end_col": 24, "end_line": 18, "start_col": 2, "start_line": 16 }
Prims.Tot
val hkeys_reqs_pub (hkeys:FStar.Seq.seq quad32) (h_BE:quad32) : Vale.Def.Prop_s.prop0
[ { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_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": "FStar.Mul", "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 } ]
false
let hkeys_reqs_pub (hkeys:seq quad32) (h_BE:quad32) : Vale.Def.Prop_s.prop0 = let h = of_quad32 (reverse_bytes_quad32 (reverse_bytes_quad32 h_BE)) in length hkeys >= 8 /\ of_quad32 (index hkeys 0) == gf128_power h 1 /\ of_quad32 (index hkeys 1) == gf128_power h 2 /\ index hkeys 2 == h_BE /\ of_quad32 (index hkeys 3) == gf128_power h 3 /\ of_quad32 (index hkeys 4) == gf128_power h 4 /\ index hkeys 5 == Mkfour 0 0 0 0 /\ // Not needed but we want injectivity of_quad32 (index hkeys 6) == gf128_power h 5 /\ of_quad32 (index hkeys 7) == gf128_power h 6
val hkeys_reqs_pub (hkeys:FStar.Seq.seq quad32) (h_BE:quad32) : Vale.Def.Prop_s.prop0 let hkeys_reqs_pub (hkeys: seq quad32) (h_BE: quad32) : Vale.Def.Prop_s.prop0 =
false
null
false
let h = of_quad32 (reverse_bytes_quad32 (reverse_bytes_quad32 h_BE)) in length hkeys >= 8 /\ of_quad32 (index hkeys 0) == gf128_power h 1 /\ of_quad32 (index hkeys 1) == gf128_power h 2 /\ index hkeys 2 == h_BE /\ of_quad32 (index hkeys 3) == gf128_power h 3 /\ of_quad32 (index hkeys 4) == gf128_power h 4 /\ index hkeys 5 == Mkfour 0 0 0 0 /\ of_quad32 (index hkeys 6) == gf128_power h 5 /\ of_quad32 (index hkeys 7) == gf128_power h 6
{ "checked_file": "Vale.AES.OptPublic.fst.checked", "dependencies": [ "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Vale.AES.OptPublic.fst" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.Seq.Base.length", "Prims.eq2", "Vale.Math.Poly2_s.poly", "Vale.Math.Poly2.Bits_s.of_quad32", "FStar.Seq.Base.index", "Vale.AES.OptPublic.gf128_power", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.Def.Prop_s.prop0" ]
[]
module Vale.AES.OptPublic open FStar.Mul open FStar.Seq open Vale.Def.Types_s open Vale.Math.Poly2_s open Vale.Math.Poly2.Bits_s open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Def.Words_s let shift_gf128_key_1 (h:poly) : poly = shift_key_1 128 gf128_modulus_low_terms h let rec g_power (a:poly) (n:nat) : poly = if n = 0 then zero else // arbitrary value for n = 0 if n = 1 then a else a *~ g_power a (n - 1) let gf128_power (h:poly) (n:nat) : poly = shift_gf128_key_1 (g_power h n)
false
true
Vale.AES.OptPublic.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val hkeys_reqs_pub (hkeys:FStar.Seq.seq quad32) (h_BE:quad32) : Vale.Def.Prop_s.prop0
[]
Vale.AES.OptPublic.hkeys_reqs_pub
{ "file_name": "vale/code/crypto/aes/Vale.AES.OptPublic.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
hkeys: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> h_BE: Vale.Def.Types_s.quad32 -> Vale.Def.Prop_s.prop0
{ "end_col": 46, "end_line": 33, "start_col": 3, "start_line": 23 }