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 uint64_to_int64: a:U64.t -> Tot (b:I64.t{I64.v b = (U64.v a @% pow2 64)})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint64_to_int64 x = I64.int_to_t (U64.v x @% pow2 64)
val uint64_to_int64: a:U64.t -> Tot (b:I64.t{I64.v b = (U64.v a @% pow2 64)}) let uint64_to_int64 x =
false
null
false
I64.int_to_t (U64.v x @% pow2 64)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.UInt64.t", "FStar.Int64.int_to_t", "FStar.Int.Cast.op_At_Percent", "FStar.UInt64.v", "Prims.pow2", "FStar.Int64.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Int64.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x) val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x = I32.int_to_t (U8.v x) val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a}) let uint8_to_int16 x = I16.int_to_t (U8.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint8_to_int8 : a:U8.t -> Tot (b:I8.t {I8.v b = (U8.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint8_to_int8 x = I8.int_to_t (U8.v x @% pow2 8) val uint16_to_int64: a:U16.t -> Tot (b:I64.t{I64.v b = U16.v a}) let uint16_to_int64 x = I64.int_to_t (U16.v x) val uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a}) let uint16_to_int32 x = I32.int_to_t (U16.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int16 x = I16.int_to_t (U16.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int8 : a:U16.t -> Tot (b:I8.t {I8.v b = (U16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int8 x = I8.int_to_t (U16.v x @% pow2 8) val uint32_to_int64: a:U32.t -> Tot (b:I64.t{I64.v b = U32.v a}) let uint32_to_int64 x = I64.int_to_t (U32.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int32: a:U32.t -> Tot (b:I32.t{I32.v b = (U32.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int32 x = I32.int_to_t (U32.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int16: a:U32.t -> Tot (b:I16.t{I16.v b = (U32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int16 x = I16.int_to_t (U32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int8 : a:U32.t -> Tot (b:I8.t {I8.v b = (U32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int8 x = I8.int_to_t (U32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int64: a:U64.t -> Tot (b:I64.t{I64.v b = (U64.v a @% pow2 64)})
false
false
FStar.Int.Cast.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 uint64_to_int64: a:U64.t -> Tot (b:I64.t{I64.v b = (U64.v a @% pow2 64)})
[]
FStar.Int.Cast.uint64_to_int64
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.Int64.t{FStar.Int64.v b = FStar.UInt64.v a @% Prims.pow2 64}
{ "end_col": 57, "end_line": 170, "start_col": 24, "start_line": 170 }
Prims.Tot
val int64_to_uint32: a:I64.t -> Tot (b:U32.t{U32.v b = I64.v a % pow2 32})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int64_to_uint32 x = U32.uint_to_t (I64.v x % pow2 32)
val int64_to_uint32: a:I64.t -> Tot (b:U32.t{U32.v b = I64.v a % pow2 32}) let int64_to_uint32 x =
false
null
false
U32.uint_to_t (I64.v x % pow2 32)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.Int64.t", "FStar.UInt32.uint_to_t", "Prims.op_Modulus", "FStar.Int64.v", "Prims.pow2", "FStar.UInt32.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.UInt32.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x) val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x = I32.int_to_t (U8.v x) val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a}) let uint8_to_int16 x = I16.int_to_t (U8.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint8_to_int8 : a:U8.t -> Tot (b:I8.t {I8.v b = (U8.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint8_to_int8 x = I8.int_to_t (U8.v x @% pow2 8) val uint16_to_int64: a:U16.t -> Tot (b:I64.t{I64.v b = U16.v a}) let uint16_to_int64 x = I64.int_to_t (U16.v x) val uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a}) let uint16_to_int32 x = I32.int_to_t (U16.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int16 x = I16.int_to_t (U16.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int8 : a:U16.t -> Tot (b:I8.t {I8.v b = (U16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int8 x = I8.int_to_t (U16.v x @% pow2 8) val uint32_to_int64: a:U32.t -> Tot (b:I64.t{I64.v b = U32.v a}) let uint32_to_int64 x = I64.int_to_t (U32.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int32: a:U32.t -> Tot (b:I32.t{I32.v b = (U32.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int32 x = I32.int_to_t (U32.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int16: a:U32.t -> Tot (b:I16.t{I16.v b = (U32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int16 x = I16.int_to_t (U32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int8 : a:U32.t -> Tot (b:I8.t {I8.v b = (U32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int8 x = I8.int_to_t (U32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int64: a:U64.t -> Tot (b:I64.t{I64.v b = (U64.v a @% pow2 64)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int64 x = I64.int_to_t (U64.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int32: a:U64.t -> Tot (b:I32.t{I32.v b = (U64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int32 x = I32.int_to_t (U64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int16: a:U64.t -> Tot (b:I16.t{I16.v b = (U64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int16 x = I16.int_to_t (U64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int8 : a:U64.t -> Tot (b:I8.t {I8.v b = (U64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int8 x = I8.int_to_t (U64.v x @% pow2 8) /// Signed to unsigned val int8_to_uint64: a:I8.t -> Tot (b:U64.t{U64.v b = I8.v a % pow2 64}) let int8_to_uint64 x = U64.uint_to_t (I8.v x % pow2 64) val int8_to_uint32: a:I8.t -> Tot (b:U32.t{U32.v b = I8.v a % pow2 32}) let int8_to_uint32 x = U32.uint_to_t (I8.v x % pow2 32) val int8_to_uint16: a:I8.t -> Tot (b:U16.t{U16.v b = I8.v a % pow2 16}) let int8_to_uint16 x = U16.uint_to_t (I8.v x % pow2 16) val int8_to_uint8 : a:I8.t -> Tot (b:U8.t {U8.v b = I8.v a % pow2 8}) let int8_to_uint8 x = U8.uint_to_t (I8.v x % pow2 8) val int16_to_uint64: a:I16.t -> Tot (b:U64.t{U64.v b = I16.v a % pow2 64}) let int16_to_uint64 x = U64.uint_to_t (I16.v x % pow2 64) val int16_to_uint32: a:I16.t -> Tot (b:U32.t{U32.v b = I16.v a % pow2 32}) let int16_to_uint32 x = U32.uint_to_t (I16.v x % pow2 32) val int16_to_uint16: a:I16.t -> Tot (b:U16.t{U16.v b = I16.v a % pow2 16}) let int16_to_uint16 x = U16.uint_to_t (I16.v x % pow2 16) val int16_to_uint8 : a:I16.t -> Tot (b:U8.t {U8.v b = I16.v a % pow2 8}) let int16_to_uint8 x = U8.uint_to_t (I16.v x % pow2 8) val int32_to_uint64: a:I32.t -> Tot (b:U64.t{U64.v b = I32.v a % pow2 64}) let int32_to_uint64 x = U64.uint_to_t (I32.v x % pow2 64) val int32_to_uint32: a:I32.t -> Tot (b:U32.t{U32.v b = I32.v a % pow2 32}) let int32_to_uint32 x = U32.uint_to_t (I32.v x % pow2 32) val int32_to_uint16: a:I32.t -> Tot (b:U16.t{U16.v b = I32.v a % pow2 16}) let int32_to_uint16 x = U16.uint_to_t (I32.v x % pow2 16) val int32_to_uint8 : a:I32.t -> Tot (b:U8.t {U8.v b = I32.v a % pow2 8}) let int32_to_uint8 x = U8.uint_to_t (I32.v x % pow2 8) val int64_to_uint64: a:I64.t -> Tot (b:U64.t{U64.v b = I64.v a % pow2 64}) let int64_to_uint64 x = U64.uint_to_t (I64.v x % pow2 64)
false
false
FStar.Int.Cast.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 int64_to_uint32: a:I64.t -> Tot (b:U32.t{U32.v b = I64.v a % pow2 32})
[]
FStar.Int.Cast.int64_to_uint32
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int64.t -> b: FStar.UInt32.t{FStar.UInt32.v b = FStar.Int64.v a % Prims.pow2 32}
{ "end_col": 57, "end_line": 229, "start_col": 24, "start_line": 229 }
Prims.Tot
val uint16_to_int8 : a:U16.t -> Tot (b:I8.t {I8.v b = (U16.v a @% pow2 8)})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint16_to_int8 x = I8.int_to_t (U16.v x @% pow2 8)
val uint16_to_int8 : a:U16.t -> Tot (b:I8.t {I8.v b = (U16.v a @% pow2 8)}) let uint16_to_int8 x =
false
null
false
I8.int_to_t (U16.v x @% pow2 8)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.UInt16.t", "FStar.Int8.int_to_t", "FStar.Int.Cast.op_At_Percent", "FStar.UInt16.v", "Prims.pow2", "FStar.Int8.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Int8.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x) val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x = I32.int_to_t (U8.v x) val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a}) let uint8_to_int16 x = I16.int_to_t (U8.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint8_to_int8 : a:U8.t -> Tot (b:I8.t {I8.v b = (U8.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint8_to_int8 x = I8.int_to_t (U8.v x @% pow2 8) val uint16_to_int64: a:U16.t -> Tot (b:I64.t{I64.v b = U16.v a}) let uint16_to_int64 x = I64.int_to_t (U16.v x) val uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a}) let uint16_to_int32 x = I32.int_to_t (U16.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int16 x = I16.int_to_t (U16.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int8 : a:U16.t -> Tot (b:I8.t {I8.v b = (U16.v a @% pow2 8)})
false
false
FStar.Int.Cast.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 uint16_to_int8 : a:U16.t -> Tot (b:I8.t {I8.v b = (U16.v a @% pow2 8)})
[]
FStar.Int.Cast.uint16_to_int8
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt16.t -> b: FStar.Int8.t{FStar.Int8.v b = FStar.UInt16.v a @% Prims.pow2 8}
{ "end_col": 54, "end_line": 147, "start_col": 23, "start_line": 147 }
Prims.Tot
val uint32_to_int8 : a:U32.t -> Tot (b:I8.t {I8.v b = (U32.v a @% pow2 8)})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint32_to_int8 x = I8.int_to_t (U32.v x @% pow2 8)
val uint32_to_int8 : a:U32.t -> Tot (b:I8.t {I8.v b = (U32.v a @% pow2 8)}) let uint32_to_int8 x =
false
null
false
I8.int_to_t (U32.v x @% pow2 8)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.UInt32.t", "FStar.Int8.int_to_t", "FStar.Int.Cast.op_At_Percent", "FStar.UInt32.v", "Prims.pow2", "FStar.Int8.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Int8.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x) val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x = I32.int_to_t (U8.v x) val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a}) let uint8_to_int16 x = I16.int_to_t (U8.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint8_to_int8 : a:U8.t -> Tot (b:I8.t {I8.v b = (U8.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint8_to_int8 x = I8.int_to_t (U8.v x @% pow2 8) val uint16_to_int64: a:U16.t -> Tot (b:I64.t{I64.v b = U16.v a}) let uint16_to_int64 x = I64.int_to_t (U16.v x) val uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a}) let uint16_to_int32 x = I32.int_to_t (U16.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int16 x = I16.int_to_t (U16.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int8 : a:U16.t -> Tot (b:I8.t {I8.v b = (U16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int8 x = I8.int_to_t (U16.v x @% pow2 8) val uint32_to_int64: a:U32.t -> Tot (b:I64.t{I64.v b = U32.v a}) let uint32_to_int64 x = I64.int_to_t (U32.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int32: a:U32.t -> Tot (b:I32.t{I32.v b = (U32.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int32 x = I32.int_to_t (U32.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int16: a:U32.t -> Tot (b:I16.t{I16.v b = (U32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int16 x = I16.int_to_t (U32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int8 : a:U32.t -> Tot (b:I8.t {I8.v b = (U32.v a @% pow2 8)})
false
false
FStar.Int.Cast.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 uint32_to_int8 : a:U32.t -> Tot (b:I8.t {I8.v b = (U32.v a @% pow2 8)})
[]
FStar.Int.Cast.uint32_to_int8
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt32.t -> b: FStar.Int8.t{FStar.Int8.v b = FStar.UInt32.v a @% Prims.pow2 8}
{ "end_col": 54, "end_line": 165, "start_col": 23, "start_line": 165 }
Prims.Tot
val uint64_to_int32: a:U64.t -> Tot (b:I32.t{I32.v b = (U64.v a @% pow2 32)})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint64_to_int32 x = I32.int_to_t (U64.v x @% pow2 32)
val uint64_to_int32: a:U64.t -> Tot (b:I32.t{I32.v b = (U64.v a @% pow2 32)}) let uint64_to_int32 x =
false
null
false
I32.int_to_t (U64.v x @% pow2 32)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.UInt64.t", "FStar.Int32.int_to_t", "FStar.Int.Cast.op_At_Percent", "FStar.UInt64.v", "Prims.pow2", "FStar.Int32.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Int32.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x) val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x = I32.int_to_t (U8.v x) val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a}) let uint8_to_int16 x = I16.int_to_t (U8.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint8_to_int8 : a:U8.t -> Tot (b:I8.t {I8.v b = (U8.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint8_to_int8 x = I8.int_to_t (U8.v x @% pow2 8) val uint16_to_int64: a:U16.t -> Tot (b:I64.t{I64.v b = U16.v a}) let uint16_to_int64 x = I64.int_to_t (U16.v x) val uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a}) let uint16_to_int32 x = I32.int_to_t (U16.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int16 x = I16.int_to_t (U16.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int8 : a:U16.t -> Tot (b:I8.t {I8.v b = (U16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int8 x = I8.int_to_t (U16.v x @% pow2 8) val uint32_to_int64: a:U32.t -> Tot (b:I64.t{I64.v b = U32.v a}) let uint32_to_int64 x = I64.int_to_t (U32.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int32: a:U32.t -> Tot (b:I32.t{I32.v b = (U32.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int32 x = I32.int_to_t (U32.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int16: a:U32.t -> Tot (b:I16.t{I16.v b = (U32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int16 x = I16.int_to_t (U32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int8 : a:U32.t -> Tot (b:I8.t {I8.v b = (U32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int8 x = I8.int_to_t (U32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int64: a:U64.t -> Tot (b:I64.t{I64.v b = (U64.v a @% pow2 64)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int64 x = I64.int_to_t (U64.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int32: a:U64.t -> Tot (b:I32.t{I32.v b = (U64.v a @% pow2 32)})
false
false
FStar.Int.Cast.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 uint64_to_int32: a:U64.t -> Tot (b:I32.t{I32.v b = (U64.v a @% pow2 32)})
[]
FStar.Int.Cast.uint64_to_int32
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.Int32.t{FStar.Int32.v b = FStar.UInt64.v a @% Prims.pow2 32}
{ "end_col": 57, "end_line": 175, "start_col": 24, "start_line": 175 }
Prims.Tot
val uint64_to_int8 : a:U64.t -> Tot (b:I8.t {I8.v b = (U64.v a @% pow2 8)})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint64_to_int8 x = I8.int_to_t (U64.v x @% pow2 8)
val uint64_to_int8 : a:U64.t -> Tot (b:I8.t {I8.v b = (U64.v a @% pow2 8)}) let uint64_to_int8 x =
false
null
false
I8.int_to_t (U64.v x @% pow2 8)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.UInt64.t", "FStar.Int8.int_to_t", "FStar.Int.Cast.op_At_Percent", "FStar.UInt64.v", "Prims.pow2", "FStar.Int8.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Int8.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x) val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x = I32.int_to_t (U8.v x) val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a}) let uint8_to_int16 x = I16.int_to_t (U8.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint8_to_int8 : a:U8.t -> Tot (b:I8.t {I8.v b = (U8.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint8_to_int8 x = I8.int_to_t (U8.v x @% pow2 8) val uint16_to_int64: a:U16.t -> Tot (b:I64.t{I64.v b = U16.v a}) let uint16_to_int64 x = I64.int_to_t (U16.v x) val uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a}) let uint16_to_int32 x = I32.int_to_t (U16.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int16 x = I16.int_to_t (U16.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int8 : a:U16.t -> Tot (b:I8.t {I8.v b = (U16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int8 x = I8.int_to_t (U16.v x @% pow2 8) val uint32_to_int64: a:U32.t -> Tot (b:I64.t{I64.v b = U32.v a}) let uint32_to_int64 x = I64.int_to_t (U32.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int32: a:U32.t -> Tot (b:I32.t{I32.v b = (U32.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int32 x = I32.int_to_t (U32.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int16: a:U32.t -> Tot (b:I16.t{I16.v b = (U32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int16 x = I16.int_to_t (U32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int8 : a:U32.t -> Tot (b:I8.t {I8.v b = (U32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int8 x = I8.int_to_t (U32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int64: a:U64.t -> Tot (b:I64.t{I64.v b = (U64.v a @% pow2 64)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int64 x = I64.int_to_t (U64.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int32: a:U64.t -> Tot (b:I32.t{I32.v b = (U64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int32 x = I32.int_to_t (U64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int16: a:U64.t -> Tot (b:I16.t{I16.v b = (U64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int16 x = I16.int_to_t (U64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int8 : a:U64.t -> Tot (b:I8.t {I8.v b = (U64.v a @% pow2 8)})
false
false
FStar.Int.Cast.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 uint64_to_int8 : a:U64.t -> Tot (b:I8.t {I8.v b = (U64.v a @% pow2 8)})
[]
FStar.Int.Cast.uint64_to_int8
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt64.t -> b: FStar.Int8.t{FStar.Int8.v b = FStar.UInt64.v a @% Prims.pow2 8}
{ "end_col": 54, "end_line": 185, "start_col": 23, "start_line": 185 }
Prims.Tot
val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16)
val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) let int64_to_int16 x =
false
null
false
I16.int_to_t (I64.v x @% pow2 16)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.Int64.t", "FStar.Int16.int_to_t", "FStar.Int.Cast.op_At_Percent", "FStar.Int64.v", "Prims.pow2", "FStar.Int16.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Int16.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)})
false
false
FStar.Int.Cast.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 int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)})
[]
FStar.Int.Cast.int64_to_int16
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int64.t -> b: FStar.Int16.t{FStar.Int16.v b = FStar.Int64.v a @% Prims.pow2 16}
{ "end_col": 56, "end_line": 110, "start_col": 23, "start_line": 110 }
Prims.Tot
val int64_to_uint8 : a:I64.t -> Tot (b:U8.t {U8.v b = I64.v a % pow2 8})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int64_to_uint8 x = U8.uint_to_t (I64.v x % pow2 8)
val int64_to_uint8 : a:I64.t -> Tot (b:U8.t {U8.v b = I64.v a % pow2 8}) let int64_to_uint8 x =
false
null
false
U8.uint_to_t (I64.v x % pow2 8)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.Int64.t", "FStar.UInt8.uint_to_t", "Prims.op_Modulus", "FStar.Int64.v", "Prims.pow2", "FStar.UInt8.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.UInt8.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x) val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x = I32.int_to_t (U8.v x) val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a}) let uint8_to_int16 x = I16.int_to_t (U8.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint8_to_int8 : a:U8.t -> Tot (b:I8.t {I8.v b = (U8.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint8_to_int8 x = I8.int_to_t (U8.v x @% pow2 8) val uint16_to_int64: a:U16.t -> Tot (b:I64.t{I64.v b = U16.v a}) let uint16_to_int64 x = I64.int_to_t (U16.v x) val uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a}) let uint16_to_int32 x = I32.int_to_t (U16.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int16 x = I16.int_to_t (U16.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int8 : a:U16.t -> Tot (b:I8.t {I8.v b = (U16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int8 x = I8.int_to_t (U16.v x @% pow2 8) val uint32_to_int64: a:U32.t -> Tot (b:I64.t{I64.v b = U32.v a}) let uint32_to_int64 x = I64.int_to_t (U32.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int32: a:U32.t -> Tot (b:I32.t{I32.v b = (U32.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int32 x = I32.int_to_t (U32.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int16: a:U32.t -> Tot (b:I16.t{I16.v b = (U32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int16 x = I16.int_to_t (U32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int8 : a:U32.t -> Tot (b:I8.t {I8.v b = (U32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int8 x = I8.int_to_t (U32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int64: a:U64.t -> Tot (b:I64.t{I64.v b = (U64.v a @% pow2 64)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int64 x = I64.int_to_t (U64.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int32: a:U64.t -> Tot (b:I32.t{I32.v b = (U64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int32 x = I32.int_to_t (U64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int16: a:U64.t -> Tot (b:I16.t{I16.v b = (U64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int16 x = I16.int_to_t (U64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int8 : a:U64.t -> Tot (b:I8.t {I8.v b = (U64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int8 x = I8.int_to_t (U64.v x @% pow2 8) /// Signed to unsigned val int8_to_uint64: a:I8.t -> Tot (b:U64.t{U64.v b = I8.v a % pow2 64}) let int8_to_uint64 x = U64.uint_to_t (I8.v x % pow2 64) val int8_to_uint32: a:I8.t -> Tot (b:U32.t{U32.v b = I8.v a % pow2 32}) let int8_to_uint32 x = U32.uint_to_t (I8.v x % pow2 32) val int8_to_uint16: a:I8.t -> Tot (b:U16.t{U16.v b = I8.v a % pow2 16}) let int8_to_uint16 x = U16.uint_to_t (I8.v x % pow2 16) val int8_to_uint8 : a:I8.t -> Tot (b:U8.t {U8.v b = I8.v a % pow2 8}) let int8_to_uint8 x = U8.uint_to_t (I8.v x % pow2 8) val int16_to_uint64: a:I16.t -> Tot (b:U64.t{U64.v b = I16.v a % pow2 64}) let int16_to_uint64 x = U64.uint_to_t (I16.v x % pow2 64) val int16_to_uint32: a:I16.t -> Tot (b:U32.t{U32.v b = I16.v a % pow2 32}) let int16_to_uint32 x = U32.uint_to_t (I16.v x % pow2 32) val int16_to_uint16: a:I16.t -> Tot (b:U16.t{U16.v b = I16.v a % pow2 16}) let int16_to_uint16 x = U16.uint_to_t (I16.v x % pow2 16) val int16_to_uint8 : a:I16.t -> Tot (b:U8.t {U8.v b = I16.v a % pow2 8}) let int16_to_uint8 x = U8.uint_to_t (I16.v x % pow2 8) val int32_to_uint64: a:I32.t -> Tot (b:U64.t{U64.v b = I32.v a % pow2 64}) let int32_to_uint64 x = U64.uint_to_t (I32.v x % pow2 64) val int32_to_uint32: a:I32.t -> Tot (b:U32.t{U32.v b = I32.v a % pow2 32}) let int32_to_uint32 x = U32.uint_to_t (I32.v x % pow2 32) val int32_to_uint16: a:I32.t -> Tot (b:U16.t{U16.v b = I32.v a % pow2 16}) let int32_to_uint16 x = U16.uint_to_t (I32.v x % pow2 16) val int32_to_uint8 : a:I32.t -> Tot (b:U8.t {U8.v b = I32.v a % pow2 8}) let int32_to_uint8 x = U8.uint_to_t (I32.v x % pow2 8) val int64_to_uint64: a:I64.t -> Tot (b:U64.t{U64.v b = I64.v a % pow2 64}) let int64_to_uint64 x = U64.uint_to_t (I64.v x % pow2 64) val int64_to_uint32: a:I64.t -> Tot (b:U32.t{U32.v b = I64.v a % pow2 32}) let int64_to_uint32 x = U32.uint_to_t (I64.v x % pow2 32) val int64_to_uint16: a:I64.t -> Tot (b:U16.t{U16.v b = I64.v a % pow2 16}) let int64_to_uint16 x = U16.uint_to_t (I64.v x % pow2 16)
false
false
FStar.Int.Cast.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 int64_to_uint8 : a:I64.t -> Tot (b:U8.t {U8.v b = I64.v a % pow2 8})
[]
FStar.Int.Cast.int64_to_uint8
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int64.t -> b: FStar.UInt8.t{FStar.UInt8.v b = FStar.Int64.v a % Prims.pow2 8}
{ "end_col": 54, "end_line": 235, "start_col": 23, "start_line": 235 }
Prims.Tot
val uint32_to_int32: a:U32.t -> Tot (b:I32.t{I32.v b = (U32.v a @% pow2 32)})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint32_to_int32 x = I32.int_to_t (U32.v x @% pow2 32)
val uint32_to_int32: a:U32.t -> Tot (b:I32.t{I32.v b = (U32.v a @% pow2 32)}) let uint32_to_int32 x =
false
null
false
I32.int_to_t (U32.v x @% pow2 32)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.UInt32.t", "FStar.Int32.int_to_t", "FStar.Int.Cast.op_At_Percent", "FStar.UInt32.v", "Prims.pow2", "FStar.Int32.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Int32.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x) val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x = I32.int_to_t (U8.v x) val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a}) let uint8_to_int16 x = I16.int_to_t (U8.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint8_to_int8 : a:U8.t -> Tot (b:I8.t {I8.v b = (U8.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint8_to_int8 x = I8.int_to_t (U8.v x @% pow2 8) val uint16_to_int64: a:U16.t -> Tot (b:I64.t{I64.v b = U16.v a}) let uint16_to_int64 x = I64.int_to_t (U16.v x) val uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a}) let uint16_to_int32 x = I32.int_to_t (U16.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int16 x = I16.int_to_t (U16.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int8 : a:U16.t -> Tot (b:I8.t {I8.v b = (U16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int8 x = I8.int_to_t (U16.v x @% pow2 8) val uint32_to_int64: a:U32.t -> Tot (b:I64.t{I64.v b = U32.v a}) let uint32_to_int64 x = I64.int_to_t (U32.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int32: a:U32.t -> Tot (b:I32.t{I32.v b = (U32.v a @% pow2 32)})
false
false
FStar.Int.Cast.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 uint32_to_int32: a:U32.t -> Tot (b:I32.t{I32.v b = (U32.v a @% pow2 32)})
[]
FStar.Int.Cast.uint32_to_int32
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt32.t -> b: FStar.Int32.t{FStar.Int32.v b = FStar.UInt32.v a @% Prims.pow2 32}
{ "end_col": 57, "end_line": 155, "start_col": 24, "start_line": 155 }
Prims.Tot
val uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint16_to_int16 x = I16.int_to_t (U16.v x @% pow2 16)
val uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)}) let uint16_to_int16 x =
false
null
false
I16.int_to_t (U16.v x @% pow2 16)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.UInt16.t", "FStar.Int16.int_to_t", "FStar.Int.Cast.op_At_Percent", "FStar.UInt16.v", "Prims.pow2", "FStar.Int16.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Int16.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x) val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x = I32.int_to_t (U8.v x) val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a}) let uint8_to_int16 x = I16.int_to_t (U8.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint8_to_int8 : a:U8.t -> Tot (b:I8.t {I8.v b = (U8.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint8_to_int8 x = I8.int_to_t (U8.v x @% pow2 8) val uint16_to_int64: a:U16.t -> Tot (b:I64.t{I64.v b = U16.v a}) let uint16_to_int64 x = I64.int_to_t (U16.v x) val uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a}) let uint16_to_int32 x = I32.int_to_t (U16.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)})
false
false
FStar.Int.Cast.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 uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)})
[]
FStar.Int.Cast.uint16_to_int16
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt16.t -> b: FStar.Int16.t{FStar.Int16.v b = FStar.UInt16.v a @% Prims.pow2 16}
{ "end_col": 57, "end_line": 142, "start_col": 24, "start_line": 142 }
Prims.Tot
val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint8_to_int16 x = I16.int_to_t (U8.v x)
val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a}) let uint8_to_int16 x =
false
null
false
I16.int_to_t (U8.v x)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.UInt8.t", "FStar.Int16.int_to_t", "FStar.UInt8.v", "FStar.Int16.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "FStar.Int.size", "FStar.Int16.n", "FStar.UInt.size", "FStar.UInt8.n", "FStar.Int16.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x) val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x = I32.int_to_t (U8.v x)
false
false
FStar.Int.Cast.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 uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a})
[]
FStar.Int.Cast.uint8_to_int16
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> b: FStar.Int16.t{FStar.Int16.v b = FStar.UInt8.v a}
{ "end_col": 44, "end_line": 126, "start_col": 23, "start_line": 126 }
Prims.Tot
val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int8_to_int16 x = I16.int_to_t (I8.v x)
val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x =
false
null
false
I16.int_to_t (I8.v x)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.Int8.t", "FStar.Int16.int_to_t", "FStar.Int8.v", "FStar.Int16.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "FStar.Int.size", "FStar.Int16.n", "FStar.Int8.n", "FStar.Int16.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x)
false
false
FStar.Int.Cast.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 int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a})
[]
FStar.Int.Cast.int8_to_int16
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int8.t -> b: FStar.Int16.t{FStar.Int16.v b = FStar.Int8.v a}
{ "end_col": 43, "end_line": 76, "start_col": 22, "start_line": 76 }
Prims.Tot
val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int8_to_int64 x = I64.int_to_t (I8.v x)
val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x =
false
null
false
I64.int_to_t (I8.v x)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.Int8.t", "FStar.Int64.int_to_t", "FStar.Int8.v", "FStar.Int64.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "FStar.Int.size", "FStar.Int64.n", "FStar.Int8.n", "FStar.Int64.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed
false
false
FStar.Int.Cast.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 int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a})
[]
FStar.Int.Cast.int8_to_int64
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int8.t -> b: FStar.Int64.t{FStar.Int64.v b = FStar.Int8.v a}
{ "end_col": 43, "end_line": 70, "start_col": 22, "start_line": 70 }
Prims.Tot
val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint32_to_uint64 x = U64.uint_to_t (U32.v x)
val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x =
false
null
false
U64.uint_to_t (U32.v x)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.UInt32.t", "FStar.UInt64.uint_to_t", "FStar.UInt32.v", "FStar.UInt64.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt64.n", "FStar.UInt32.n", "FStar.UInt64.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8)
false
false
FStar.Int.Cast.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 uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a})
[]
FStar.Int.Cast.uint32_to_uint64
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt32.t -> b: FStar.UInt64.t{FStar.UInt64.v b = FStar.UInt32.v a}
{ "end_col": 48, "end_line": 50, "start_col": 25, "start_line": 50 }
Prims.Tot
val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int8_to_int32 x = I32.int_to_t (I8.v x)
val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x =
false
null
false
I32.int_to_t (I8.v x)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.Int8.t", "FStar.Int32.int_to_t", "FStar.Int8.v", "FStar.Int32.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "FStar.Int.size", "FStar.Int32.n", "FStar.Int8.n", "FStar.Int32.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x)
false
false
FStar.Int.Cast.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 int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a})
[]
FStar.Int.Cast.int8_to_int32
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int8.t -> b: FStar.Int32.t{FStar.Int32.v b = FStar.Int8.v a}
{ "end_col": 43, "end_line": 73, "start_col": 22, "start_line": 73 }
Prims.Tot
val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32)
val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x =
false
null
false
I32.int_to_t (I16.v x @% pow2 32)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.Int16.t", "FStar.Int32.int_to_t", "FStar.Int.Cast.op_At_Percent", "FStar.Int16.v", "Prims.pow2", "FStar.Int32.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "FStar.Int.size", "FStar.Int32.n", "FStar.Int16.n", "FStar.Int32.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64)
false
false
FStar.Int.Cast.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 int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a})
[]
FStar.Int.Cast.int16_to_int32
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int16.t -> b: FStar.Int32.t{FStar.Int32.v b = FStar.Int16.v a}
{ "end_col": 56, "end_line": 82, "start_col": 23, "start_line": 82 }
Prims.Tot
val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64)
val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x =
false
null
false
I64.int_to_t (I16.v x @% pow2 64)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.Int16.t", "FStar.Int64.int_to_t", "FStar.Int.Cast.op_At_Percent", "FStar.Int16.v", "Prims.pow2", "FStar.Int64.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "FStar.Int.size", "FStar.Int64.n", "FStar.Int16.n", "FStar.Int64.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x)
false
false
FStar.Int.Cast.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 int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a})
[]
FStar.Int.Cast.int16_to_int64
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int16.t -> b: FStar.Int64.t{FStar.Int64.v b = FStar.Int16.v a}
{ "end_col": 56, "end_line": 79, "start_col": 23, "start_line": 79 }
Prims.Tot
val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint8_to_int32 x = I32.int_to_t (U8.v x)
val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x =
false
null
false
I32.int_to_t (U8.v x)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.UInt8.t", "FStar.Int32.int_to_t", "FStar.UInt8.v", "FStar.Int32.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "FStar.Int.size", "FStar.Int32.n", "FStar.UInt.size", "FStar.UInt8.n", "FStar.Int32.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x)
false
false
FStar.Int.Cast.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 uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a})
[]
FStar.Int.Cast.uint8_to_int32
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt8.t -> b: FStar.Int32.t{FStar.Int32.v b = FStar.UInt8.v a}
{ "end_col": 44, "end_line": 123, "start_col": 23, "start_line": 123 }
Prims.Tot
val uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint16_to_int32 x = I32.int_to_t (U16.v x)
val uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a}) let uint16_to_int32 x =
false
null
false
I32.int_to_t (U16.v x)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.UInt16.t", "FStar.Int32.int_to_t", "FStar.UInt16.v", "FStar.Int32.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "FStar.Int.size", "FStar.Int32.n", "FStar.UInt.size", "FStar.UInt16.n", "FStar.Int32.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x) val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x = I32.int_to_t (U8.v x) val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a}) let uint8_to_int16 x = I16.int_to_t (U8.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint8_to_int8 : a:U8.t -> Tot (b:I8.t {I8.v b = (U8.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint8_to_int8 x = I8.int_to_t (U8.v x @% pow2 8) val uint16_to_int64: a:U16.t -> Tot (b:I64.t{I64.v b = U16.v a}) let uint16_to_int64 x = I64.int_to_t (U16.v x)
false
false
FStar.Int.Cast.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 uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a})
[]
FStar.Int.Cast.uint16_to_int32
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt16.t -> b: FStar.Int32.t{FStar.Int32.v b = FStar.UInt16.v a}
{ "end_col": 46, "end_line": 137, "start_col": 24, "start_line": 137 }
Prims.Tot
val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8)
val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) let int16_to_int8 x =
false
null
false
I8.int_to_t (I16.v x @% pow2 8)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.Int16.t", "FStar.Int8.int_to_t", "FStar.Int.Cast.op_At_Percent", "FStar.Int16.v", "Prims.pow2", "FStar.Int8.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Int8.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)})
false
false
FStar.Int.Cast.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 int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)})
[]
FStar.Int.Cast.int16_to_int8
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int16.t -> b: FStar.Int8.t{FStar.Int8.v b = FStar.Int16.v a @% Prims.pow2 8}
{ "end_col": 53, "end_line": 87, "start_col": 22, "start_line": 87 }
Prims.Tot
val int16_to_uint16: a:I16.t -> Tot (b:U16.t{U16.v b = I16.v a % pow2 16})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int16_to_uint16 x = U16.uint_to_t (I16.v x % pow2 16)
val int16_to_uint16: a:I16.t -> Tot (b:U16.t{U16.v b = I16.v a % pow2 16}) let int16_to_uint16 x =
false
null
false
U16.uint_to_t (I16.v x % pow2 16)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.Int16.t", "FStar.UInt16.uint_to_t", "Prims.op_Modulus", "FStar.Int16.v", "Prims.pow2", "FStar.UInt16.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.UInt16.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x) val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x = I32.int_to_t (U8.v x) val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a}) let uint8_to_int16 x = I16.int_to_t (U8.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint8_to_int8 : a:U8.t -> Tot (b:I8.t {I8.v b = (U8.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint8_to_int8 x = I8.int_to_t (U8.v x @% pow2 8) val uint16_to_int64: a:U16.t -> Tot (b:I64.t{I64.v b = U16.v a}) let uint16_to_int64 x = I64.int_to_t (U16.v x) val uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a}) let uint16_to_int32 x = I32.int_to_t (U16.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int16 x = I16.int_to_t (U16.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int8 : a:U16.t -> Tot (b:I8.t {I8.v b = (U16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int8 x = I8.int_to_t (U16.v x @% pow2 8) val uint32_to_int64: a:U32.t -> Tot (b:I64.t{I64.v b = U32.v a}) let uint32_to_int64 x = I64.int_to_t (U32.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int32: a:U32.t -> Tot (b:I32.t{I32.v b = (U32.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int32 x = I32.int_to_t (U32.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int16: a:U32.t -> Tot (b:I16.t{I16.v b = (U32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int16 x = I16.int_to_t (U32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int8 : a:U32.t -> Tot (b:I8.t {I8.v b = (U32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int8 x = I8.int_to_t (U32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int64: a:U64.t -> Tot (b:I64.t{I64.v b = (U64.v a @% pow2 64)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int64 x = I64.int_to_t (U64.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int32: a:U64.t -> Tot (b:I32.t{I32.v b = (U64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int32 x = I32.int_to_t (U64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int16: a:U64.t -> Tot (b:I16.t{I16.v b = (U64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int16 x = I16.int_to_t (U64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int8 : a:U64.t -> Tot (b:I8.t {I8.v b = (U64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int8 x = I8.int_to_t (U64.v x @% pow2 8) /// Signed to unsigned val int8_to_uint64: a:I8.t -> Tot (b:U64.t{U64.v b = I8.v a % pow2 64}) let int8_to_uint64 x = U64.uint_to_t (I8.v x % pow2 64) val int8_to_uint32: a:I8.t -> Tot (b:U32.t{U32.v b = I8.v a % pow2 32}) let int8_to_uint32 x = U32.uint_to_t (I8.v x % pow2 32) val int8_to_uint16: a:I8.t -> Tot (b:U16.t{U16.v b = I8.v a % pow2 16}) let int8_to_uint16 x = U16.uint_to_t (I8.v x % pow2 16) val int8_to_uint8 : a:I8.t -> Tot (b:U8.t {U8.v b = I8.v a % pow2 8}) let int8_to_uint8 x = U8.uint_to_t (I8.v x % pow2 8) val int16_to_uint64: a:I16.t -> Tot (b:U64.t{U64.v b = I16.v a % pow2 64}) let int16_to_uint64 x = U64.uint_to_t (I16.v x % pow2 64) val int16_to_uint32: a:I16.t -> Tot (b:U32.t{U32.v b = I16.v a % pow2 32}) let int16_to_uint32 x = U32.uint_to_t (I16.v x % pow2 32)
false
false
FStar.Int.Cast.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 int16_to_uint16: a:I16.t -> Tot (b:U16.t{U16.v b = I16.v a % pow2 16})
[]
FStar.Int.Cast.int16_to_uint16
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int16.t -> b: FStar.UInt16.t{FStar.UInt16.v b = FStar.Int16.v a % Prims.pow2 16}
{ "end_col": 57, "end_line": 208, "start_col": 24, "start_line": 208 }
Prims.Tot
val int8_to_uint8 : a:I8.t -> Tot (b:U8.t {U8.v b = I8.v a % pow2 8})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int8_to_uint8 x = U8.uint_to_t (I8.v x % pow2 8)
val int8_to_uint8 : a:I8.t -> Tot (b:U8.t {U8.v b = I8.v a % pow2 8}) let int8_to_uint8 x =
false
null
false
U8.uint_to_t (I8.v x % pow2 8)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.Int8.t", "FStar.UInt8.uint_to_t", "Prims.op_Modulus", "FStar.Int8.v", "Prims.pow2", "FStar.UInt8.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.UInt8.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x) val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x = I32.int_to_t (U8.v x) val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a}) let uint8_to_int16 x = I16.int_to_t (U8.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint8_to_int8 : a:U8.t -> Tot (b:I8.t {I8.v b = (U8.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint8_to_int8 x = I8.int_to_t (U8.v x @% pow2 8) val uint16_to_int64: a:U16.t -> Tot (b:I64.t{I64.v b = U16.v a}) let uint16_to_int64 x = I64.int_to_t (U16.v x) val uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a}) let uint16_to_int32 x = I32.int_to_t (U16.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int16 x = I16.int_to_t (U16.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int8 : a:U16.t -> Tot (b:I8.t {I8.v b = (U16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int8 x = I8.int_to_t (U16.v x @% pow2 8) val uint32_to_int64: a:U32.t -> Tot (b:I64.t{I64.v b = U32.v a}) let uint32_to_int64 x = I64.int_to_t (U32.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int32: a:U32.t -> Tot (b:I32.t{I32.v b = (U32.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int32 x = I32.int_to_t (U32.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int16: a:U32.t -> Tot (b:I16.t{I16.v b = (U32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int16 x = I16.int_to_t (U32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int8 : a:U32.t -> Tot (b:I8.t {I8.v b = (U32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int8 x = I8.int_to_t (U32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int64: a:U64.t -> Tot (b:I64.t{I64.v b = (U64.v a @% pow2 64)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int64 x = I64.int_to_t (U64.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int32: a:U64.t -> Tot (b:I32.t{I32.v b = (U64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int32 x = I32.int_to_t (U64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int16: a:U64.t -> Tot (b:I16.t{I16.v b = (U64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int16 x = I16.int_to_t (U64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int8 : a:U64.t -> Tot (b:I8.t {I8.v b = (U64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int8 x = I8.int_to_t (U64.v x @% pow2 8) /// Signed to unsigned val int8_to_uint64: a:I8.t -> Tot (b:U64.t{U64.v b = I8.v a % pow2 64}) let int8_to_uint64 x = U64.uint_to_t (I8.v x % pow2 64) val int8_to_uint32: a:I8.t -> Tot (b:U32.t{U32.v b = I8.v a % pow2 32}) let int8_to_uint32 x = U32.uint_to_t (I8.v x % pow2 32) val int8_to_uint16: a:I8.t -> Tot (b:U16.t{U16.v b = I8.v a % pow2 16}) let int8_to_uint16 x = U16.uint_to_t (I8.v x % pow2 16)
false
false
FStar.Int.Cast.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 int8_to_uint8 : a:I8.t -> Tot (b:U8.t {U8.v b = I8.v a % pow2 8})
[]
FStar.Int.Cast.int8_to_uint8
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int8.t -> b: FStar.UInt8.t{FStar.UInt8.v b = FStar.Int8.v a % Prims.pow2 8}
{ "end_col": 52, "end_line": 199, "start_col": 22, "start_line": 199 }
Prims.Tot
val int64_to_uint16: a:I64.t -> Tot (b:U16.t{U16.v b = I64.v a % pow2 16})
[ { "abbrev": true, "full_module": "FStar.Int64", "short_module": "I64" }, { "abbrev": true, "full_module": "FStar.Int32", "short_module": "I32" }, { "abbrev": true, "full_module": "FStar.Int16", "short_module": "I16" }, { "abbrev": true, "full_module": "FStar.Int8", "short_module": "I8" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Int", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int64_to_uint16 x = U16.uint_to_t (I64.v x % pow2 16)
val int64_to_uint16: a:I64.t -> Tot (b:U16.t{U16.v b = I64.v a % pow2 16}) let int64_to_uint16 x =
false
null
false
U16.uint_to_t (I64.v x % pow2 16)
{ "checked_file": "FStar.Int.Cast.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Int8.fsti.checked", "FStar.Int64.fsti.checked", "FStar.Int32.fsti.checked", "FStar.Int16.fsti.checked", "FStar.Int.fsti.checked" ], "interface_file": false, "source_file": "FStar.Int.Cast.fst" }
[ "total" ]
[ "FStar.Int64.t", "FStar.UInt16.uint_to_t", "Prims.op_Modulus", "FStar.Int64.v", "Prims.pow2", "FStar.UInt16.t", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.UInt16.v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Int.Cast module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module I8 = FStar.Int8 module I16 = FStar.Int16 module I32 = FStar.Int32 module I64 = FStar.Int64 let op_At_Percent = FStar.Int.op_At_Percent /// Unsigned to unsigned val uint8_to_uint64: a:U8.t -> Tot (b:U64.t{U64.v b = U8.v a}) let uint8_to_uint64 a = U64.uint_to_t (U8.v a) val uint8_to_uint32: a:U8.t -> Tot (b:U32.t{U32.v b = U8.v a}) let uint8_to_uint32 x = U32.uint_to_t (U8.v x) val uint8_to_uint16: a:U8.t -> Tot (b:U16.t{U16.v b = U8.v a}) let uint8_to_uint16 x = U16.uint_to_t (U8.v x) val uint16_to_uint64: a:U16.t -> Tot (b:U64.t{U64.v b = U16.v a}) let uint16_to_uint64 x = U64.uint_to_t (U16.v x) val uint16_to_uint32: a:U16.t -> Tot (b:U32.t{U32.v b = U16.v a}) let uint16_to_uint32 x = U32.uint_to_t (U16.v x) val uint16_to_uint8 : a:U16.t -> Tot (b:U8.t{U8.v b = U16.v a % pow2 8}) let uint16_to_uint8 x = U8.uint_to_t (U16.v x % pow2 8) val uint32_to_uint64: a:U32.t -> Tot (b:U64.t{U64.v b = U32.v a}) let uint32_to_uint64 x = U64.uint_to_t (U32.v x) val uint32_to_uint16: a:U32.t -> Tot (b:U16.t{U16.v b = U32.v a % pow2 16}) let uint32_to_uint16 x = U16.uint_to_t (U32.v x % pow2 16) val uint32_to_uint8 : a:U32.t -> Tot (b:U8.t{U8.v b = U32.v a % pow2 8}) let uint32_to_uint8 x = U8.uint_to_t (U32.v x % pow2 8) val uint64_to_uint32: a:U64.t -> Tot (b:U32.t{U32.v b = U64.v a % pow2 32}) let uint64_to_uint32 x = U32.uint_to_t (U64.v x % pow2 32) val uint64_to_uint16: a:U64.t -> Tot (b:U16.t{U16.v b = U64.v a % pow2 16}) let uint64_to_uint16 x = U16.uint_to_t (U64.v x % pow2 16) val uint64_to_uint8 : a:U64.t -> Tot (b:U8.t{U8.v b = U64.v a % pow2 8}) let uint64_to_uint8 x = U8.uint_to_t (U64.v x % pow2 8) /// Signed to signed val int8_to_int64: a:I8.t -> Tot (b:I64.t{I64.v b = I8.v a}) let int8_to_int64 x = I64.int_to_t (I8.v x) val int8_to_int32: a:I8.t -> Tot (b:I32.t{I32.v b = I8.v a}) let int8_to_int32 x = I32.int_to_t (I8.v x) val int8_to_int16: a:I8.t -> Tot (b:I16.t{I16.v b = I8.v a}) let int8_to_int16 x = I16.int_to_t (I8.v x) val int16_to_int64: a:I16.t -> Tot (b:I64.t{I64.v b = I16.v a}) let int16_to_int64 x = I64.int_to_t (I16.v x @% pow2 64) val int16_to_int32: a:I16.t -> Tot (b:I32.t{I32.v b = I16.v a}) let int16_to_int32 x = I32.int_to_t (I16.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int16_to_int8 : a:I16.t -> Tot (b:I8.t {I8.v b = (I16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int16_to_int8 x = I8.int_to_t (I16.v x @% pow2 8) val int32_to_int64: a:I32.t -> Tot (b:I64.t{I64.v b = I32.v a}) let int32_to_int64 x = I64.int_to_t (I32.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int16: a:I32.t -> Tot (b:I16.t{I16.v b = (I32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int16 x = I16.int_to_t (I32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int32_to_int8 : a:I32.t -> Tot (b:I8.t {I8.v b = (I32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int32_to_int8 x = I8.int_to_t (I32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int32: a:I64.t -> Tot (b:I32.t{I32.v b = (I64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int32 x = I32.int_to_t (I64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int16: a:I64.t -> Tot (b:I16.t{I16.v b = (I64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int16 x = I16.int_to_t (I64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val int64_to_int8 : a:I64.t -> Tot (b:I8.t {I8.v b = (I64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let int64_to_int8 x = I8.int_to_t (I64.v x @% pow2 8) /// Unsigned to signed val uint8_to_int64: a:U8.t -> Tot (b:I64.t{I64.v b = U8.v a}) let uint8_to_int64 x = I64.int_to_t (U8.v x) val uint8_to_int32: a:U8.t -> Tot (b:I32.t{I32.v b = U8.v a}) let uint8_to_int32 x = I32.int_to_t (U8.v x) val uint8_to_int16: a:U8.t -> Tot (b:I16.t{I16.v b = U8.v a}) let uint8_to_int16 x = I16.int_to_t (U8.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint8_to_int8 : a:U8.t -> Tot (b:I8.t {I8.v b = (U8.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint8_to_int8 x = I8.int_to_t (U8.v x @% pow2 8) val uint16_to_int64: a:U16.t -> Tot (b:I64.t{I64.v b = U16.v a}) let uint16_to_int64 x = I64.int_to_t (U16.v x) val uint16_to_int32: a:U16.t -> Tot (b:I32.t{I32.v b = U16.v a}) let uint16_to_int32 x = I32.int_to_t (U16.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int16: a:U16.t -> Tot (b:I16.t{I16.v b = (U16.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int16 x = I16.int_to_t (U16.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint16_to_int8 : a:U16.t -> Tot (b:I8.t {I8.v b = (U16.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint16_to_int8 x = I8.int_to_t (U16.v x @% pow2 8) val uint32_to_int64: a:U32.t -> Tot (b:I64.t{I64.v b = U32.v a}) let uint32_to_int64 x = I64.int_to_t (U32.v x) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int32: a:U32.t -> Tot (b:I32.t{I32.v b = (U32.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int32 x = I32.int_to_t (U32.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int16: a:U32.t -> Tot (b:I16.t{I16.v b = (U32.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int16 x = I16.int_to_t (U32.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint32_to_int8 : a:U32.t -> Tot (b:I8.t {I8.v b = (U32.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint32_to_int8 x = I8.int_to_t (U32.v x @% pow2 8) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int64: a:U64.t -> Tot (b:I64.t{I64.v b = (U64.v a @% pow2 64)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int64 x = I64.int_to_t (U64.v x @% pow2 64) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int32: a:U64.t -> Tot (b:I32.t{I32.v b = (U64.v a @% pow2 32)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int32 x = I32.int_to_t (U64.v x @% pow2 32) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int16: a:U64.t -> Tot (b:I16.t{I16.v b = (U64.v a @% pow2 16)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int16 x = I16.int_to_t (U64.v x @% pow2 16) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] val uint64_to_int8 : a:U64.t -> Tot (b:I8.t {I8.v b = (U64.v a @% pow2 8)}) [@@(deprecated "with care; in C the result is implementation-defined when not representable")] let uint64_to_int8 x = I8.int_to_t (U64.v x @% pow2 8) /// Signed to unsigned val int8_to_uint64: a:I8.t -> Tot (b:U64.t{U64.v b = I8.v a % pow2 64}) let int8_to_uint64 x = U64.uint_to_t (I8.v x % pow2 64) val int8_to_uint32: a:I8.t -> Tot (b:U32.t{U32.v b = I8.v a % pow2 32}) let int8_to_uint32 x = U32.uint_to_t (I8.v x % pow2 32) val int8_to_uint16: a:I8.t -> Tot (b:U16.t{U16.v b = I8.v a % pow2 16}) let int8_to_uint16 x = U16.uint_to_t (I8.v x % pow2 16) val int8_to_uint8 : a:I8.t -> Tot (b:U8.t {U8.v b = I8.v a % pow2 8}) let int8_to_uint8 x = U8.uint_to_t (I8.v x % pow2 8) val int16_to_uint64: a:I16.t -> Tot (b:U64.t{U64.v b = I16.v a % pow2 64}) let int16_to_uint64 x = U64.uint_to_t (I16.v x % pow2 64) val int16_to_uint32: a:I16.t -> Tot (b:U32.t{U32.v b = I16.v a % pow2 32}) let int16_to_uint32 x = U32.uint_to_t (I16.v x % pow2 32) val int16_to_uint16: a:I16.t -> Tot (b:U16.t{U16.v b = I16.v a % pow2 16}) let int16_to_uint16 x = U16.uint_to_t (I16.v x % pow2 16) val int16_to_uint8 : a:I16.t -> Tot (b:U8.t {U8.v b = I16.v a % pow2 8}) let int16_to_uint8 x = U8.uint_to_t (I16.v x % pow2 8) val int32_to_uint64: a:I32.t -> Tot (b:U64.t{U64.v b = I32.v a % pow2 64}) let int32_to_uint64 x = U64.uint_to_t (I32.v x % pow2 64) val int32_to_uint32: a:I32.t -> Tot (b:U32.t{U32.v b = I32.v a % pow2 32}) let int32_to_uint32 x = U32.uint_to_t (I32.v x % pow2 32) val int32_to_uint16: a:I32.t -> Tot (b:U16.t{U16.v b = I32.v a % pow2 16}) let int32_to_uint16 x = U16.uint_to_t (I32.v x % pow2 16) val int32_to_uint8 : a:I32.t -> Tot (b:U8.t {U8.v b = I32.v a % pow2 8}) let int32_to_uint8 x = U8.uint_to_t (I32.v x % pow2 8) val int64_to_uint64: a:I64.t -> Tot (b:U64.t{U64.v b = I64.v a % pow2 64}) let int64_to_uint64 x = U64.uint_to_t (I64.v x % pow2 64) val int64_to_uint32: a:I64.t -> Tot (b:U32.t{U32.v b = I64.v a % pow2 32}) let int64_to_uint32 x = U32.uint_to_t (I64.v x % pow2 32)
false
false
FStar.Int.Cast.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 int64_to_uint16: a:I64.t -> Tot (b:U16.t{U16.v b = I64.v a % pow2 16})
[]
FStar.Int.Cast.int64_to_uint16
{ "file_name": "ulib/FStar.Int.Cast.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.Int64.t -> b: FStar.UInt16.t{FStar.UInt16.v b = FStar.Int64.v a % Prims.pow2 16}
{ "end_col": 57, "end_line": 232, "start_col": 24, "start_line": 232 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ( /% ) (x:elem) (y:elem) = x *% finv y
let op_Slash_Percent (x y: elem) =
false
null
false
x *% finv y
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Spec.Curve25519.elem", "Spec.Curve25519.op_Star_Percent", "Spec.Curve25519.finv" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_Slash_Percent : x: Spec.Curve25519.elem -> y: Spec.Curve25519.elem -> Spec.Curve25519.elem
[]
Spec.Curve25519.op_Slash_Percent
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Spec.Curve25519.elem -> y: Spec.Curve25519.elem -> Spec.Curve25519.elem
{ "end_col": 42, "end_line": 31, "start_col": 31, "start_line": 31 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let cswap2 (sw:uint64) (nq:proj_point) (nqp1:proj_point) = let open Lib.RawIntTypes in if uint_to_nat sw = 1 then (nqp1, nq) else (nq, nqp1)
let cswap2 (sw: uint64) (nq nqp1: proj_point) =
false
null
false
let open Lib.RawIntTypes in if uint_to_nat sw = 1 then (nqp1, nq) else (nq, nqp1)
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Lib.IntTypes.uint64", "Spec.Curve25519.proj_point", "Prims.op_Equality", "Prims.int", "Lib.RawIntTypes.uint_to_nat", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Pervasives.Native.Mktuple2", "Prims.bool", "FStar.Pervasives.Native.tuple2" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow let finv (x:elem) : elem = x **% (prime - 2) let ( /% ) (x:elem) (y:elem) = x *% finv y (* Type aliases *) type scalar = lbytes 32 type serialized_point = lbytes 32 type proj_point = elem & elem let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 = let q = i / 8 in let r = size (i % 8) in to_u64 ((k.[q] >>. r) &. u8 1) let decodeScalar (k:scalar) = let k : scalar = k.[0] <- (k.[0] &. u8 248) in let k : scalar = k.[31] <- (k.[31] &. u8 127) in let k : scalar = k.[31] <- (k.[31] |. u8 64) in k let decodePoint (u:serialized_point) = (nat_from_bytes_le u % pow2 255) % prime let encodePoint (p:proj_point) : Tot serialized_point = let x, z = p in let p = x /% z in nat_to_bytes_le 32 p let add_and_double q nq nqp1 = let x_1, z_1 = q in let x_2, z_2 = nq in let x_3, z_3 = nqp1 in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3) let double nq = let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let aa = a *% a in let bb = b *% b in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in x_2, z_2
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val cswap2 : sw: Lib.IntTypes.uint64 -> nq: Spec.Curve25519.proj_point -> nqp1: Spec.Curve25519.proj_point -> Spec.Curve25519.proj_point * Spec.Curve25519.proj_point
[]
Spec.Curve25519.cswap2
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
sw: Lib.IntTypes.uint64 -> nq: Spec.Curve25519.proj_point -> nqp1: Spec.Curve25519.proj_point -> Spec.Curve25519.proj_point * Spec.Curve25519.proj_point
{ "end_col": 55, "end_line": 94, "start_col": 2, "start_line": 93 }
Prims.Tot
val basepoint_list:x: list byte_t {List.Tot.length x == 32}
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let basepoint_list : x:list byte_t{List.Tot.length x == 32} = [@inline_let] let l = [9uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy] in assert_norm (List.Tot.length l == 32); l
val basepoint_list:x: list byte_t {List.Tot.length x == 32} let basepoint_list:x: list byte_t {List.Tot.length x == 32} =
false
null
false
[@@ inline_let ]let l = [ 9uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy ] in assert_norm (List.Tot.length l == 32); l
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.PUB", "Prims.list", "Prims.Cons", "FStar.UInt8.__uint_to_t", "Prims.Nil" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow let finv (x:elem) : elem = x **% (prime - 2) let ( /% ) (x:elem) (y:elem) = x *% finv y (* Type aliases *) type scalar = lbytes 32 type serialized_point = lbytes 32 type proj_point = elem & elem let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 = let q = i / 8 in let r = size (i % 8) in to_u64 ((k.[q] >>. r) &. u8 1) let decodeScalar (k:scalar) = let k : scalar = k.[0] <- (k.[0] &. u8 248) in let k : scalar = k.[31] <- (k.[31] &. u8 127) in let k : scalar = k.[31] <- (k.[31] |. u8 64) in k let decodePoint (u:serialized_point) = (nat_from_bytes_le u % pow2 255) % prime let encodePoint (p:proj_point) : Tot serialized_point = let x, z = p in let p = x /% z in nat_to_bytes_le 32 p let add_and_double q nq nqp1 = let x_1, z_1 = q in let x_2, z_2 = nq in let x_3, z_3 = nqp1 in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3) let double nq = let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let aa = a *% a in let bb = b *% b in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in x_2, z_2 let cswap2 (sw:uint64) (nq:proj_point) (nqp1:proj_point) = let open Lib.RawIntTypes in if uint_to_nat sw = 1 then (nqp1, nq) else (nq, nqp1) let ladder_step (k:scalar) (q:proj_point) (i:nat{i < 251}) (nq, nqp1, swap) = let bit = ith_bit k (253-i) in let sw = swap ^. bit in let nq, nqp1 = cswap2 sw nq nqp1 in let nq, nqp1 = add_and_double q nq nqp1 in (nq, nqp1, bit) let montgomery_ladder (init:elem) (k:scalar) : Tot proj_point = let q = (init, one) in let nq = (one, zero) in let nqp1 = (init, one) in // bit 255 is 0 and bit 254 is 1 let nq,nqp1 = cswap2 (u64 1) nq nqp1 in let nq,nqp1 = add_and_double q nq nqp1 in let swap = u64 1 in // bits 253-3 depend on scalar let nq,nqp1,swap = Lib.LoopCombinators.repeati 251 (ladder_step k q) (nq, nqp1, swap) in let nq,nqp1 = cswap2 swap nq nqp1 in // bits 2-0 are 0 let nq = double nq in let nq = double nq in let nq = double nq in nq let scalarmult (k:scalar) (u:serialized_point) : Tot serialized_point = let u = decodePoint u in let res = montgomery_ladder u k in encodePoint res inline_for_extraction
false
false
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val basepoint_list:x: list byte_t {List.Tot.length x == 32}
[]
Spec.Curve25519.basepoint_list
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Prims.list (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.PUB) {FStar.List.Tot.Base.length x == 32}
{ "end_col": 3, "end_line": 134, "start_col": 2, "start_line": 127 }
Prims.Tot
val fpow (x: elem) (b: nat) : elem
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b
val fpow (x: elem) (b: nat) : elem let fpow (x: elem) (b: nat) : elem =
false
null
false
Lib.NatMod.pow_mod #prime x b
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Spec.Curve25519.elem", "Prims.nat", "Lib.NatMod.pow_mod", "Spec.Curve25519.prime" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fpow (x: elem) (b: nat) : elem
[]
Spec.Curve25519.fpow
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Spec.Curve25519.elem -> b: Prims.nat -> Spec.Curve25519.elem
{ "end_col": 64, "end_line": 27, "start_col": 35, "start_line": 27 }
Prims.Tot
val zero:elem
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let zero : elem = 0
val zero:elem let zero:elem =
false
null
false
0
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val zero:elem
[]
Spec.Curve25519.zero
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Curve25519.elem
{ "end_col": 19, "end_line": 16, "start_col": 18, "start_line": 16 }
Prims.Tot
val prime:pos
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let prime : pos = pow2 255 - 19
val prime:pos let prime:pos =
false
null
false
pow2 255 - 19
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Prims.op_Subtraction", "Prims.pow2" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0"
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val prime:pos
[]
Spec.Curve25519.prime
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.pos
{ "end_col": 31, "end_line": 13, "start_col": 18, "start_line": 13 }
Prims.Tot
val fadd (x y: elem) : elem
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fadd (x:elem) (y:elem) : elem = (x + y) % prime
val fadd (x y: elem) : elem let fadd (x y: elem) : elem =
false
null
false
(x + y) % prime
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Spec.Curve25519.elem", "Prims.op_Modulus", "Prims.op_Addition", "Spec.Curve25519.prime" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fadd (x y: elem) : elem
[]
Spec.Curve25519.fadd
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Spec.Curve25519.elem -> y: Spec.Curve25519.elem -> Spec.Curve25519.elem
{ "end_col": 51, "end_line": 19, "start_col": 36, "start_line": 19 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let double nq = let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let aa = a *% a in let bb = b *% b in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in x_2, z_2
let double nq =
false
null
false
let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let aa = a *% a in let bb = b *% b in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in x_2, z_2
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.tuple2", "Spec.Curve25519.elem", "FStar.Pervasives.Native.Mktuple2", "Spec.Curve25519.op_Star_Percent", "Spec.Curve25519.op_Plus_Percent", "Spec.Curve25519.op_Subtraction_Percent" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow let finv (x:elem) : elem = x **% (prime - 2) let ( /% ) (x:elem) (y:elem) = x *% finv y (* Type aliases *) type scalar = lbytes 32 type serialized_point = lbytes 32 type proj_point = elem & elem let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 = let q = i / 8 in let r = size (i % 8) in to_u64 ((k.[q] >>. r) &. u8 1) let decodeScalar (k:scalar) = let k : scalar = k.[0] <- (k.[0] &. u8 248) in let k : scalar = k.[31] <- (k.[31] &. u8 127) in let k : scalar = k.[31] <- (k.[31] |. u8 64) in k let decodePoint (u:serialized_point) = (nat_from_bytes_le u % pow2 255) % prime let encodePoint (p:proj_point) : Tot serialized_point = let x, z = p in let p = x /% z in nat_to_bytes_le 32 p let add_and_double q nq nqp1 = let x_1, z_1 = q in let x_2, z_2 = nq in let x_3, z_3 = nqp1 in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3)
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val double : nq: (Spec.Curve25519.elem * Spec.Curve25519.elem) -> Spec.Curve25519.elem * Spec.Curve25519.elem
[]
Spec.Curve25519.double
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
nq: (Spec.Curve25519.elem * Spec.Curve25519.elem) -> Spec.Curve25519.elem * Spec.Curve25519.elem
{ "end_col": 10, "end_line": 90, "start_col": 15, "start_line": 79 }
Prims.Tot
val one:elem
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let one : elem = 1
val one:elem let one:elem =
false
null
false
1
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime}
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val one:elem
[]
Spec.Curve25519.one
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Curve25519.elem
{ "end_col": 19, "end_line": 17, "start_col": 18, "start_line": 17 }
Prims.Tot
val fmul (x y: elem) : elem
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fmul (x:elem) (y:elem) : elem = (x * y) % prime
val fmul (x y: elem) : elem let fmul (x y: elem) : elem =
false
null
false
(x * y) % prime
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Spec.Curve25519.elem", "Prims.op_Modulus", "FStar.Mul.op_Star", "Spec.Curve25519.prime" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fmul (x y: elem) : elem
[]
Spec.Curve25519.fmul
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Spec.Curve25519.elem -> y: Spec.Curve25519.elem -> Spec.Curve25519.elem
{ "end_col": 51, "end_line": 21, "start_col": 36, "start_line": 21 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let decodePoint (u:serialized_point) = (nat_from_bytes_le u % pow2 255) % prime
let decodePoint (u: serialized_point) =
false
null
false
(nat_from_bytes_le u % pow2 255) % prime
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Spec.Curve25519.serialized_point", "Prims.op_Modulus", "Lib.ByteSequence.nat_from_bytes_le", "Lib.IntTypes.SEC", "Prims.pow2", "Spec.Curve25519.prime", "Prims.int" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow let finv (x:elem) : elem = x **% (prime - 2) let ( /% ) (x:elem) (y:elem) = x *% finv y (* Type aliases *) type scalar = lbytes 32 type serialized_point = lbytes 32 type proj_point = elem & elem let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 = let q = i / 8 in let r = size (i % 8) in to_u64 ((k.[q] >>. r) &. u8 1) let decodeScalar (k:scalar) = let k : scalar = k.[0] <- (k.[0] &. u8 248) in let k : scalar = k.[31] <- (k.[31] &. u8 127) in let k : scalar = k.[31] <- (k.[31] |. u8 64) in k
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val decodePoint : u23: Spec.Curve25519.serialized_point -> Prims.int
[]
Spec.Curve25519.decodePoint
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
u23: Spec.Curve25519.serialized_point -> Prims.int
{ "end_col": 42, "end_line": 48, "start_col": 2, "start_line": 48 }
Prims.Tot
val fsub (x y: elem) : elem
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fsub (x:elem) (y:elem) : elem = (x - y) % prime
val fsub (x y: elem) : elem let fsub (x y: elem) : elem =
false
null
false
(x - y) % prime
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Spec.Curve25519.elem", "Prims.op_Modulus", "Prims.op_Subtraction", "Spec.Curve25519.prime" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fsub (x y: elem) : elem
[]
Spec.Curve25519.fsub
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Spec.Curve25519.elem -> y: Spec.Curve25519.elem -> Spec.Curve25519.elem
{ "end_col": 51, "end_line": 20, "start_col": 36, "start_line": 20 }
Prims.Tot
val finv (x: elem) : elem
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let finv (x:elem) : elem = x **% (prime - 2)
val finv (x: elem) : elem let finv (x: elem) : elem =
false
null
false
x **% (prime - 2)
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Spec.Curve25519.elem", "Spec.Curve25519.op_Star_Star_Percent", "Prims.op_Subtraction", "Spec.Curve25519.prime" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val finv (x: elem) : elem
[]
Spec.Curve25519.finv
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Spec.Curve25519.elem -> Spec.Curve25519.elem
{ "end_col": 44, "end_line": 30, "start_col": 27, "start_line": 30 }
Prims.Tot
val montgomery_ladder (init: elem) (k: scalar) : Tot proj_point
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let montgomery_ladder (init:elem) (k:scalar) : Tot proj_point = let q = (init, one) in let nq = (one, zero) in let nqp1 = (init, one) in // bit 255 is 0 and bit 254 is 1 let nq,nqp1 = cswap2 (u64 1) nq nqp1 in let nq,nqp1 = add_and_double q nq nqp1 in let swap = u64 1 in // bits 253-3 depend on scalar let nq,nqp1,swap = Lib.LoopCombinators.repeati 251 (ladder_step k q) (nq, nqp1, swap) in let nq,nqp1 = cswap2 swap nq nqp1 in // bits 2-0 are 0 let nq = double nq in let nq = double nq in let nq = double nq in nq
val montgomery_ladder (init: elem) (k: scalar) : Tot proj_point let montgomery_ladder (init: elem) (k: scalar) : Tot proj_point =
false
null
false
let q = (init, one) in let nq = (one, zero) in let nqp1 = (init, one) in let nq, nqp1 = cswap2 (u64 1) nq nqp1 in let nq, nqp1 = add_and_double q nq nqp1 in let swap = u64 1 in let nq, nqp1, swap = Lib.LoopCombinators.repeati 251 (ladder_step k q) (nq, nqp1, swap) in let nq, nqp1 = cswap2 swap nq nqp1 in let nq = double nq in let nq = double nq in let nq = double nq in nq
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Spec.Curve25519.elem", "Spec.Curve25519.scalar", "Spec.Curve25519.proj_point", "FStar.Pervasives.Native.tuple2", "Lib.IntTypes.uint64", "Spec.Curve25519.double", "Spec.Curve25519.cswap2", "FStar.Pervasives.Native.tuple3", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.LoopCombinators.repeati", "Spec.Curve25519.ladder_step", "FStar.Pervasives.Native.Mktuple3", "Prims.eq2", "Prims.int", "Lib.IntTypes.range", "Lib.IntTypes.v", "Lib.IntTypes.u64", "Spec.Curve25519.add_and_double", "FStar.Pervasives.Native.Mktuple2", "Spec.Curve25519.one", "Spec.Curve25519.zero" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow let finv (x:elem) : elem = x **% (prime - 2) let ( /% ) (x:elem) (y:elem) = x *% finv y (* Type aliases *) type scalar = lbytes 32 type serialized_point = lbytes 32 type proj_point = elem & elem let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 = let q = i / 8 in let r = size (i % 8) in to_u64 ((k.[q] >>. r) &. u8 1) let decodeScalar (k:scalar) = let k : scalar = k.[0] <- (k.[0] &. u8 248) in let k : scalar = k.[31] <- (k.[31] &. u8 127) in let k : scalar = k.[31] <- (k.[31] |. u8 64) in k let decodePoint (u:serialized_point) = (nat_from_bytes_le u % pow2 255) % prime let encodePoint (p:proj_point) : Tot serialized_point = let x, z = p in let p = x /% z in nat_to_bytes_le 32 p let add_and_double q nq nqp1 = let x_1, z_1 = q in let x_2, z_2 = nq in let x_3, z_3 = nqp1 in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3) let double nq = let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let aa = a *% a in let bb = b *% b in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in x_2, z_2 let cswap2 (sw:uint64) (nq:proj_point) (nqp1:proj_point) = let open Lib.RawIntTypes in if uint_to_nat sw = 1 then (nqp1, nq) else (nq, nqp1) let ladder_step (k:scalar) (q:proj_point) (i:nat{i < 251}) (nq, nqp1, swap) = let bit = ith_bit k (253-i) in let sw = swap ^. bit in let nq, nqp1 = cswap2 sw nq nqp1 in let nq, nqp1 = add_and_double q nq nqp1 in (nq, nqp1, bit)
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val montgomery_ladder (init: elem) (k: scalar) : Tot proj_point
[]
Spec.Curve25519.montgomery_ladder
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
init: Spec.Curve25519.elem -> k: Spec.Curve25519.scalar -> Spec.Curve25519.proj_point
{ "end_col": 4, "end_line": 118, "start_col": 63, "start_line": 103 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ladder_step (k:scalar) (q:proj_point) (i:nat{i < 251}) (nq, nqp1, swap) = let bit = ith_bit k (253-i) in let sw = swap ^. bit in let nq, nqp1 = cswap2 sw nq nqp1 in let nq, nqp1 = add_and_double q nq nqp1 in (nq, nqp1, bit)
let ladder_step (k: scalar) (q: proj_point) (i: nat{i < 251}) (nq, nqp1, swap) =
false
null
false
let bit = ith_bit k (253 - i) in let sw = swap ^. bit in let nq, nqp1 = cswap2 sw nq nqp1 in let nq, nqp1 = add_and_double q nq nqp1 in (nq, nqp1, bit)
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Spec.Curve25519.scalar", "Spec.Curve25519.proj_point", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Pervasives.Native.tuple3", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Pervasives.Native.tuple2", "Spec.Curve25519.elem", "FStar.Pervasives.Native.Mktuple3", "Lib.IntTypes.uint64", "Spec.Curve25519.add_and_double", "Spec.Curve25519.cswap2", "Lib.IntTypes.op_Hat_Dot", "Spec.Curve25519.ith_bit", "Prims.op_Subtraction" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow let finv (x:elem) : elem = x **% (prime - 2) let ( /% ) (x:elem) (y:elem) = x *% finv y (* Type aliases *) type scalar = lbytes 32 type serialized_point = lbytes 32 type proj_point = elem & elem let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 = let q = i / 8 in let r = size (i % 8) in to_u64 ((k.[q] >>. r) &. u8 1) let decodeScalar (k:scalar) = let k : scalar = k.[0] <- (k.[0] &. u8 248) in let k : scalar = k.[31] <- (k.[31] &. u8 127) in let k : scalar = k.[31] <- (k.[31] |. u8 64) in k let decodePoint (u:serialized_point) = (nat_from_bytes_le u % pow2 255) % prime let encodePoint (p:proj_point) : Tot serialized_point = let x, z = p in let p = x /% z in nat_to_bytes_le 32 p let add_and_double q nq nqp1 = let x_1, z_1 = q in let x_2, z_2 = nq in let x_3, z_3 = nqp1 in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3) let double nq = let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let aa = a *% a in let bb = b *% b in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in x_2, z_2 let cswap2 (sw:uint64) (nq:proj_point) (nqp1:proj_point) = let open Lib.RawIntTypes in if uint_to_nat sw = 1 then (nqp1, nq) else (nq, nqp1)
false
false
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ladder_step : k: Spec.Curve25519.scalar -> q: Spec.Curve25519.proj_point -> i: Prims.nat{i < 251} -> _: ((Spec.Curve25519.proj_point * Spec.Curve25519.proj_point) * Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC) -> ((Spec.Curve25519.elem * Spec.Curve25519.elem) * (Spec.Curve25519.elem * Spec.Curve25519.elem)) * Lib.IntTypes.uint64
[]
Spec.Curve25519.ladder_step
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Curve25519.scalar -> q: Spec.Curve25519.proj_point -> i: Prims.nat{i < 251} -> _: ((Spec.Curve25519.proj_point * Spec.Curve25519.proj_point) * Lib.IntTypes.int_t Lib.IntTypes.U64 Lib.IntTypes.SEC) -> ((Spec.Curve25519.elem * Spec.Curve25519.elem) * (Spec.Curve25519.elem * Spec.Curve25519.elem)) * Lib.IntTypes.uint64
{ "end_col": 17, "end_line": 101, "start_col": 77, "start_line": 96 }
Prims.Tot
val scalarmult (k: scalar) (u: serialized_point) : Tot serialized_point
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let scalarmult (k:scalar) (u:serialized_point) : Tot serialized_point = let u = decodePoint u in let res = montgomery_ladder u k in encodePoint res
val scalarmult (k: scalar) (u: serialized_point) : Tot serialized_point let scalarmult (k: scalar) (u: serialized_point) : Tot serialized_point =
false
null
false
let u = decodePoint u in let res = montgomery_ladder u k in encodePoint res
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Spec.Curve25519.scalar", "Spec.Curve25519.serialized_point", "Spec.Curve25519.encodePoint", "Spec.Curve25519.proj_point", "Spec.Curve25519.montgomery_ladder", "Prims.int", "Spec.Curve25519.decodePoint" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow let finv (x:elem) : elem = x **% (prime - 2) let ( /% ) (x:elem) (y:elem) = x *% finv y (* Type aliases *) type scalar = lbytes 32 type serialized_point = lbytes 32 type proj_point = elem & elem let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 = let q = i / 8 in let r = size (i % 8) in to_u64 ((k.[q] >>. r) &. u8 1) let decodeScalar (k:scalar) = let k : scalar = k.[0] <- (k.[0] &. u8 248) in let k : scalar = k.[31] <- (k.[31] &. u8 127) in let k : scalar = k.[31] <- (k.[31] |. u8 64) in k let decodePoint (u:serialized_point) = (nat_from_bytes_le u % pow2 255) % prime let encodePoint (p:proj_point) : Tot serialized_point = let x, z = p in let p = x /% z in nat_to_bytes_le 32 p let add_and_double q nq nqp1 = let x_1, z_1 = q in let x_2, z_2 = nq in let x_3, z_3 = nqp1 in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3) let double nq = let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let aa = a *% a in let bb = b *% b in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in x_2, z_2 let cswap2 (sw:uint64) (nq:proj_point) (nqp1:proj_point) = let open Lib.RawIntTypes in if uint_to_nat sw = 1 then (nqp1, nq) else (nq, nqp1) let ladder_step (k:scalar) (q:proj_point) (i:nat{i < 251}) (nq, nqp1, swap) = let bit = ith_bit k (253-i) in let sw = swap ^. bit in let nq, nqp1 = cswap2 sw nq nqp1 in let nq, nqp1 = add_and_double q nq nqp1 in (nq, nqp1, bit) let montgomery_ladder (init:elem) (k:scalar) : Tot proj_point = let q = (init, one) in let nq = (one, zero) in let nqp1 = (init, one) in // bit 255 is 0 and bit 254 is 1 let nq,nqp1 = cswap2 (u64 1) nq nqp1 in let nq,nqp1 = add_and_double q nq nqp1 in let swap = u64 1 in // bits 253-3 depend on scalar let nq,nqp1,swap = Lib.LoopCombinators.repeati 251 (ladder_step k q) (nq, nqp1, swap) in let nq,nqp1 = cswap2 swap nq nqp1 in // bits 2-0 are 0 let nq = double nq in let nq = double nq in let nq = double nq in nq
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val scalarmult (k: scalar) (u: serialized_point) : Tot serialized_point
[]
Spec.Curve25519.scalarmult
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Curve25519.scalar -> u41: Spec.Curve25519.serialized_point -> Spec.Curve25519.serialized_point
{ "end_col": 17, "end_line": 123, "start_col": 71, "start_line": 120 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add_and_double q nq nqp1 = let x_1, z_1 = q in let x_2, z_2 = nq in let x_3, z_3 = nqp1 in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3)
let add_and_double q nq nqp1 =
false
null
false
let x_1, z_1 = q in let x_2, z_2 = nq in let x_3, z_3 = nqp1 in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3)
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.tuple2", "Spec.Curve25519.elem", "FStar.Pervasives.Native.Mktuple2", "Spec.Curve25519.op_Star_Percent", "Spec.Curve25519.op_Plus_Percent", "Spec.Curve25519.op_Subtraction_Percent" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow let finv (x:elem) : elem = x **% (prime - 2) let ( /% ) (x:elem) (y:elem) = x *% finv y (* Type aliases *) type scalar = lbytes 32 type serialized_point = lbytes 32 type proj_point = elem & elem let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 = let q = i / 8 in let r = size (i % 8) in to_u64 ((k.[q] >>. r) &. u8 1) let decodeScalar (k:scalar) = let k : scalar = k.[0] <- (k.[0] &. u8 248) in let k : scalar = k.[31] <- (k.[31] &. u8 127) in let k : scalar = k.[31] <- (k.[31] |. u8 64) in k let decodePoint (u:serialized_point) = (nat_from_bytes_le u % pow2 255) % prime let encodePoint (p:proj_point) : Tot serialized_point = let x, z = p in let p = x /% z in nat_to_bytes_le 32 p
false
false
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val add_and_double : q: (Spec.Curve25519.elem * _) -> nq: (Spec.Curve25519.elem * Spec.Curve25519.elem) -> nqp1: (Spec.Curve25519.elem * Spec.Curve25519.elem) -> (Spec.Curve25519.elem * Spec.Curve25519.elem) * (Spec.Curve25519.elem * Spec.Curve25519.elem)
[]
Spec.Curve25519.add_and_double
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
q: (Spec.Curve25519.elem * _) -> nq: (Spec.Curve25519.elem * Spec.Curve25519.elem) -> nqp1: (Spec.Curve25519.elem * Spec.Curve25519.elem) -> (Spec.Curve25519.elem * Spec.Curve25519.elem) * (Spec.Curve25519.elem * Spec.Curve25519.elem)
{ "end_col": 24, "end_line": 77, "start_col": 30, "start_line": 55 }
Prims.Tot
val encodePoint (p: proj_point) : Tot serialized_point
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let encodePoint (p:proj_point) : Tot serialized_point = let x, z = p in let p = x /% z in nat_to_bytes_le 32 p
val encodePoint (p: proj_point) : Tot serialized_point let encodePoint (p: proj_point) : Tot serialized_point =
false
null
false
let x, z = p in let p = x /% z in nat_to_bytes_le 32 p
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Spec.Curve25519.proj_point", "Spec.Curve25519.elem", "Lib.ByteSequence.nat_to_bytes_le", "Lib.IntTypes.SEC", "Spec.Curve25519.op_Slash_Percent", "Spec.Curve25519.serialized_point" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow let finv (x:elem) : elem = x **% (prime - 2) let ( /% ) (x:elem) (y:elem) = x *% finv y (* Type aliases *) type scalar = lbytes 32 type serialized_point = lbytes 32 type proj_point = elem & elem let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 = let q = i / 8 in let r = size (i % 8) in to_u64 ((k.[q] >>. r) &. u8 1) let decodeScalar (k:scalar) = let k : scalar = k.[0] <- (k.[0] &. u8 248) in let k : scalar = k.[31] <- (k.[31] &. u8 127) in let k : scalar = k.[31] <- (k.[31] |. u8 64) in k let decodePoint (u:serialized_point) = (nat_from_bytes_le u % pow2 255) % prime
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val encodePoint (p: proj_point) : Tot serialized_point
[]
Spec.Curve25519.encodePoint
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Spec.Curve25519.proj_point -> Spec.Curve25519.serialized_point
{ "end_col": 22, "end_line": 53, "start_col": 55, "start_line": 50 }
Prims.Tot
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let decodeScalar (k:scalar) = let k : scalar = k.[0] <- (k.[0] &. u8 248) in let k : scalar = k.[31] <- (k.[31] &. u8 127) in let k : scalar = k.[31] <- (k.[31] |. u8 64) in k
let decodeScalar (k: scalar) =
false
null
false
let k:scalar = k.[ 0 ] <- (k.[ 0 ] &. u8 248) in let k:scalar = k.[ 31 ] <- (k.[ 31 ] &. u8 127) in let k:scalar = k.[ 31 ] <- (k.[ 31 ] |. u8 64) in k
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Spec.Curve25519.scalar", "Lib.Sequence.op_String_Assignment", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Bar_Dot", "Lib.Sequence.op_String_Access", "Lib.IntTypes.u8", "Lib.IntTypes.op_Amp_Dot" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow let finv (x:elem) : elem = x **% (prime - 2) let ( /% ) (x:elem) (y:elem) = x *% finv y (* Type aliases *) type scalar = lbytes 32 type serialized_point = lbytes 32 type proj_point = elem & elem let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 = let q = i / 8 in let r = size (i % 8) in to_u64 ((k.[q] >>. r) &. u8 1)
false
true
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val decodeScalar : k: Spec.Curve25519.scalar -> Spec.Curve25519.scalar
[]
Spec.Curve25519.decodeScalar
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Curve25519.scalar -> Spec.Curve25519.scalar
{ "end_col": 51, "end_line": 45, "start_col": 29, "start_line": 42 }
Prims.Tot
val ith_bit (k: scalar) (i: nat{i < 256}) : uint64
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 = let q = i / 8 in let r = size (i % 8) in to_u64 ((k.[q] >>. r) &. u8 1)
val ith_bit (k: scalar) (i: nat{i < 256}) : uint64 let ith_bit (k: scalar) (i: nat{i < 256}) : uint64 =
false
null
false
let q = i / 8 in let r = size (i % 8) in to_u64 ((k.[ q ] >>. r) &. u8 1)
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Spec.Curve25519.scalar", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.to_u64", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.op_Greater_Greater_Dot", "Lib.Sequence.op_String_Access", "Lib.IntTypes.uint_t", "Lib.IntTypes.u8", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.IntTypes.size", "Prims.op_Modulus", "Prims.int", "Prims.op_Division", "Lib.IntTypes.uint64" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow let finv (x:elem) : elem = x **% (prime - 2) let ( /% ) (x:elem) (y:elem) = x *% finv y (* Type aliases *) type scalar = lbytes 32 type serialized_point = lbytes 32 type proj_point = elem & elem
false
false
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ith_bit (k: scalar) (i: nat{i < 256}) : uint64
[]
Spec.Curve25519.ith_bit
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Curve25519.scalar -> i: Prims.nat{i < 256} -> Lib.IntTypes.uint64
{ "end_col": 32, "end_line": 40, "start_col": 50, "start_line": 38 }
Prims.Tot
val basepoint_lseq:Lib.Sequence.lseq byte_t 32
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let basepoint_lseq : Lib.Sequence.lseq byte_t 32 = Lib.Sequence.of_list basepoint_list
val basepoint_lseq:Lib.Sequence.lseq byte_t 32 let basepoint_lseq:Lib.Sequence.lseq byte_t 32 =
false
null
false
Lib.Sequence.of_list basepoint_list
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Lib.Sequence.of_list", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.PUB", "Spec.Curve25519.basepoint_list" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow let finv (x:elem) : elem = x **% (prime - 2) let ( /% ) (x:elem) (y:elem) = x *% finv y (* Type aliases *) type scalar = lbytes 32 type serialized_point = lbytes 32 type proj_point = elem & elem let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 = let q = i / 8 in let r = size (i % 8) in to_u64 ((k.[q] >>. r) &. u8 1) let decodeScalar (k:scalar) = let k : scalar = k.[0] <- (k.[0] &. u8 248) in let k : scalar = k.[31] <- (k.[31] &. u8 127) in let k : scalar = k.[31] <- (k.[31] |. u8 64) in k let decodePoint (u:serialized_point) = (nat_from_bytes_le u % pow2 255) % prime let encodePoint (p:proj_point) : Tot serialized_point = let x, z = p in let p = x /% z in nat_to_bytes_le 32 p let add_and_double q nq nqp1 = let x_1, z_1 = q in let x_2, z_2 = nq in let x_3, z_3 = nqp1 in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3) let double nq = let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let aa = a *% a in let bb = b *% b in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in x_2, z_2 let cswap2 (sw:uint64) (nq:proj_point) (nqp1:proj_point) = let open Lib.RawIntTypes in if uint_to_nat sw = 1 then (nqp1, nq) else (nq, nqp1) let ladder_step (k:scalar) (q:proj_point) (i:nat{i < 251}) (nq, nqp1, swap) = let bit = ith_bit k (253-i) in let sw = swap ^. bit in let nq, nqp1 = cswap2 sw nq nqp1 in let nq, nqp1 = add_and_double q nq nqp1 in (nq, nqp1, bit) let montgomery_ladder (init:elem) (k:scalar) : Tot proj_point = let q = (init, one) in let nq = (one, zero) in let nqp1 = (init, one) in // bit 255 is 0 and bit 254 is 1 let nq,nqp1 = cswap2 (u64 1) nq nqp1 in let nq,nqp1 = add_and_double q nq nqp1 in let swap = u64 1 in // bits 253-3 depend on scalar let nq,nqp1,swap = Lib.LoopCombinators.repeati 251 (ladder_step k q) (nq, nqp1, swap) in let nq,nqp1 = cswap2 swap nq nqp1 in // bits 2-0 are 0 let nq = double nq in let nq = double nq in let nq = double nq in nq let scalarmult (k:scalar) (u:serialized_point) : Tot serialized_point = let u = decodePoint u in let res = montgomery_ladder u k in encodePoint res inline_for_extraction let basepoint_list : x:list byte_t{List.Tot.length x == 32} = [@inline_let] let l = [9uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy] in assert_norm (List.Tot.length l == 32); l
false
false
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val basepoint_lseq:Lib.Sequence.lseq byte_t 32
[]
Spec.Curve25519.basepoint_lseq
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.PUB) 32
{ "end_col": 37, "end_line": 137, "start_col": 2, "start_line": 137 }
Prims.Tot
val secret_to_public: lbytes 32 -> lbytes 32
[ { "abbrev": false, "full_module": "Spec.Curve25519.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let secret_to_public kpriv = let basepoint = map secret basepoint_lseq in scalarmult kpriv basepoint
val secret_to_public: lbytes 32 -> lbytes 32 let secret_to_public kpriv =
false
null
false
let basepoint = map secret basepoint_lseq in scalarmult kpriv basepoint
{ "checked_file": "Spec.Curve25519.fst.checked", "dependencies": [ "Spec.Curve25519.Lemmas.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.RawIntTypes.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Curve25519.fst" }
[ "total" ]
[ "Lib.ByteSequence.lbytes", "Spec.Curve25519.scalarmult", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Prims.eq2", "Lib.Sequence.index", "Lib.IntTypes.secret", "Lib.IntTypes.PUB", "Spec.Curve25519.basepoint_lseq", "Lib.Sequence.map", "Lib.IntTypes.uint_t" ]
[]
module Spec.Curve25519 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Curve25519.Lemmas #set-options "--z3rlimit 30 --ifuel 0 --fuel 0" (* Field types and parameters *) let prime : pos = pow2 255 - 19 type elem = x:nat{x < prime} let zero : elem = 0 let one : elem = 1 let fadd (x:elem) (y:elem) : elem = (x + y) % prime let fsub (x:elem) (y:elem) : elem = (x - y) % prime let fmul (x:elem) (y:elem) : elem = (x * y) % prime let ( +% ) = fadd let ( -% ) = fsub let ( *% ) = fmul let fpow (x:elem) (b:nat) : elem = Lib.NatMod.pow_mod #prime x b let ( **% ) = fpow let finv (x:elem) : elem = x **% (prime - 2) let ( /% ) (x:elem) (y:elem) = x *% finv y (* Type aliases *) type scalar = lbytes 32 type serialized_point = lbytes 32 type proj_point = elem & elem let ith_bit (k:scalar) (i:nat{i < 256}) : uint64 = let q = i / 8 in let r = size (i % 8) in to_u64 ((k.[q] >>. r) &. u8 1) let decodeScalar (k:scalar) = let k : scalar = k.[0] <- (k.[0] &. u8 248) in let k : scalar = k.[31] <- (k.[31] &. u8 127) in let k : scalar = k.[31] <- (k.[31] |. u8 64) in k let decodePoint (u:serialized_point) = (nat_from_bytes_le u % pow2 255) % prime let encodePoint (p:proj_point) : Tot serialized_point = let x, z = p in let p = x /% z in nat_to_bytes_le 32 p let add_and_double q nq nqp1 = let x_1, z_1 = q in let x_2, z_2 = nq in let x_3, z_3 = nqp1 in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let c = x_3 +% z_3 in let d = x_3 -% z_3 in let da = d *% a in let cb = c *% b in let x_3 = da +% cb in let z_3 = da -% cb in let aa = a *% a in let bb = b *% b in let x_3 = x_3 *% x_3 in let z_3 = z_3 *% z_3 in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in let z_3 = z_3 *% x_1 in (x_2, z_2), (x_3, z_3) let double nq = let x_2, z_2 = nq in let a = x_2 +% z_2 in let b = x_2 -% z_2 in let aa = a *% a in let bb = b *% b in let e = aa -% bb in let e121665 = e *% 121665 in let aa_e121665 = e121665 +% aa in let x_2 = aa *% bb in let z_2 = e *% aa_e121665 in x_2, z_2 let cswap2 (sw:uint64) (nq:proj_point) (nqp1:proj_point) = let open Lib.RawIntTypes in if uint_to_nat sw = 1 then (nqp1, nq) else (nq, nqp1) let ladder_step (k:scalar) (q:proj_point) (i:nat{i < 251}) (nq, nqp1, swap) = let bit = ith_bit k (253-i) in let sw = swap ^. bit in let nq, nqp1 = cswap2 sw nq nqp1 in let nq, nqp1 = add_and_double q nq nqp1 in (nq, nqp1, bit) let montgomery_ladder (init:elem) (k:scalar) : Tot proj_point = let q = (init, one) in let nq = (one, zero) in let nqp1 = (init, one) in // bit 255 is 0 and bit 254 is 1 let nq,nqp1 = cswap2 (u64 1) nq nqp1 in let nq,nqp1 = add_and_double q nq nqp1 in let swap = u64 1 in // bits 253-3 depend on scalar let nq,nqp1,swap = Lib.LoopCombinators.repeati 251 (ladder_step k q) (nq, nqp1, swap) in let nq,nqp1 = cswap2 swap nq nqp1 in // bits 2-0 are 0 let nq = double nq in let nq = double nq in let nq = double nq in nq let scalarmult (k:scalar) (u:serialized_point) : Tot serialized_point = let u = decodePoint u in let res = montgomery_ladder u k in encodePoint res inline_for_extraction let basepoint_list : x:list byte_t{List.Tot.length x == 32} = [@inline_let] let l = [9uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy; 0uy] in assert_norm (List.Tot.length l == 32); l let basepoint_lseq : Lib.Sequence.lseq byte_t 32 = Lib.Sequence.of_list basepoint_list
false
false
Spec.Curve25519.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val secret_to_public: lbytes 32 -> lbytes 32
[]
Spec.Curve25519.secret_to_public
{ "file_name": "specs/Spec.Curve25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
kpriv: Lib.ByteSequence.lbytes 32 -> Lib.ByteSequence.lbytes 32
{ "end_col": 28, "end_line": 142, "start_col": 28, "start_line": 140 }
Prims.Pure
val sign_abs: a:nat -> b:nat -> Pure (tuple2 sign nat) (requires True) (ensures fun (s, res) -> res == abs a b /\ s == (if a < b then Negative else Positive))
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Karatsuba", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Karatsuba", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sign_abs a b = if a < b then (Negative, b - a) else (Positive, a - b)
val sign_abs: a:nat -> b:nat -> Pure (tuple2 sign nat) (requires True) (ensures fun (s, res) -> res == abs a b /\ s == (if a < b then Negative else Positive)) let sign_abs a b =
false
null
false
if a < b then (Negative, b - a) else (Positive, a - b)
{ "checked_file": "Hacl.Spec.Karatsuba.Lemmas.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Karatsuba.Lemmas.fst" }
[]
[ "Prims.nat", "Prims.op_LessThan", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.Karatsuba.Lemmas.sign", "Hacl.Spec.Karatsuba.Lemmas.Negative", "Prims.op_Subtraction", "Prims.bool", "Hacl.Spec.Karatsuba.Lemmas.Positive", "FStar.Pervasives.Native.tuple2" ]
[]
module Hacl.Spec.Karatsuba.Lemmas open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" type sign = | Positive | Negative let abs (a:nat) (b:nat) : nat = if a < b then b - a else a - b val sign_abs: a:nat -> b:nat -> Pure (tuple2 sign nat) (requires True) (ensures fun (s, res) -> res == abs a b /\ s == (if a < b then Negative else Positive))
false
false
Hacl.Spec.Karatsuba.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sign_abs: a:nat -> b:nat -> Pure (tuple2 sign nat) (requires True) (ensures fun (s, res) -> res == abs a b /\ s == (if a < b then Negative else Positive))
[]
Hacl.Spec.Karatsuba.Lemmas.sign_abs
{ "file_name": "code/bignum/Hacl.Spec.Karatsuba.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Prims.nat -> b: Prims.nat -> Prims.Pure (Hacl.Spec.Karatsuba.Lemmas.sign * Prims.nat)
{ "end_col": 56, "end_line": 22, "start_col": 2, "start_line": 22 }
Prims.Tot
val abs (a b: nat) : nat
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Karatsuba", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Karatsuba", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let abs (a:nat) (b:nat) : nat = if a < b then b - a else a - b
val abs (a b: nat) : nat let abs (a b: nat) : nat =
false
null
false
if a < b then b - a else a - b
{ "checked_file": "Hacl.Spec.Karatsuba.Lemmas.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Karatsuba.Lemmas.fst" }
[ "total" ]
[ "Prims.nat", "Prims.op_LessThan", "Prims.op_Subtraction", "Prims.bool" ]
[]
module Hacl.Spec.Karatsuba.Lemmas open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" type sign = | Positive | Negative
false
true
Hacl.Spec.Karatsuba.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val abs (a b: nat) : nat
[]
Hacl.Spec.Karatsuba.Lemmas.abs
{ "file_name": "code/bignum/Hacl.Spec.Karatsuba.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Prims.nat -> b: Prims.nat -> Prims.nat
{ "end_col": 32, "end_line": 13, "start_col": 2, "start_line": 13 }
FStar.Pervasives.Lemma
val lemma_double_p: pbits:pos -> aLen:nat{aLen % 2 = 0} -> Lemma (let p = pow2 (aLen / 2 * pbits) in p * p == pow2 (pbits * aLen))
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Karatsuba", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Karatsuba", "short_module": null }, { "abbrev": false, "full_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_double_p pbits aLen = let p = pow2 (aLen / 2 * pbits) in calc (==) { p * p; (==) { Math.Lemmas.pow2_plus (aLen / 2 * pbits) (aLen / 2 * pbits) } pow2 (aLen / 2 * pbits + aLen / 2 * pbits); (==) { Math.Lemmas.distributivity_add_left (aLen / 2) (aLen / 2) pbits } pow2 ((aLen / 2 * 2) * pbits); (==) { Math.Lemmas.lemma_div_exact aLen 2 } pow2 (aLen * pbits); }
val lemma_double_p: pbits:pos -> aLen:nat{aLen % 2 = 0} -> Lemma (let p = pow2 (aLen / 2 * pbits) in p * p == pow2 (pbits * aLen)) let lemma_double_p pbits aLen =
false
null
true
let p = pow2 ((aLen / 2) * pbits) in calc ( == ) { p * p; ( == ) { Math.Lemmas.pow2_plus ((aLen / 2) * pbits) ((aLen / 2) * pbits) } pow2 ((aLen / 2) * pbits + (aLen / 2) * pbits); ( == ) { Math.Lemmas.distributivity_add_left (aLen / 2) (aLen / 2) pbits } pow2 (((aLen / 2) * 2) * pbits); ( == ) { Math.Lemmas.lemma_div_exact aLen 2 } pow2 (aLen * pbits); }
{ "checked_file": "Hacl.Spec.Karatsuba.Lemmas.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Karatsuba.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "FStar.Calc.calc_finish", "Prims.eq2", "FStar.Mul.op_Star", "Prims.pow2", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Prims.op_Division", "Prims.op_Addition", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.pow2_plus", "Prims.squash", "FStar.Math.Lemmas.distributivity_add_left", "FStar.Math.Lemmas.lemma_div_exact" ]
[]
module Hacl.Spec.Karatsuba.Lemmas open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" type sign = | Positive | Negative let abs (a:nat) (b:nat) : nat = if a < b then b - a else a - b val sign_abs: a:nat -> b:nat -> Pure (tuple2 sign nat) (requires True) (ensures fun (s, res) -> res == abs a b /\ s == (if a < b then Negative else Positive)) let sign_abs a b = if a < b then (Negative, b - a) else (Positive, a - b) val lemma_double_p: pbits:pos -> aLen:nat{aLen % 2 = 0} ->
false
false
Hacl.Spec.Karatsuba.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_double_p: pbits:pos -> aLen:nat{aLen % 2 = 0} -> Lemma (let p = pow2 (aLen / 2 * pbits) in p * p == pow2 (pbits * aLen))
[]
Hacl.Spec.Karatsuba.Lemmas.lemma_double_p
{ "file_name": "code/bignum/Hacl.Spec.Karatsuba.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> aLen: Prims.nat{aLen % 2 = 0} -> FStar.Pervasives.Lemma (ensures (let p = Prims.pow2 ((aLen / 2) * pbits) in p * p == Prims.pow2 (pbits * aLen)))
{ "end_col": 5, "end_line": 37, "start_col": 31, "start_line": 27 }
FStar.Pervasives.Lemma
val lemma_bn_halves: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a:nat{a < pow2 (pbits * aLen)} -> Lemma (let p = pow2 (aLen / 2 * pbits) in a / p < p /\ a % p < p /\ a == a / p * p + a % p)
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Karatsuba", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Karatsuba", "short_module": null }, { "abbrev": false, "full_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_bn_halves pbits aLen a = lemma_double_p pbits aLen
val lemma_bn_halves: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a:nat{a < pow2 (pbits * aLen)} -> Lemma (let p = pow2 (aLen / 2 * pbits) in a / p < p /\ a % p < p /\ a == a / p * p + a % p) let lemma_bn_halves pbits aLen a =
false
null
true
lemma_double_p pbits aLen
{ "checked_file": "Hacl.Spec.Karatsuba.Lemmas.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Karatsuba.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.op_LessThan", "Prims.pow2", "FStar.Mul.op_Star", "Hacl.Spec.Karatsuba.Lemmas.lemma_double_p", "Prims.unit" ]
[]
module Hacl.Spec.Karatsuba.Lemmas open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" type sign = | Positive | Negative let abs (a:nat) (b:nat) : nat = if a < b then b - a else a - b val sign_abs: a:nat -> b:nat -> Pure (tuple2 sign nat) (requires True) (ensures fun (s, res) -> res == abs a b /\ s == (if a < b then Negative else Positive)) let sign_abs a b = if a < b then (Negative, b - a) else (Positive, a - b) val lemma_double_p: pbits:pos -> aLen:nat{aLen % 2 = 0} -> Lemma (let p = pow2 (aLen / 2 * pbits) in p * p == pow2 (pbits * aLen)) let lemma_double_p pbits aLen = let p = pow2 (aLen / 2 * pbits) in calc (==) { p * p; (==) { Math.Lemmas.pow2_plus (aLen / 2 * pbits) (aLen / 2 * pbits) } pow2 (aLen / 2 * pbits + aLen / 2 * pbits); (==) { Math.Lemmas.distributivity_add_left (aLen / 2) (aLen / 2) pbits } pow2 ((aLen / 2 * 2) * pbits); (==) { Math.Lemmas.lemma_div_exact aLen 2 } pow2 (aLen * pbits); } val lemma_bn_halves: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a:nat{a < pow2 (pbits * aLen)} ->
false
false
Hacl.Spec.Karatsuba.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_bn_halves: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a:nat{a < pow2 (pbits * aLen)} -> Lemma (let p = pow2 (aLen / 2 * pbits) in a / p < p /\ a % p < p /\ a == a / p * p + a % p)
[]
Hacl.Spec.Karatsuba.Lemmas.lemma_bn_halves
{ "file_name": "code/bignum/Hacl.Spec.Karatsuba.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> aLen: Prims.nat{aLen % 2 = 0} -> a: Prims.nat{a < Prims.pow2 (pbits * aLen)} -> FStar.Pervasives.Lemma (ensures (let p = Prims.pow2 ((aLen / 2) * pbits) in a / p < p /\ a % p < p /\ a == (a / p) * p + a % p))
{ "end_col": 60, "end_line": 42, "start_col": 35, "start_line": 42 }
FStar.Pervasives.Lemma
val lemma_middle_karatsuba: a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma (let s0, t0 = sign_abs a0 a1 in let s1, t1 = sign_abs b0 b1 in let t23 = t0 * t1 in let t01 = a0 * b0 + a1 * b1 in let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in t45 == a0 * b1 + a1 * b0)
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Karatsuba", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Karatsuba", "short_module": null }, { "abbrev": false, "full_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_middle_karatsuba a0 a1 b0 b1 = let s0, t0 = sign_abs a0 a1 in let s1, t1 = sign_abs b0 b1 in let t23 = t0 * t1 in let t01 = a0 * b0 + a1 * b1 in let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in match (s0, s1) with | (Positive, Positive) -> calc (==) { //t45 t01 - t23; (==) { } a0 * b0 + a1 * b1 - (a0 - a1) * (b0 - b1); (==) { Math.Lemmas.distributivity_sub_right (a0 - a1) b0 b1 } a0 * b0 + a1 * b1 - ((a0 - a1) * b0 - (a0 - a1) * b1); (==) { Math.Lemmas.distributivity_sub_left a0 a1 b0; Math.Lemmas.distributivity_sub_left a0 a1 b1 } a0 * b0 + a1 * b1 - (a0 * b0 - a1 * b0 - (a0 * b1 - a1 * b1)); (==) { } a1 * b0 + a0 * b1; } | (Negative, Negative) -> calc (==) { //t45 t01 - t23; (==) { } a0 * b0 + a1 * b1 - (a1 - a0) * (b1 - b0); (==) { Math.Lemmas.distributivity_sub_right (a1 - a0) b1 b0 } a0 * b0 + a1 * b1 - ((a1 - a0) * b1 - (a1 - a0) * b0); (==) { Math.Lemmas.distributivity_sub_left a1 a0 b1; Math.Lemmas.distributivity_sub_left a1 a0 b0 } a0 * b0 + a1 * b1 - (a1 * b1 - a0 * b1 - (a1 * b0 - a0 * b0)); (==) { } a1 * b0 + a0 * b1; } | (Positive, Negative) -> calc (==) { //t45 t01 + t23; (==) { } a0 * b0 + a1 * b1 + (a0 - a1) * (b1 - b0); (==) { Math.Lemmas.distributivity_sub_right (a0 - a1) b1 b0 } a0 * b0 + a1 * b1 + ((a0 - a1) * b1 - (a0 - a1) * b0); (==) { Math.Lemmas.distributivity_sub_left a0 a1 b1; Math.Lemmas.distributivity_sub_left a0 a1 b0 } a0 * b0 + a1 * b1 + (a0 * b1 - a1 * b1 - (a0 * b0 - a1 * b0)); (==) { } a1 * b0 + a0 * b1; } | (Negative, Positive) -> calc (==) { //t45 t01 + t23; (==) { } a0 * b0 + a1 * b1 + (a1 - a0) * (b0 - b1); (==) { Math.Lemmas.distributivity_sub_right (a1 - a0) b0 b1 } a0 * b0 + a1 * b1 + ((a1 - a0) * b0 - (a1 - a0) * b1); (==) { Math.Lemmas.distributivity_sub_left a1 a0 b0; Math.Lemmas.distributivity_sub_left a1 a0 b1 } a0 * b0 + a1 * b1 + (a1 * b0 - a0 * b0 - (a1 * b1 - a0 * b1)); (==) { } a1 * b0 + a0 * b1; }
val lemma_middle_karatsuba: a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma (let s0, t0 = sign_abs a0 a1 in let s1, t1 = sign_abs b0 b1 in let t23 = t0 * t1 in let t01 = a0 * b0 + a1 * b1 in let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in t45 == a0 * b1 + a1 * b0) let lemma_middle_karatsuba a0 a1 b0 b1 =
false
null
true
let s0, t0 = sign_abs a0 a1 in let s1, t1 = sign_abs b0 b1 in let t23 = t0 * t1 in let t01 = a0 * b0 + a1 * b1 in let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in match (s0, s1) with | Positive, Positive -> calc ( == ) { t01 - t23; ( == ) { () } a0 * b0 + a1 * b1 - (a0 - a1) * (b0 - b1); ( == ) { Math.Lemmas.distributivity_sub_right (a0 - a1) b0 b1 } a0 * b0 + a1 * b1 - ((a0 - a1) * b0 - (a0 - a1) * b1); ( == ) { (Math.Lemmas.distributivity_sub_left a0 a1 b0; Math.Lemmas.distributivity_sub_left a0 a1 b1) } a0 * b0 + a1 * b1 - (a0 * b0 - a1 * b0 - (a0 * b1 - a1 * b1)); ( == ) { () } a1 * b0 + a0 * b1; } | Negative, Negative -> calc ( == ) { t01 - t23; ( == ) { () } a0 * b0 + a1 * b1 - (a1 - a0) * (b1 - b0); ( == ) { Math.Lemmas.distributivity_sub_right (a1 - a0) b1 b0 } a0 * b0 + a1 * b1 - ((a1 - a0) * b1 - (a1 - a0) * b0); ( == ) { (Math.Lemmas.distributivity_sub_left a1 a0 b1; Math.Lemmas.distributivity_sub_left a1 a0 b0) } a0 * b0 + a1 * b1 - (a1 * b1 - a0 * b1 - (a1 * b0 - a0 * b0)); ( == ) { () } a1 * b0 + a0 * b1; } | Positive, Negative -> calc ( == ) { t01 + t23; ( == ) { () } a0 * b0 + a1 * b1 + (a0 - a1) * (b1 - b0); ( == ) { Math.Lemmas.distributivity_sub_right (a0 - a1) b1 b0 } a0 * b0 + a1 * b1 + ((a0 - a1) * b1 - (a0 - a1) * b0); ( == ) { (Math.Lemmas.distributivity_sub_left a0 a1 b1; Math.Lemmas.distributivity_sub_left a0 a1 b0) } a0 * b0 + a1 * b1 + (a0 * b1 - a1 * b1 - (a0 * b0 - a1 * b0)); ( == ) { () } a1 * b0 + a0 * b1; } | Negative, Positive -> calc ( == ) { t01 + t23; ( == ) { () } a0 * b0 + a1 * b1 + (a1 - a0) * (b0 - b1); ( == ) { Math.Lemmas.distributivity_sub_right (a1 - a0) b0 b1 } a0 * b0 + a1 * b1 + ((a1 - a0) * b0 - (a1 - a0) * b1); ( == ) { (Math.Lemmas.distributivity_sub_left a1 a0 b0; Math.Lemmas.distributivity_sub_left a1 a0 b1) } a0 * b0 + a1 * b1 + (a1 * b0 - a0 * b0 - (a1 * b1 - a0 * b1)); ( == ) { () } a1 * b0 + a0 * b1; }
{ "checked_file": "Hacl.Spec.Karatsuba.Lemmas.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Karatsuba.Lemmas.fst" }
[ "lemma" ]
[ "Prims.nat", "Hacl.Spec.Karatsuba.Lemmas.sign", "FStar.Pervasives.Native.Mktuple2", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Subtraction", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "FStar.Math.Lemmas.distributivity_sub_right", "FStar.Math.Lemmas.distributivity_sub_left", "Prims.op_Equality", "Prims.bool", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Karatsuba.Lemmas.sign_abs" ]
[]
module Hacl.Spec.Karatsuba.Lemmas open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" type sign = | Positive | Negative let abs (a:nat) (b:nat) : nat = if a < b then b - a else a - b val sign_abs: a:nat -> b:nat -> Pure (tuple2 sign nat) (requires True) (ensures fun (s, res) -> res == abs a b /\ s == (if a < b then Negative else Positive)) let sign_abs a b = if a < b then (Negative, b - a) else (Positive, a - b) val lemma_double_p: pbits:pos -> aLen:nat{aLen % 2 = 0} -> Lemma (let p = pow2 (aLen / 2 * pbits) in p * p == pow2 (pbits * aLen)) let lemma_double_p pbits aLen = let p = pow2 (aLen / 2 * pbits) in calc (==) { p * p; (==) { Math.Lemmas.pow2_plus (aLen / 2 * pbits) (aLen / 2 * pbits) } pow2 (aLen / 2 * pbits + aLen / 2 * pbits); (==) { Math.Lemmas.distributivity_add_left (aLen / 2) (aLen / 2) pbits } pow2 ((aLen / 2 * 2) * pbits); (==) { Math.Lemmas.lemma_div_exact aLen 2 } pow2 (aLen * pbits); } val lemma_bn_halves: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a:nat{a < pow2 (pbits * aLen)} -> Lemma (let p = pow2 (aLen / 2 * pbits) in a / p < p /\ a % p < p /\ a == a / p * p + a % p) let lemma_bn_halves pbits aLen a = lemma_double_p pbits aLen val lemma_middle_karatsuba: a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma (let s0, t0 = sign_abs a0 a1 in let s1, t1 = sign_abs b0 b1 in let t23 = t0 * t1 in let t01 = a0 * b0 + a1 * b1 in let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in t45 == a0 * b1 + a1 * b0)
false
false
Hacl.Spec.Karatsuba.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_middle_karatsuba: a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma (let s0, t0 = sign_abs a0 a1 in let s1, t1 = sign_abs b0 b1 in let t23 = t0 * t1 in let t01 = a0 * b0 + a1 * b1 in let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in t45 == a0 * b1 + a1 * b0)
[]
Hacl.Spec.Karatsuba.Lemmas.lemma_middle_karatsuba
{ "file_name": "code/bignum/Hacl.Spec.Karatsuba.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a0: Prims.nat -> a1: Prims.nat -> b0: Prims.nat -> b1: Prims.nat -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.Karatsuba.Lemmas.sign_abs a0 a1 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ s0 t0 = _ in let _ = Hacl.Spec.Karatsuba.Lemmas.sign_abs b0 b1 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ s1 t1 = _ in let t23 = t0 * t1 in let t01 = a0 * b0 + a1 * b1 in let t45 = (match s0 = s1 with | true -> t01 - t23 | _ -> t01 + t23) <: Prims.int in t45 == a0 * b1 + a1 * b0) <: Type0) <: Type0))
{ "end_col": 6, "end_line": 111, "start_col": 40, "start_line": 54 }
Prims.Tot
val karatsuba: pbits:pos // pbits = bits t -> aLen:nat -> a:nat{a < pow2 (pbits * aLen)} -> b:nat{b < pow2 (pbits * aLen)} -> Tot (res:nat{res == a * b}) (decreases aLen)
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Karatsuba", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Karatsuba", "short_module": null }, { "abbrev": false, "full_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 karatsuba pbits aLen a b = if aLen < 16 || aLen % 2 = 1 then a * b else begin let aLen2 = aLen / 2 in let p = pow2 (aLen2 * pbits) in let a0 = a % p in let a1 = a / p in let b0 = b % p in let b1 = b / p in lemma_bn_halves pbits aLen a; lemma_bn_halves pbits aLen b; let s0, t0 = sign_abs a0 a1 in let s1, t1 = sign_abs b0 b1 in let t23 = karatsuba pbits aLen2 t0 t1 in assert (t23 == t0 * t1); let r01 = karatsuba pbits aLen2 a0 b0 in assert (r01 == a0 * b0); let r23 = karatsuba pbits aLen2 a1 b1 in assert (r23 == a1 * b1); let t01 = r01 + r23 in assert (t01 == a0 * b0 + a1 * b1); let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in lemma_middle_karatsuba a0 a1 b0 b1; assert (t45 == a0 * b1 + a1 * b0); let res = r23 * pow2 (pbits * aLen) + t45 * p + r01 in lemma_karatsuba pbits aLen a0 a1 b0 b1; res end
val karatsuba: pbits:pos // pbits = bits t -> aLen:nat -> a:nat{a < pow2 (pbits * aLen)} -> b:nat{b < pow2 (pbits * aLen)} -> Tot (res:nat{res == a * b}) (decreases aLen) let rec karatsuba pbits aLen a b =
false
null
false
if aLen < 16 || aLen % 2 = 1 then a * b else let aLen2 = aLen / 2 in let p = pow2 (aLen2 * pbits) in let a0 = a % p in let a1 = a / p in let b0 = b % p in let b1 = b / p in lemma_bn_halves pbits aLen a; lemma_bn_halves pbits aLen b; let s0, t0 = sign_abs a0 a1 in let s1, t1 = sign_abs b0 b1 in let t23 = karatsuba pbits aLen2 t0 t1 in assert (t23 == t0 * t1); let r01 = karatsuba pbits aLen2 a0 b0 in assert (r01 == a0 * b0); let r23 = karatsuba pbits aLen2 a1 b1 in assert (r23 == a1 * b1); let t01 = r01 + r23 in assert (t01 == a0 * b0 + a1 * b1); let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in lemma_middle_karatsuba a0 a1 b0 b1; assert (t45 == a0 * b1 + a1 * b0); let res = r23 * pow2 (pbits * aLen) + t45 * p + r01 in lemma_karatsuba pbits aLen a0 a1 b0 b1; res
{ "checked_file": "Hacl.Spec.Karatsuba.Lemmas.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Karatsuba.Lemmas.fst" }
[ "total", "" ]
[ "Prims.pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Mul.op_Star", "Prims.op_BarBar", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.bool", "Hacl.Spec.Karatsuba.Lemmas.sign", "Prims.unit", "Hacl.Spec.Karatsuba.Lemmas.lemma_karatsuba", "Prims.op_Addition", "Prims._assert", "Prims.eq2", "Hacl.Spec.Karatsuba.Lemmas.lemma_middle_karatsuba", "Prims.op_Subtraction", "Prims.op_Multiply", "Hacl.Spec.Karatsuba.Lemmas.karatsuba", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Karatsuba.Lemmas.sign_abs", "Hacl.Spec.Karatsuba.Lemmas.lemma_bn_halves", "Prims.op_Division" ]
[]
module Hacl.Spec.Karatsuba.Lemmas open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" type sign = | Positive | Negative let abs (a:nat) (b:nat) : nat = if a < b then b - a else a - b val sign_abs: a:nat -> b:nat -> Pure (tuple2 sign nat) (requires True) (ensures fun (s, res) -> res == abs a b /\ s == (if a < b then Negative else Positive)) let sign_abs a b = if a < b then (Negative, b - a) else (Positive, a - b) val lemma_double_p: pbits:pos -> aLen:nat{aLen % 2 = 0} -> Lemma (let p = pow2 (aLen / 2 * pbits) in p * p == pow2 (pbits * aLen)) let lemma_double_p pbits aLen = let p = pow2 (aLen / 2 * pbits) in calc (==) { p * p; (==) { Math.Lemmas.pow2_plus (aLen / 2 * pbits) (aLen / 2 * pbits) } pow2 (aLen / 2 * pbits + aLen / 2 * pbits); (==) { Math.Lemmas.distributivity_add_left (aLen / 2) (aLen / 2) pbits } pow2 ((aLen / 2 * 2) * pbits); (==) { Math.Lemmas.lemma_div_exact aLen 2 } pow2 (aLen * pbits); } val lemma_bn_halves: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a:nat{a < pow2 (pbits * aLen)} -> Lemma (let p = pow2 (aLen / 2 * pbits) in a / p < p /\ a % p < p /\ a == a / p * p + a % p) let lemma_bn_halves pbits aLen a = lemma_double_p pbits aLen val lemma_middle_karatsuba: a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma (let s0, t0 = sign_abs a0 a1 in let s1, t1 = sign_abs b0 b1 in let t23 = t0 * t1 in let t01 = a0 * b0 + a1 * b1 in let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in t45 == a0 * b1 + a1 * b0) let lemma_middle_karatsuba a0 a1 b0 b1 = let s0, t0 = sign_abs a0 a1 in let s1, t1 = sign_abs b0 b1 in let t23 = t0 * t1 in let t01 = a0 * b0 + a1 * b1 in let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in match (s0, s1) with | (Positive, Positive) -> calc (==) { //t45 t01 - t23; (==) { } a0 * b0 + a1 * b1 - (a0 - a1) * (b0 - b1); (==) { Math.Lemmas.distributivity_sub_right (a0 - a1) b0 b1 } a0 * b0 + a1 * b1 - ((a0 - a1) * b0 - (a0 - a1) * b1); (==) { Math.Lemmas.distributivity_sub_left a0 a1 b0; Math.Lemmas.distributivity_sub_left a0 a1 b1 } a0 * b0 + a1 * b1 - (a0 * b0 - a1 * b0 - (a0 * b1 - a1 * b1)); (==) { } a1 * b0 + a0 * b1; } | (Negative, Negative) -> calc (==) { //t45 t01 - t23; (==) { } a0 * b0 + a1 * b1 - (a1 - a0) * (b1 - b0); (==) { Math.Lemmas.distributivity_sub_right (a1 - a0) b1 b0 } a0 * b0 + a1 * b1 - ((a1 - a0) * b1 - (a1 - a0) * b0); (==) { Math.Lemmas.distributivity_sub_left a1 a0 b1; Math.Lemmas.distributivity_sub_left a1 a0 b0 } a0 * b0 + a1 * b1 - (a1 * b1 - a0 * b1 - (a1 * b0 - a0 * b0)); (==) { } a1 * b0 + a0 * b1; } | (Positive, Negative) -> calc (==) { //t45 t01 + t23; (==) { } a0 * b0 + a1 * b1 + (a0 - a1) * (b1 - b0); (==) { Math.Lemmas.distributivity_sub_right (a0 - a1) b1 b0 } a0 * b0 + a1 * b1 + ((a0 - a1) * b1 - (a0 - a1) * b0); (==) { Math.Lemmas.distributivity_sub_left a0 a1 b1; Math.Lemmas.distributivity_sub_left a0 a1 b0 } a0 * b0 + a1 * b1 + (a0 * b1 - a1 * b1 - (a0 * b0 - a1 * b0)); (==) { } a1 * b0 + a0 * b1; } | (Negative, Positive) -> calc (==) { //t45 t01 + t23; (==) { } a0 * b0 + a1 * b1 + (a1 - a0) * (b0 - b1); (==) { Math.Lemmas.distributivity_sub_right (a1 - a0) b0 b1 } a0 * b0 + a1 * b1 + ((a1 - a0) * b0 - (a1 - a0) * b1); (==) { Math.Lemmas.distributivity_sub_left a1 a0 b0; Math.Lemmas.distributivity_sub_left a1 a0 b1 } a0 * b0 + a1 * b1 + (a1 * b0 - a0 * b0 - (a1 * b1 - a0 * b1)); (==) { } a1 * b0 + a0 * b1; } val lemma_karatsuba: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma (let aLen2 = aLen / 2 in let p = pow2 (pbits * aLen2) in let a = a1 * p + a0 in let b = b1 * p + b0 in a1 * b1 * pow2 (pbits * aLen) + (a0 * b1 + a1 * b0) * p + a0 * b0 == a * b) #push-options "--z3rlimit 200" let lemma_karatsuba pbits aLen a0 a1 b0 b1 = let aLen2 = aLen / 2 in let p = pow2 (pbits * aLen2) in let a = a1 * p + a0 in let b = b1 * p + b0 in calc (==) { a * b; (==) { } (a1 * p + a0) * (b1 * p + b0); (==) { Math.Lemmas.distributivity_add_left (a1 * p) a0 (b1 * p + b0) } a1 * p * (b1 * p + b0) + a0 * (b1 * p + b0); (==) { Math.Lemmas.distributivity_add_right (a1 * p) (b1 * p) b0; Math.Lemmas.distributivity_add_right a0 (b1 * p) b0 } a1 * p * (b1 * p) + a1 * p * b0 + a0 * (b1 * p) + a0 * b0; (==) { Math.Lemmas.paren_mul_right a0 b1 p } a1 * p * (b1 * p) + a1 * p * b0 + a0 * b1 * p + a0 * b0; (==) { Math.Lemmas.paren_mul_right a1 p (b1 * p); Math.Lemmas.swap_mul b1 p; Math.Lemmas.paren_mul_right p p b1; Math.Lemmas.swap_mul b1 (p * p) } a1 * (b1 * (p * p)) + a1 * p * b0 + a0 * b1 * p + a0 * b0; (==) { Math.Lemmas.paren_mul_right a1 b1 (p * p) } a1 * b1 * (p * p) + a1 * p * b0 + a0 * b1 * p + a0 * b0; (==) { lemma_double_p pbits aLen } a1 * b1 * pow2 (pbits * aLen) + a1 * p * b0 + a0 * b1 * p + a0 * b0; (==) { Math.Lemmas.paren_mul_right a1 p b0; Math.Lemmas.swap_mul b0 p; Math.Lemmas.paren_mul_right a1 b0 p } a1 * b1 * pow2 (pbits * aLen) + a1 * b0 * p + a0 * b1 * p + a0 * b0; (==) { Math.Lemmas.distributivity_add_left (a1 * b0) (a0 * b1) p } a1 * b1 * pow2 (pbits * aLen) + (a1 * b0 + a0 * b1) * p + a0 * b0; } #pop-options val karatsuba: pbits:pos // pbits = bits t -> aLen:nat -> a:nat{a < pow2 (pbits * aLen)} -> b:nat{b < pow2 (pbits * aLen)} -> Tot (res:nat{res == a * b}) (decreases aLen)
false
false
Hacl.Spec.Karatsuba.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val karatsuba: pbits:pos // pbits = bits t -> aLen:nat -> a:nat{a < pow2 (pbits * aLen)} -> b:nat{b < pow2 (pbits * aLen)} -> Tot (res:nat{res == a * b}) (decreases aLen)
[ "recursion" ]
Hacl.Spec.Karatsuba.Lemmas.karatsuba
{ "file_name": "code/bignum/Hacl.Spec.Karatsuba.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> aLen: Prims.nat -> a: Prims.nat{a < Prims.pow2 (pbits * aLen)} -> b: Prims.nat{b < Prims.pow2 (pbits * aLen)} -> Prims.Tot (res: Prims.nat{res == a * b})
{ "end_col": 11, "end_line": 185, "start_col": 2, "start_line": 161 }
FStar.Pervasives.Lemma
val lemma_karatsuba: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma (let aLen2 = aLen / 2 in let p = pow2 (pbits * aLen2) in let a = a1 * p + a0 in let b = b1 * p + b0 in a1 * b1 * pow2 (pbits * aLen) + (a0 * b1 + a1 * b0) * p + a0 * b0 == a * b)
[ { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Karatsuba", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Karatsuba", "short_module": null }, { "abbrev": false, "full_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_karatsuba pbits aLen a0 a1 b0 b1 = let aLen2 = aLen / 2 in let p = pow2 (pbits * aLen2) in let a = a1 * p + a0 in let b = b1 * p + b0 in calc (==) { a * b; (==) { } (a1 * p + a0) * (b1 * p + b0); (==) { Math.Lemmas.distributivity_add_left (a1 * p) a0 (b1 * p + b0) } a1 * p * (b1 * p + b0) + a0 * (b1 * p + b0); (==) { Math.Lemmas.distributivity_add_right (a1 * p) (b1 * p) b0; Math.Lemmas.distributivity_add_right a0 (b1 * p) b0 } a1 * p * (b1 * p) + a1 * p * b0 + a0 * (b1 * p) + a0 * b0; (==) { Math.Lemmas.paren_mul_right a0 b1 p } a1 * p * (b1 * p) + a1 * p * b0 + a0 * b1 * p + a0 * b0; (==) { Math.Lemmas.paren_mul_right a1 p (b1 * p); Math.Lemmas.swap_mul b1 p; Math.Lemmas.paren_mul_right p p b1; Math.Lemmas.swap_mul b1 (p * p) } a1 * (b1 * (p * p)) + a1 * p * b0 + a0 * b1 * p + a0 * b0; (==) { Math.Lemmas.paren_mul_right a1 b1 (p * p) } a1 * b1 * (p * p) + a1 * p * b0 + a0 * b1 * p + a0 * b0; (==) { lemma_double_p pbits aLen } a1 * b1 * pow2 (pbits * aLen) + a1 * p * b0 + a0 * b1 * p + a0 * b0; (==) { Math.Lemmas.paren_mul_right a1 p b0; Math.Lemmas.swap_mul b0 p; Math.Lemmas.paren_mul_right a1 b0 p } a1 * b1 * pow2 (pbits * aLen) + a1 * b0 * p + a0 * b1 * p + a0 * b0; (==) { Math.Lemmas.distributivity_add_left (a1 * b0) (a0 * b1) p } a1 * b1 * pow2 (pbits * aLen) + (a1 * b0 + a0 * b1) * p + a0 * b0; }
val lemma_karatsuba: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma (let aLen2 = aLen / 2 in let p = pow2 (pbits * aLen2) in let a = a1 * p + a0 in let b = b1 * p + b0 in a1 * b1 * pow2 (pbits * aLen) + (a0 * b1 + a1 * b0) * p + a0 * b0 == a * b) let lemma_karatsuba pbits aLen a0 a1 b0 b1 =
false
null
true
let aLen2 = aLen / 2 in let p = pow2 (pbits * aLen2) in let a = a1 * p + a0 in let b = b1 * p + b0 in calc ( == ) { a * b; ( == ) { () } (a1 * p + a0) * (b1 * p + b0); ( == ) { Math.Lemmas.distributivity_add_left (a1 * p) a0 (b1 * p + b0) } (a1 * p) * (b1 * p + b0) + a0 * (b1 * p + b0); ( == ) { (Math.Lemmas.distributivity_add_right (a1 * p) (b1 * p) b0; Math.Lemmas.distributivity_add_right a0 (b1 * p) b0) } (a1 * p) * (b1 * p) + (a1 * p) * b0 + a0 * (b1 * p) + a0 * b0; ( == ) { Math.Lemmas.paren_mul_right a0 b1 p } (a1 * p) * (b1 * p) + (a1 * p) * b0 + (a0 * b1) * p + a0 * b0; ( == ) { (Math.Lemmas.paren_mul_right a1 p (b1 * p); Math.Lemmas.swap_mul b1 p; Math.Lemmas.paren_mul_right p p b1; Math.Lemmas.swap_mul b1 (p * p)) } a1 * (b1 * (p * p)) + (a1 * p) * b0 + (a0 * b1) * p + a0 * b0; ( == ) { Math.Lemmas.paren_mul_right a1 b1 (p * p) } (a1 * b1) * (p * p) + (a1 * p) * b0 + (a0 * b1) * p + a0 * b0; ( == ) { lemma_double_p pbits aLen } (a1 * b1) * pow2 (pbits * aLen) + (a1 * p) * b0 + (a0 * b1) * p + a0 * b0; ( == ) { (Math.Lemmas.paren_mul_right a1 p b0; Math.Lemmas.swap_mul b0 p; Math.Lemmas.paren_mul_right a1 b0 p) } (a1 * b1) * pow2 (pbits * aLen) + (a1 * b0) * p + (a0 * b1) * p + a0 * b0; ( == ) { Math.Lemmas.distributivity_add_left (a1 * b0) (a0 * b1) p } (a1 * b1) * pow2 (pbits * aLen) + (a1 * b0 + a0 * b1) * p + a0 * b0; }
{ "checked_file": "Hacl.Spec.Karatsuba.Lemmas.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Karatsuba.Lemmas.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "FStar.Calc.calc_finish", "Prims.eq2", "FStar.Mul.op_Star", "Prims.op_Addition", "Prims.pow2", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "FStar.Math.Lemmas.distributivity_add_left", "FStar.Math.Lemmas.distributivity_add_right", "FStar.Math.Lemmas.paren_mul_right", "FStar.Math.Lemmas.swap_mul", "Hacl.Spec.Karatsuba.Lemmas.lemma_double_p", "Prims.op_Division" ]
[]
module Hacl.Spec.Karatsuba.Lemmas open FStar.Mul open Lib.IntTypes #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" type sign = | Positive | Negative let abs (a:nat) (b:nat) : nat = if a < b then b - a else a - b val sign_abs: a:nat -> b:nat -> Pure (tuple2 sign nat) (requires True) (ensures fun (s, res) -> res == abs a b /\ s == (if a < b then Negative else Positive)) let sign_abs a b = if a < b then (Negative, b - a) else (Positive, a - b) val lemma_double_p: pbits:pos -> aLen:nat{aLen % 2 = 0} -> Lemma (let p = pow2 (aLen / 2 * pbits) in p * p == pow2 (pbits * aLen)) let lemma_double_p pbits aLen = let p = pow2 (aLen / 2 * pbits) in calc (==) { p * p; (==) { Math.Lemmas.pow2_plus (aLen / 2 * pbits) (aLen / 2 * pbits) } pow2 (aLen / 2 * pbits + aLen / 2 * pbits); (==) { Math.Lemmas.distributivity_add_left (aLen / 2) (aLen / 2) pbits } pow2 ((aLen / 2 * 2) * pbits); (==) { Math.Lemmas.lemma_div_exact aLen 2 } pow2 (aLen * pbits); } val lemma_bn_halves: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a:nat{a < pow2 (pbits * aLen)} -> Lemma (let p = pow2 (aLen / 2 * pbits) in a / p < p /\ a % p < p /\ a == a / p * p + a % p) let lemma_bn_halves pbits aLen a = lemma_double_p pbits aLen val lemma_middle_karatsuba: a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma (let s0, t0 = sign_abs a0 a1 in let s1, t1 = sign_abs b0 b1 in let t23 = t0 * t1 in let t01 = a0 * b0 + a1 * b1 in let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in t45 == a0 * b1 + a1 * b0) let lemma_middle_karatsuba a0 a1 b0 b1 = let s0, t0 = sign_abs a0 a1 in let s1, t1 = sign_abs b0 b1 in let t23 = t0 * t1 in let t01 = a0 * b0 + a1 * b1 in let t45 = if s0 = s1 then t01 - t23 else t01 + t23 in match (s0, s1) with | (Positive, Positive) -> calc (==) { //t45 t01 - t23; (==) { } a0 * b0 + a1 * b1 - (a0 - a1) * (b0 - b1); (==) { Math.Lemmas.distributivity_sub_right (a0 - a1) b0 b1 } a0 * b0 + a1 * b1 - ((a0 - a1) * b0 - (a0 - a1) * b1); (==) { Math.Lemmas.distributivity_sub_left a0 a1 b0; Math.Lemmas.distributivity_sub_left a0 a1 b1 } a0 * b0 + a1 * b1 - (a0 * b0 - a1 * b0 - (a0 * b1 - a1 * b1)); (==) { } a1 * b0 + a0 * b1; } | (Negative, Negative) -> calc (==) { //t45 t01 - t23; (==) { } a0 * b0 + a1 * b1 - (a1 - a0) * (b1 - b0); (==) { Math.Lemmas.distributivity_sub_right (a1 - a0) b1 b0 } a0 * b0 + a1 * b1 - ((a1 - a0) * b1 - (a1 - a0) * b0); (==) { Math.Lemmas.distributivity_sub_left a1 a0 b1; Math.Lemmas.distributivity_sub_left a1 a0 b0 } a0 * b0 + a1 * b1 - (a1 * b1 - a0 * b1 - (a1 * b0 - a0 * b0)); (==) { } a1 * b0 + a0 * b1; } | (Positive, Negative) -> calc (==) { //t45 t01 + t23; (==) { } a0 * b0 + a1 * b1 + (a0 - a1) * (b1 - b0); (==) { Math.Lemmas.distributivity_sub_right (a0 - a1) b1 b0 } a0 * b0 + a1 * b1 + ((a0 - a1) * b1 - (a0 - a1) * b0); (==) { Math.Lemmas.distributivity_sub_left a0 a1 b1; Math.Lemmas.distributivity_sub_left a0 a1 b0 } a0 * b0 + a1 * b1 + (a0 * b1 - a1 * b1 - (a0 * b0 - a1 * b0)); (==) { } a1 * b0 + a0 * b1; } | (Negative, Positive) -> calc (==) { //t45 t01 + t23; (==) { } a0 * b0 + a1 * b1 + (a1 - a0) * (b0 - b1); (==) { Math.Lemmas.distributivity_sub_right (a1 - a0) b0 b1 } a0 * b0 + a1 * b1 + ((a1 - a0) * b0 - (a1 - a0) * b1); (==) { Math.Lemmas.distributivity_sub_left a1 a0 b0; Math.Lemmas.distributivity_sub_left a1 a0 b1 } a0 * b0 + a1 * b1 + (a1 * b0 - a0 * b0 - (a1 * b1 - a0 * b1)); (==) { } a1 * b0 + a0 * b1; } val lemma_karatsuba: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma (let aLen2 = aLen / 2 in let p = pow2 (pbits * aLen2) in let a = a1 * p + a0 in let b = b1 * p + b0 in a1 * b1 * pow2 (pbits * aLen) + (a0 * b1 + a1 * b0) * p + a0 * b0 == a * b)
false
false
Hacl.Spec.Karatsuba.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_karatsuba: pbits:pos -> aLen:nat{aLen % 2 = 0} -> a0:nat -> a1:nat -> b0:nat -> b1:nat -> Lemma (let aLen2 = aLen / 2 in let p = pow2 (pbits * aLen2) in let a = a1 * p + a0 in let b = b1 * p + b0 in a1 * b1 * pow2 (pbits * aLen) + (a0 * b1 + a1 * b0) * p + a0 * b0 == a * b)
[]
Hacl.Spec.Karatsuba.Lemmas.lemma_karatsuba
{ "file_name": "code/bignum/Hacl.Spec.Karatsuba.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
pbits: Prims.pos -> aLen: Prims.nat{aLen % 2 = 0} -> a0: Prims.nat -> a1: Prims.nat -> b0: Prims.nat -> b1: Prims.nat -> FStar.Pervasives.Lemma (ensures (let aLen2 = aLen / 2 in let p = Prims.pow2 (pbits * aLen2) in let a = a1 * p + a0 in let b = b1 * p + b0 in (a1 * b1) * Prims.pow2 (pbits * aLen) + (a0 * b1 + a1 * b0) * p + a0 * b0 == a * b))
{ "end_col": 4, "end_line": 150, "start_col": 44, "start_line": 122 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let compute_iv_BE = opaque_make compute_iv_BE_def
let compute_iv_BE =
false
null
false
opaque_make compute_iv_BE_def
{ "checked_file": "Vale.AES.GCM_s.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.GCM_s.fst" }
[ "total" ]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.Def.Types_s.quad32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.AES.GCM_s.compute_iv_BE_def" ]
[]
module Vale.AES.GCM_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GHash_s open FStar.Seq open FStar.Mul unfold type gcm_plain_LE = gctr_plain_LE unfold type gcm_auth_LE = gctr_plain_LE #reset-options "--z3rlimit 30" type supported_iv_LE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 } let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32 = if 8 * (length iv) = 96 then ( let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in let iv_BE = reverse_bytes_quad32 iv_LE in let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in j0_BE ) else ( let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in let length_LE = reverse_bytes_quad32 length_BE in let hash_input_LE = append padded_iv_quads (create 1 length_LE) in let hash_output_LE = ghash_LE h_LE hash_input_LE in reverse_bytes_quad32 hash_output_LE
false
true
Vale.AES.GCM_s.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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val compute_iv_BE : _: Vale.Def.Types_s.quad32 -> _: Vale.AES.GCM_s.supported_iv_LE -> Vale.Def.Types_s.quad32
[]
Vale.AES.GCM_s.compute_iv_BE
{ "file_name": "vale/specs/crypto/Vale.AES.GCM_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Vale.Def.Types_s.quad32 -> _: Vale.AES.GCM_s.supported_iv_LE -> Vale.Def.Types_s.quad32
{ "end_col": 68, "end_line": 35, "start_col": 39, "start_line": 35 }
FStar.Pervasives.Lemma
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def
let compute_iv_BE_reveal =
false
null
true
opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def
{ "checked_file": "Vale.AES.GCM_s.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.GCM_s.fst" }
[ "lemma" ]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.Def.Types_s.quad32", "Vale.AES.GCM_s.supported_iv_LE", "Vale.AES.GCM_s.compute_iv_BE", "Vale.AES.GCM_s.compute_iv_BE_def" ]
[]
module Vale.AES.GCM_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GHash_s open FStar.Seq open FStar.Mul unfold type gcm_plain_LE = gctr_plain_LE unfold type gcm_auth_LE = gctr_plain_LE #reset-options "--z3rlimit 30" type supported_iv_LE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 } let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32 = if 8 * (length iv) = 96 then ( let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in let iv_BE = reverse_bytes_quad32 iv_LE in let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in j0_BE ) else ( let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in let length_LE = reverse_bytes_quad32 length_BE in let hash_input_LE = append padded_iv_quads (create 1 length_LE) in let hash_output_LE = ghash_LE h_LE hash_input_LE in reverse_bytes_quad32 hash_output_LE )
false
false
Vale.AES.GCM_s.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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val compute_iv_BE_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.AES.GCM_s.compute_iv_BE == Vale.AES.GCM_s.compute_iv_BE_def)
[]
Vale.AES.GCM_s.compute_iv_BE_reveal
{ "file_name": "vale/specs/crypto/Vale.AES.GCM_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.AES.GCM_s.compute_iv_BE == Vale.AES.GCM_s.compute_iv_BE_def)
{ "end_col": 104, "end_line": 36, "start_col": 39, "start_line": 36 }
FStar.Pervasives.Lemma
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gcm_encrypt_LE_reveal = opaque_revealer (`%gcm_encrypt_LE) gcm_encrypt_LE gcm_encrypt_LE_def
let gcm_encrypt_LE_reveal =
false
null
true
opaque_revealer (`%gcm_encrypt_LE) gcm_encrypt_LE gcm_encrypt_LE_def
{ "checked_file": "Vale.AES.GCM_s.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.GCM_s.fst" }
[ "lemma" ]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Vale.AES.GCM_s.supported_iv_LE", "FStar.Pervasives.Native.tuple2", "Prims.l_and", "Vale.AES.AES_common_s.is_aes_key", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.Def.Words_s.pow2_32", "Prims.l_True", "Vale.AES.GCM_s.gcm_encrypt_LE", "Vale.AES.GCM_s.gcm_encrypt_LE_def" ]
[]
module Vale.AES.GCM_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GHash_s open FStar.Seq open FStar.Mul unfold type gcm_plain_LE = gctr_plain_LE unfold type gcm_auth_LE = gctr_plain_LE #reset-options "--z3rlimit 30" type supported_iv_LE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 } let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32 = if 8 * (length iv) = 96 then ( let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in let iv_BE = reverse_bytes_quad32 iv_LE in let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in j0_BE ) else ( let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in let length_LE = reverse_bytes_quad32 length_BE in let hash_input_LE = append padded_iv_quads (create 1 length_LE) in let hash_output_LE = ghash_LE h_LE hash_input_LE in reverse_bytes_quad32 hash_output_LE ) [@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def // little-endian let gcm_encrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (plain:seq nat8) (auth:seq nat8) : Pure (seq nat8 & seq nat8) (requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32 ) (ensures fun (c, t) -> True) = let key_LE = seq_nat8_to_seq_nat32_LE key in let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in let j0_BE = compute_iv_BE h_LE iv in let c = gctr_encrypt_LE (inc32 j0_BE 1) plain alg key_LE in // Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0 in let lengths_LE = reverse_bytes_quad32 lengths_BE in let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits c) in let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in let s_LE = ghash_LE h_LE hash_input_LE in let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in (c, t)
false
false
Vale.AES.GCM_s.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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm_encrypt_LE_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.AES.GCM_s.gcm_encrypt_LE == Vale.AES.GCM_s.gcm_encrypt_LE_def)
[]
Vale.AES.GCM_s.gcm_encrypt_LE_reveal
{ "file_name": "vale/specs/crypto/Vale.AES.GCM_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.AES.GCM_s.gcm_encrypt_LE == Vale.AES.GCM_s.gcm_encrypt_LE_def)
{ "end_col": 108, "end_line": 67, "start_col": 40, "start_line": 67 }
FStar.Pervasives.Lemma
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gcm_decrypt_LE_reveal = opaque_revealer (`%gcm_decrypt_LE) gcm_decrypt_LE gcm_decrypt_LE_def
let gcm_decrypt_LE_reveal =
false
null
true
opaque_revealer (`%gcm_decrypt_LE) gcm_decrypt_LE gcm_decrypt_LE_def
{ "checked_file": "Vale.AES.GCM_s.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.GCM_s.fst" }
[ "lemma" ]
[ "Vale.Def.Opaque_s.opaque_revealer", "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Vale.AES.GCM_s.supported_iv_LE", "FStar.Pervasives.Native.tuple2", "Prims.bool", "Prims.l_and", "Vale.AES.AES_common_s.is_aes_key", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.Def.Words_s.pow2_32", "Prims.l_True", "Vale.AES.GCM_s.gcm_decrypt_LE", "Vale.AES.GCM_s.gcm_decrypt_LE_def" ]
[]
module Vale.AES.GCM_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GHash_s open FStar.Seq open FStar.Mul unfold type gcm_plain_LE = gctr_plain_LE unfold type gcm_auth_LE = gctr_plain_LE #reset-options "--z3rlimit 30" type supported_iv_LE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 } let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32 = if 8 * (length iv) = 96 then ( let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in let iv_BE = reverse_bytes_quad32 iv_LE in let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in j0_BE ) else ( let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in let length_LE = reverse_bytes_quad32 length_BE in let hash_input_LE = append padded_iv_quads (create 1 length_LE) in let hash_output_LE = ghash_LE h_LE hash_input_LE in reverse_bytes_quad32 hash_output_LE ) [@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def // little-endian let gcm_encrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (plain:seq nat8) (auth:seq nat8) : Pure (seq nat8 & seq nat8) (requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32 ) (ensures fun (c, t) -> True) = let key_LE = seq_nat8_to_seq_nat32_LE key in let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in let j0_BE = compute_iv_BE h_LE iv in let c = gctr_encrypt_LE (inc32 j0_BE 1) plain alg key_LE in // Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0 in let lengths_LE = reverse_bytes_quad32 lengths_BE in let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits c) in let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in let s_LE = ghash_LE h_LE hash_input_LE in let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in (c, t) [@"opaque_to_smt"] let gcm_encrypt_LE = opaque_make gcm_encrypt_LE_def irreducible let gcm_encrypt_LE_reveal = opaque_revealer (`%gcm_encrypt_LE) gcm_encrypt_LE gcm_encrypt_LE_def let gcm_decrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (cipher:seq nat8) (auth:seq nat8) (tag:seq nat8) : Pure (seq nat8 & bool) (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32 ) (ensures fun (p, t) -> True) = let key_LE = seq_nat8_to_seq_nat32_LE key in let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in let j0_BE = compute_iv_BE h_LE iv in let p = gctr_encrypt_LE (inc32 j0_BE 1) cipher alg key_LE in // TODO: Rename gctr_encrypt_LE to gctr_LE let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length cipher) 0 in let lengths_LE = reverse_bytes_quad32 lengths_BE in let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in let s_LE = ghash_LE h_LE hash_input_LE in let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in (p, t = tag)
false
false
Vale.AES.GCM_s.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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm_decrypt_LE_reveal : _: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.AES.GCM_s.gcm_decrypt_LE == Vale.AES.GCM_s.gcm_decrypt_LE_def)
[]
Vale.AES.GCM_s.gcm_decrypt_LE_reveal
{ "file_name": "vale/specs/crypto/Vale.AES.GCM_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
_: Prims.unit -> FStar.Pervasives.Lemma (ensures Vale.AES.GCM_s.gcm_decrypt_LE == Vale.AES.GCM_s.gcm_decrypt_LE_def)
{ "end_col": 108, "end_line": 96, "start_col": 40, "start_line": 96 }
Prims.Pure
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gcm_encrypt_LE = opaque_make gcm_encrypt_LE_def
let gcm_encrypt_LE =
false
null
false
opaque_make gcm_encrypt_LE_def
{ "checked_file": "Vale.AES.GCM_s.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.GCM_s.fst" }
[]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Vale.AES.GCM_s.supported_iv_LE", "FStar.Pervasives.Native.tuple2", "Prims.l_and", "Vale.AES.AES_common_s.is_aes_key", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.Def.Words_s.pow2_32", "Prims.l_True", "Vale.AES.GCM_s.gcm_encrypt_LE_def" ]
[]
module Vale.AES.GCM_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GHash_s open FStar.Seq open FStar.Mul unfold type gcm_plain_LE = gctr_plain_LE unfold type gcm_auth_LE = gctr_plain_LE #reset-options "--z3rlimit 30" type supported_iv_LE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 } let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32 = if 8 * (length iv) = 96 then ( let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in let iv_BE = reverse_bytes_quad32 iv_LE in let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in j0_BE ) else ( let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in let length_LE = reverse_bytes_quad32 length_BE in let hash_input_LE = append padded_iv_quads (create 1 length_LE) in let hash_output_LE = ghash_LE h_LE hash_input_LE in reverse_bytes_quad32 hash_output_LE ) [@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def // little-endian let gcm_encrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (plain:seq nat8) (auth:seq nat8) : Pure (seq nat8 & seq nat8) (requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32 ) (ensures fun (c, t) -> True) = let key_LE = seq_nat8_to_seq_nat32_LE key in let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in let j0_BE = compute_iv_BE h_LE iv in let c = gctr_encrypt_LE (inc32 j0_BE 1) plain alg key_LE in // Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0 in let lengths_LE = reverse_bytes_quad32 lengths_BE in let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits c) in let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in let s_LE = ghash_LE h_LE hash_input_LE in let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in
false
false
Vale.AES.GCM_s.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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm_encrypt_LE : alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> iv: Vale.AES.GCM_s.supported_iv_LE -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * FStar.Seq.Base.seq Vale.Def.Types_s.nat8)
[]
Vale.AES.GCM_s.gcm_encrypt_LE
{ "file_name": "vale/specs/crypto/Vale.AES.GCM_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> iv: Vale.AES.GCM_s.supported_iv_LE -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * FStar.Seq.Base.seq Vale.Def.Types_s.nat8)
{ "end_col": 70, "end_line": 66, "start_col": 40, "start_line": 66 }
Prims.Pure
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gcm_decrypt_LE = opaque_make gcm_decrypt_LE_def
let gcm_decrypt_LE =
false
null
false
opaque_make gcm_decrypt_LE_def
{ "checked_file": "Vale.AES.GCM_s.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.GCM_s.fst" }
[]
[ "Vale.Def.Opaque_s.opaque_make", "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Vale.AES.GCM_s.supported_iv_LE", "FStar.Pervasives.Native.tuple2", "Prims.bool", "Prims.l_and", "Vale.AES.AES_common_s.is_aes_key", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.Def.Words_s.pow2_32", "Prims.l_True", "Vale.AES.GCM_s.gcm_decrypt_LE_def" ]
[]
module Vale.AES.GCM_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GHash_s open FStar.Seq open FStar.Mul unfold type gcm_plain_LE = gctr_plain_LE unfold type gcm_auth_LE = gctr_plain_LE #reset-options "--z3rlimit 30" type supported_iv_LE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 } let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32 = if 8 * (length iv) = 96 then ( let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in let iv_BE = reverse_bytes_quad32 iv_LE in let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in j0_BE ) else ( let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in let length_LE = reverse_bytes_quad32 length_BE in let hash_input_LE = append padded_iv_quads (create 1 length_LE) in let hash_output_LE = ghash_LE h_LE hash_input_LE in reverse_bytes_quad32 hash_output_LE ) [@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def // little-endian let gcm_encrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (plain:seq nat8) (auth:seq nat8) : Pure (seq nat8 & seq nat8) (requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32 ) (ensures fun (c, t) -> True) = let key_LE = seq_nat8_to_seq_nat32_LE key in let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in let j0_BE = compute_iv_BE h_LE iv in let c = gctr_encrypt_LE (inc32 j0_BE 1) plain alg key_LE in // Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0 in let lengths_LE = reverse_bytes_quad32 lengths_BE in let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits c) in let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in let s_LE = ghash_LE h_LE hash_input_LE in let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in (c, t) [@"opaque_to_smt"] let gcm_encrypt_LE = opaque_make gcm_encrypt_LE_def irreducible let gcm_encrypt_LE_reveal = opaque_revealer (`%gcm_encrypt_LE) gcm_encrypt_LE gcm_encrypt_LE_def let gcm_decrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (cipher:seq nat8) (auth:seq nat8) (tag:seq nat8) : Pure (seq nat8 & bool) (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32 ) (ensures fun (p, t) -> True) = let key_LE = seq_nat8_to_seq_nat32_LE key in let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in let j0_BE = compute_iv_BE h_LE iv in let p = gctr_encrypt_LE (inc32 j0_BE 1) cipher alg key_LE in // TODO: Rename gctr_encrypt_LE to gctr_LE let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length cipher) 0 in let lengths_LE = reverse_bytes_quad32 lengths_BE in let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in let s_LE = ghash_LE h_LE hash_input_LE in let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in
false
false
Vale.AES.GCM_s.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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm_decrypt_LE : alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> iv: Vale.AES.GCM_s.supported_iv_LE -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> tag: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * Prims.bool)
[]
Vale.AES.GCM_s.gcm_decrypt_LE
{ "file_name": "vale/specs/crypto/Vale.AES.GCM_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> iv: Vale.AES.GCM_s.supported_iv_LE -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> tag: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * Prims.bool)
{ "end_col": 70, "end_line": 95, "start_col": 40, "start_line": 95 }
Prims.Tot
val compute_iv_BE_def (h_LE: quad32) (iv: supported_iv_LE) : quad32
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32 = if 8 * (length iv) = 96 then ( let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in let iv_BE = reverse_bytes_quad32 iv_LE in let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in j0_BE ) else ( let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in let length_LE = reverse_bytes_quad32 length_BE in let hash_input_LE = append padded_iv_quads (create 1 length_LE) in let hash_output_LE = ghash_LE h_LE hash_input_LE in reverse_bytes_quad32 hash_output_LE )
val compute_iv_BE_def (h_LE: quad32) (iv: supported_iv_LE) : quad32 let compute_iv_BE_def (h_LE: quad32) (iv: supported_iv_LE) : quad32 =
false
null
false
if 8 * (length iv) = 96 then (let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in let iv_BE = reverse_bytes_quad32 iv_LE in let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in j0_BE) else (let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in let length_LE = reverse_bytes_quad32 length_BE in let hash_input_LE = append padded_iv_quads (create 1 length_LE) in let hash_output_LE = ghash_LE h_LE hash_input_LE in reverse_bytes_quad32 hash_output_LE)
{ "checked_file": "Vale.AES.GCM_s.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.GCM_s.fst" }
[ "total" ]
[ "Vale.Def.Types_s.quad32", "Vale.AES.GCM_s.supported_iv_LE", "Prims.op_Equality", "Prims.int", "FStar.Mul.op_Star", "FStar.Seq.Base.length", "Vale.Def.Types_s.nat8", "Vale.Def.Words_s.four", "Vale.Def.Words_s.nat32", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.Def.Types_s.le_bytes_to_quad32", "Vale.AES.GCTR_s.pad_to_128_bits", "Prims.bool", "Vale.AES.GHash_s.ghash_LE", "FStar.Seq.Base.seq", "FStar.Seq.Base.append", "FStar.Seq.Base.create", "Vale.Def.Types_s.insert_nat64_def", "Vale.Def.Types_s.le_bytes_to_seq_quad32" ]
[]
module Vale.AES.GCM_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GHash_s open FStar.Seq open FStar.Mul unfold type gcm_plain_LE = gctr_plain_LE unfold type gcm_auth_LE = gctr_plain_LE #reset-options "--z3rlimit 30" type supported_iv_LE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 } let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32
false
true
Vale.AES.GCM_s.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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val compute_iv_BE_def (h_LE: quad32) (iv: supported_iv_LE) : quad32
[]
Vale.AES.GCM_s.compute_iv_BE_def
{ "file_name": "vale/specs/crypto/Vale.AES.GCM_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h_LE: Vale.Def.Types_s.quad32 -> iv: Vale.AES.GCM_s.supported_iv_LE -> Vale.Def.Types_s.quad32
{ "end_col": 3, "end_line": 34, "start_col": 2, "start_line": 22 }
Prims.Pure
val gcm_encrypt_LE_def (alg: algorithm) (key: seq nat8) (iv: supported_iv_LE) (plain auth: seq nat8) : Pure (seq nat8 & seq nat8) (requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32) (ensures fun (c, t) -> True)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gcm_encrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (plain:seq nat8) (auth:seq nat8) : Pure (seq nat8 & seq nat8) (requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32 ) (ensures fun (c, t) -> True) = let key_LE = seq_nat8_to_seq_nat32_LE key in let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in let j0_BE = compute_iv_BE h_LE iv in let c = gctr_encrypt_LE (inc32 j0_BE 1) plain alg key_LE in // Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0 in let lengths_LE = reverse_bytes_quad32 lengths_BE in let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits c) in let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in let s_LE = ghash_LE h_LE hash_input_LE in let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in (c, t)
val gcm_encrypt_LE_def (alg: algorithm) (key: seq nat8) (iv: supported_iv_LE) (plain auth: seq nat8) : Pure (seq nat8 & seq nat8) (requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32) (ensures fun (c, t) -> True) let gcm_encrypt_LE_def (alg: algorithm) (key: seq nat8) (iv: supported_iv_LE) (plain auth: seq nat8) : Pure (seq nat8 & seq nat8) (requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32) (ensures fun (c, t) -> True) =
false
null
false
let key_LE = seq_nat8_to_seq_nat32_LE key in let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in let j0_BE = compute_iv_BE h_LE iv in let c = gctr_encrypt_LE (inc32 j0_BE 1) plain alg key_LE in let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0 in let lengths_LE = reverse_bytes_quad32 lengths_BE in let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits c) in let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in let s_LE = ghash_LE h_LE hash_input_LE in let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in (c, t)
{ "checked_file": "Vale.AES.GCM_s.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.GCM_s.fst" }
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Vale.AES.GCM_s.supported_iv_LE", "FStar.Pervasives.Native.Mktuple2", "Vale.Def.Words_s.nat8", "Vale.AES.GCTR_s.gctr_encrypt_LE", "Vale.Def.Types_s.le_quad32_to_bytes", "Vale.Def.Types_s.quad32", "Vale.AES.GHash_s.ghash_LE", "FStar.Seq.Base.append", "FStar.Seq.Base.create", "Vale.Def.Types_s.le_bytes_to_seq_quad32", "Vale.AES.GCTR_s.pad_to_128_bits", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.Def.Types_s.insert_nat64_def", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "FStar.Mul.op_Star", "FStar.Seq.Base.length", "Vale.AES.GCTR_s.inc32", "Vale.AES.GCM_s.compute_iv_BE", "Vale.AES.AES_s.aes_encrypt_LE", "Vale.Def.Words_s.nat32", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE", "FStar.Pervasives.Native.tuple2", "Prims.l_and", "Vale.AES.AES_common_s.is_aes_key", "Prims.b2t", "Prims.op_LessThan", "Vale.Def.Words_s.pow2_32", "Prims.l_True" ]
[]
module Vale.AES.GCM_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GHash_s open FStar.Seq open FStar.Mul unfold type gcm_plain_LE = gctr_plain_LE unfold type gcm_auth_LE = gctr_plain_LE #reset-options "--z3rlimit 30" type supported_iv_LE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 } let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32 = if 8 * (length iv) = 96 then ( let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in let iv_BE = reverse_bytes_quad32 iv_LE in let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in j0_BE ) else ( let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in let length_LE = reverse_bytes_quad32 length_BE in let hash_input_LE = append padded_iv_quads (create 1 length_LE) in let hash_output_LE = ghash_LE h_LE hash_input_LE in reverse_bytes_quad32 hash_output_LE ) [@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def // little-endian let gcm_encrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (plain:seq nat8) (auth:seq nat8) : Pure (seq nat8 & seq nat8) (requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32 )
false
false
Vale.AES.GCM_s.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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm_encrypt_LE_def (alg: algorithm) (key: seq nat8) (iv: supported_iv_LE) (plain auth: seq nat8) : Pure (seq nat8 & seq nat8) (requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32) (ensures fun (c, t) -> True)
[]
Vale.AES.GCM_s.gcm_encrypt_LE_def
{ "file_name": "vale/specs/crypto/Vale.AES.GCM_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> iv: Vale.AES.GCM_s.supported_iv_LE -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * FStar.Seq.Base.seq Vale.Def.Types_s.nat8)
{ "end_col": 8, "end_line": 65, "start_col": 3, "start_line": 47 }
Prims.Pure
val gcm_decrypt_LE_def (alg: algorithm) (key: seq nat8) (iv: supported_iv_LE) (cipher auth tag: seq nat8) : Pure (seq nat8 & bool) (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32) (ensures fun (p, t) -> True)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gcm_decrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (cipher:seq nat8) (auth:seq nat8) (tag:seq nat8) : Pure (seq nat8 & bool) (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32 ) (ensures fun (p, t) -> True) = let key_LE = seq_nat8_to_seq_nat32_LE key in let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in let j0_BE = compute_iv_BE h_LE iv in let p = gctr_encrypt_LE (inc32 j0_BE 1) cipher alg key_LE in // TODO: Rename gctr_encrypt_LE to gctr_LE let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length cipher) 0 in let lengths_LE = reverse_bytes_quad32 lengths_BE in let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in let s_LE = ghash_LE h_LE hash_input_LE in let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in (p, t = tag)
val gcm_decrypt_LE_def (alg: algorithm) (key: seq nat8) (iv: supported_iv_LE) (cipher auth tag: seq nat8) : Pure (seq nat8 & bool) (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32) (ensures fun (p, t) -> True) let gcm_decrypt_LE_def (alg: algorithm) (key: seq nat8) (iv: supported_iv_LE) (cipher auth tag: seq nat8) : Pure (seq nat8 & bool) (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32) (ensures fun (p, t) -> True) =
false
null
false
let key_LE = seq_nat8_to_seq_nat32_LE key in let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in let j0_BE = compute_iv_BE h_LE iv in let p = gctr_encrypt_LE (inc32 j0_BE 1) cipher alg key_LE in let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length cipher) 0 in let lengths_LE = reverse_bytes_quad32 lengths_BE in let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits cipher) in let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in let s_LE = ghash_LE h_LE hash_input_LE in let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in (p, t = tag)
{ "checked_file": "Vale.AES.GCM_s.fst.checked", "dependencies": [ "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.AES_s.fst.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.GCM_s.fst" }
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Vale.AES.GCM_s.supported_iv_LE", "FStar.Pervasives.Native.Mktuple2", "Prims.bool", "Prims.op_Equality", "Vale.Def.Words_s.nat8", "Vale.AES.GCTR_s.gctr_encrypt_LE", "Vale.Def.Types_s.le_quad32_to_bytes", "Vale.Def.Types_s.quad32", "Vale.AES.GHash_s.ghash_LE", "FStar.Seq.Base.append", "FStar.Seq.Base.create", "Vale.Def.Types_s.le_bytes_to_seq_quad32", "Vale.AES.GCTR_s.pad_to_128_bits", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.Def.Types_s.insert_nat64_def", "Vale.Def.Words_s.Mkfour", "Vale.Def.Types_s.nat32", "FStar.Mul.op_Star", "FStar.Seq.Base.length", "Vale.AES.GCTR_s.inc32", "Vale.AES.GCM_s.compute_iv_BE", "Vale.AES.AES_s.aes_encrypt_LE", "Vale.Def.Words_s.nat32", "Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE", "FStar.Pervasives.Native.tuple2", "Prims.l_and", "Vale.AES.AES_common_s.is_aes_key", "Prims.b2t", "Prims.op_LessThan", "Vale.Def.Words_s.pow2_32", "Prims.l_True" ]
[]
module Vale.AES.GCM_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GHash_s open FStar.Seq open FStar.Mul unfold type gcm_plain_LE = gctr_plain_LE unfold type gcm_auth_LE = gctr_plain_LE #reset-options "--z3rlimit 30" type supported_iv_LE:eqtype = iv:seq nat8 { 1 <= 8 * (length iv) /\ 8 * (length iv) < pow2_64 } let compute_iv_BE_def (h_LE:quad32) (iv:supported_iv_LE) : quad32 = if 8 * (length iv) = 96 then ( let iv_LE = le_bytes_to_quad32 (pad_to_128_bits iv) in let iv_BE = reverse_bytes_quad32 iv_LE in let j0_BE = Mkfour 1 iv_BE.lo1 iv_BE.hi2 iv_BE.hi3 in j0_BE ) else ( let padded_iv_quads = le_bytes_to_seq_quad32 (pad_to_128_bits iv) in let length_BE = insert_nat64_def (Mkfour 0 0 0 0) (8 * length iv) 0 in let length_LE = reverse_bytes_quad32 length_BE in let hash_input_LE = append padded_iv_quads (create 1 length_LE) in let hash_output_LE = ghash_LE h_LE hash_input_LE in reverse_bytes_quad32 hash_output_LE ) [@"opaque_to_smt"] let compute_iv_BE = opaque_make compute_iv_BE_def irreducible let compute_iv_BE_reveal = opaque_revealer (`%compute_iv_BE) compute_iv_BE compute_iv_BE_def // little-endian let gcm_encrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (plain:seq nat8) (auth:seq nat8) : Pure (seq nat8 & seq nat8) (requires is_aes_key alg key /\ length plain < pow2_32 /\ length auth < pow2_32 ) (ensures fun (c, t) -> True) = let key_LE = seq_nat8_to_seq_nat32_LE key in let h_LE = aes_encrypt_LE alg key_LE (Mkfour 0 0 0 0) in let j0_BE = compute_iv_BE h_LE iv in let c = gctr_encrypt_LE (inc32 j0_BE 1) plain alg key_LE in // Sets the first 64-bit number to 8 * length plain, and the second to 8* length auth let lengths_BE = insert_nat64_def (insert_nat64_def (Mkfour 0 0 0 0) (8 * length auth) 1) (8 * length plain) 0 in let lengths_LE = reverse_bytes_quad32 lengths_BE in let zero_padded_c_LE = le_bytes_to_seq_quad32 (pad_to_128_bits c) in let zero_padded_a_LE = le_bytes_to_seq_quad32 (pad_to_128_bits auth) in let hash_input_LE = append zero_padded_a_LE (append zero_padded_c_LE (create 1 lengths_LE)) in let s_LE = ghash_LE h_LE hash_input_LE in let t = gctr_encrypt_LE j0_BE (le_quad32_to_bytes s_LE) alg key_LE in (c, t) [@"opaque_to_smt"] let gcm_encrypt_LE = opaque_make gcm_encrypt_LE_def irreducible let gcm_encrypt_LE_reveal = opaque_revealer (`%gcm_encrypt_LE) gcm_encrypt_LE gcm_encrypt_LE_def let gcm_decrypt_LE_def (alg:algorithm) (key:seq nat8) (iv:supported_iv_LE) (cipher:seq nat8) (auth:seq nat8) (tag:seq nat8) : Pure (seq nat8 & bool) (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32 )
false
false
Vale.AES.GCM_s.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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gcm_decrypt_LE_def (alg: algorithm) (key: seq nat8) (iv: supported_iv_LE) (cipher auth tag: seq nat8) : Pure (seq nat8 & bool) (requires is_aes_key alg key /\ length cipher < pow2_32 /\ length auth < pow2_32) (ensures fun (p, t) -> True)
[]
Vale.AES.GCM_s.gcm_decrypt_LE_def
{ "file_name": "vale/specs/crypto/Vale.AES.GCM_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> iv: Vale.AES.GCM_s.supported_iv_LE -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> auth: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> tag: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8 * Prims.bool)
{ "end_col": 14, "end_line": 94, "start_col": 3, "start_line": 77 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_of (f':flags_t) (o:nat1) = flag_of f' == o /\ valid_of f'
let update_of (f': flags_t) (o: nat1) =
false
null
false
flag_of f' == o /\ valid_of f'
{ "checked_file": "Vale.Bignum.X64.fsti.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Bignum.Defs.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.Bignum.X64.fsti" }
[ "total" ]
[ "Vale.Bignum.X64.flags_t", "Vale.Def.Words_s.nat1", "Prims.l_and", "Prims.eq2", "Vale.Bignum.X64.flag_of", "Prims.b2t", "Vale.X64.Decls.valid_of", "Prims.logical" ]
[]
module Vale.Bignum.X64 open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsStack open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s open Vale.Bignum.Defs let flags_t = Vale.X64.Flags.t val flag_cf (f:flags_t) : nat1 val flag_of (f:flags_t) : nat1
false
true
Vale.Bignum.X64.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_of : f': Vale.Bignum.X64.flags_t -> o: Vale.Def.Words_s.nat1 -> Prims.logical
[]
Vale.Bignum.X64.update_of
{ "file_name": "obj/Vale.Bignum.X64.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f': Vale.Bignum.X64.flags_t -> o: Vale.Def.Words_s.nat1 -> Prims.logical
{ "end_col": 68, "end_line": 21, "start_col": 38, "start_line": 21 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_cf (f':flags_t) (c:nat1) = flag_cf f' == c /\ valid_cf f'
let update_cf (f': flags_t) (c: nat1) =
false
null
false
flag_cf f' == c /\ valid_cf f'
{ "checked_file": "Vale.Bignum.X64.fsti.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Bignum.Defs.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.Bignum.X64.fsti" }
[ "total" ]
[ "Vale.Bignum.X64.flags_t", "Vale.Def.Words_s.nat1", "Prims.l_and", "Prims.eq2", "Vale.Bignum.X64.flag_cf", "Prims.b2t", "Vale.X64.Decls.valid_cf", "Prims.logical" ]
[]
module Vale.Bignum.X64 open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsStack open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s open Vale.Bignum.Defs let flags_t = Vale.X64.Flags.t val flag_cf (f:flags_t) : nat1
false
true
Vale.Bignum.X64.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_cf : f': Vale.Bignum.X64.flags_t -> c: Vale.Def.Words_s.nat1 -> Prims.logical
[]
Vale.Bignum.X64.update_cf
{ "file_name": "obj/Vale.Bignum.X64.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f': Vale.Bignum.X64.flags_t -> c: Vale.Def.Words_s.nat1 -> Prims.logical
{ "end_col": 68, "end_line": 20, "start_col": 38, "start_line": 20 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let maintain_of (f':flags_t) (f:flags_t) = flag_of f' == flag_of f /\ valid_of f' == valid_of f
let maintain_of (f' f: flags_t) =
false
null
false
flag_of f' == flag_of f /\ valid_of f' == valid_of f
{ "checked_file": "Vale.Bignum.X64.fsti.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Bignum.Defs.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.Bignum.X64.fsti" }
[ "total" ]
[ "Vale.Bignum.X64.flags_t", "Prims.l_and", "Prims.eq2", "Vale.Def.Words_s.nat1", "Vale.Bignum.X64.flag_of", "Prims.bool", "Vale.X64.Decls.valid_of", "Prims.logical" ]
[]
module Vale.Bignum.X64 open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsStack open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s open Vale.Bignum.Defs let flags_t = Vale.X64.Flags.t val flag_cf (f:flags_t) : nat1 val flag_of (f:flags_t) : nat1 let update_cf (f':flags_t) (c:nat1) = flag_cf f' == c /\ valid_cf f' let update_of (f':flags_t) (o:nat1) = flag_of f' == o /\ valid_of f'
false
true
Vale.Bignum.X64.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 maintain_of : f': Vale.Bignum.X64.flags_t -> f: Vale.Bignum.X64.flags_t -> Prims.logical
[]
Vale.Bignum.X64.maintain_of
{ "file_name": "obj/Vale.Bignum.X64.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f': Vale.Bignum.X64.flags_t -> f: Vale.Bignum.X64.flags_t -> Prims.logical
{ "end_col": 95, "end_line": 23, "start_col": 43, "start_line": 23 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let maintain_cf (f':flags_t) (f:flags_t) = flag_cf f' == flag_cf f /\ valid_cf f' == valid_cf f
let maintain_cf (f' f: flags_t) =
false
null
false
flag_cf f' == flag_cf f /\ valid_cf f' == valid_cf f
{ "checked_file": "Vale.Bignum.X64.fsti.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Bignum.Defs.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.Bignum.X64.fsti" }
[ "total" ]
[ "Vale.Bignum.X64.flags_t", "Prims.l_and", "Prims.eq2", "Vale.Def.Words_s.nat1", "Vale.Bignum.X64.flag_cf", "Prims.bool", "Vale.X64.Decls.valid_cf", "Prims.logical" ]
[]
module Vale.Bignum.X64 open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsStack open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s open Vale.Bignum.Defs let flags_t = Vale.X64.Flags.t val flag_cf (f:flags_t) : nat1 val flag_of (f:flags_t) : nat1 let update_cf (f':flags_t) (c:nat1) = flag_cf f' == c /\ valid_cf f'
false
true
Vale.Bignum.X64.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 maintain_cf : f': Vale.Bignum.X64.flags_t -> f: Vale.Bignum.X64.flags_t -> Prims.logical
[]
Vale.Bignum.X64.maintain_cf
{ "file_name": "obj/Vale.Bignum.X64.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f': Vale.Bignum.X64.flags_t -> f: Vale.Bignum.X64.flags_t -> Prims.logical
{ "end_col": 95, "end_line": 22, "start_col": 43, "start_line": 22 }
Prims.Tot
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let flags_t = Vale.X64.Flags.t
let flags_t =
false
null
false
Vale.X64.Flags.t
{ "checked_file": "Vale.Bignum.X64.fsti.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Bignum.Defs.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.Bignum.X64.fsti" }
[ "total" ]
[ "Vale.X64.Flags.t" ]
[]
module Vale.Bignum.X64 open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsStack open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s
false
true
Vale.Bignum.X64.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 flags_t : Type0
[]
Vale.Bignum.X64.flags_t
{ "file_name": "obj/Vale.Bignum.X64.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 30, "end_line": 17, "start_col": 14, "start_line": 17 }
Prims.Tot
val va_wp_Adcx_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_Adcx_64 (dst:va_operand_dst_opr64) (src:va_operand_opr64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ adx_enabled /\ Vale.X64.Decls.valid_cf (va_get_flags va_s0) /\ (forall (va_x_dst:va_value_dst_opr64) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_dst_opr64 dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.Bignum.Defs.add_lo (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0)) /\ update_cf (va_get_flags va_sM) (Vale.Bignum.Defs.add_hi (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0))) /\ maintain_of (va_get_flags va_sM) (va_get_flags va_s0) ==> va_k va_sM (())))
val va_wp_Adcx_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_Adcx_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ adx_enabled /\ Vale.X64.Decls.valid_cf (va_get_flags va_s0) /\ (forall (va_x_dst: va_value_dst_opr64) (va_x_efl: Vale.X64.Flags.t). let va_sM = va_upd_flags va_x_efl (va_upd_operand_dst_opr64 dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.Bignum.Defs.add_lo (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0)) /\ update_cf (va_get_flags va_sM) (Vale.Bignum.Defs.add_hi (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0))) /\ maintain_of (va_get_flags va_sM) (va_get_flags va_s0) ==> va_k va_sM (())))
{ "checked_file": "Vale.Bignum.X64.fsti.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Bignum.Defs.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.Bignum.X64.fsti" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_operand_opr64", "Vale.X64.Decls.va_state", "Prims.unit", "Prims.l_and", "Prims.b2t", "Vale.X64.Decls.va_is_dst_dst_opr64", "Vale.X64.Decls.va_is_src_opr64", "Vale.X64.Decls.va_get_ok", "Vale.X64.CPU_Features_s.adx_enabled", "Vale.X64.Decls.valid_cf", "Vale.X64.Decls.va_get_flags", "Prims.l_Forall", "Vale.X64.Decls.va_value_dst_opr64", "Vale.X64.Flags.t", "Prims.l_imp", "Prims.eq2", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.pow2_64", "Vale.X64.Decls.va_eval_dst_opr64", "Vale.Bignum.Defs.add_lo", "Vale.X64.Decls.va_eval_opr64", "Vale.Bignum.X64.flag_cf", "Vale.Bignum.X64.update_cf", "Vale.Bignum.Defs.add_hi", "Vale.Bignum.X64.maintain_of", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_upd_flags", "Vale.X64.Decls.va_upd_operand_dst_opr64" ]
[]
module Vale.Bignum.X64 open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsStack open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s open Vale.Bignum.Defs let flags_t = Vale.X64.Flags.t val flag_cf (f:flags_t) : nat1 val flag_of (f:flags_t) : nat1 let update_cf (f':flags_t) (c:nat1) = flag_cf f' == c /\ valid_cf f' let update_of (f':flags_t) (o:nat1) = flag_of f' == o /\ valid_of f' let maintain_cf (f':flags_t) (f:flags_t) = flag_cf f' == flag_cf f /\ valid_cf f' == valid_cf f let maintain_of (f':flags_t) (f:flags_t) = flag_of f' == flag_of f /\ valid_of f' == valid_of f //-- reveal_flags val reveal_flags : f:flags_t -> Lemma (requires true) (ensures (flag_cf f = 1 == Vale.X64.Decls.cf f /\ flag_of f = 1 == Vale.X64.Decls.overflow f)) //-- //-- lemma_add_hi_lo64 val lemma_add_hi_lo64 : dummy:int -> Lemma (requires true) (ensures (forall (a:nat64) (b:nat64) (c:nat1) . {:pattern(add_lo a b c); (add_hi a b c)}Vale.Bignum.Defs.add_lo a b c + va_mul_nat pow2_64 (Vale.Bignum.Defs.add_hi a b c) == a + b + c)) //-- //-- Adcx_64 val va_code_Adcx_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code val va_codegen_success_Adcx_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool val va_lemma_Adcx_64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Adcx_64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ adx_enabled /\ Vale.X64.Decls.valid_cf (va_get_flags va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.Bignum.Defs.add_lo (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0)) /\ update_cf (va_get_flags va_sM) (Vale.Bignum.Defs.add_hi (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0))) /\ maintain_of (va_get_flags va_sM) (va_get_flags va_s0) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))) [@ va_qattr] let va_wp_Adcx_64 (dst:va_operand_dst_opr64) (src:va_operand_opr64) (va_s0:va_state)
false
true
Vale.Bignum.X64.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 va_wp_Adcx_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.Bignum.X64.va_wp_Adcx_64
{ "file_name": "obj/Vale.Bignum.X64.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 46, "end_line": 69, "start_col": 2, "start_line": 62 }
Prims.Tot
val va_wp_Adox_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_Adox_64 (dst:va_operand_dst_opr64) (src:va_operand_opr64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ adx_enabled /\ Vale.X64.Decls.valid_of (va_get_flags va_s0) /\ (forall (va_x_dst:va_value_dst_opr64) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_dst_opr64 dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.Bignum.Defs.add_lo (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_of (va_get_flags va_s0)) /\ update_of (va_get_flags va_sM) (Vale.Bignum.Defs.add_hi (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_of (va_get_flags va_s0))) /\ maintain_cf (va_get_flags va_sM) (va_get_flags va_s0) ==> va_k va_sM (())))
val va_wp_Adox_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_Adox_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ adx_enabled /\ Vale.X64.Decls.valid_of (va_get_flags va_s0) /\ (forall (va_x_dst: va_value_dst_opr64) (va_x_efl: Vale.X64.Flags.t). let va_sM = va_upd_flags va_x_efl (va_upd_operand_dst_opr64 dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.Bignum.Defs.add_lo (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_of (va_get_flags va_s0)) /\ update_of (va_get_flags va_sM) (Vale.Bignum.Defs.add_hi (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_of (va_get_flags va_s0))) /\ maintain_cf (va_get_flags va_sM) (va_get_flags va_s0) ==> va_k va_sM (())))
{ "checked_file": "Vale.Bignum.X64.fsti.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Bignum.Defs.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.Bignum.X64.fsti" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_operand_opr64", "Vale.X64.Decls.va_state", "Prims.unit", "Prims.l_and", "Prims.b2t", "Vale.X64.Decls.va_is_dst_dst_opr64", "Vale.X64.Decls.va_is_src_opr64", "Vale.X64.Decls.va_get_ok", "Vale.X64.CPU_Features_s.adx_enabled", "Vale.X64.Decls.valid_of", "Vale.X64.Decls.va_get_flags", "Prims.l_Forall", "Vale.X64.Decls.va_value_dst_opr64", "Vale.X64.Flags.t", "Prims.l_imp", "Prims.eq2", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.pow2_64", "Vale.X64.Decls.va_eval_dst_opr64", "Vale.Bignum.Defs.add_lo", "Vale.X64.Decls.va_eval_opr64", "Vale.Bignum.X64.flag_of", "Vale.Bignum.X64.update_of", "Vale.Bignum.Defs.add_hi", "Vale.Bignum.X64.maintain_cf", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_upd_flags", "Vale.X64.Decls.va_upd_operand_dst_opr64" ]
[]
module Vale.Bignum.X64 open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsStack open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s open Vale.Bignum.Defs let flags_t = Vale.X64.Flags.t val flag_cf (f:flags_t) : nat1 val flag_of (f:flags_t) : nat1 let update_cf (f':flags_t) (c:nat1) = flag_cf f' == c /\ valid_cf f' let update_of (f':flags_t) (o:nat1) = flag_of f' == o /\ valid_of f' let maintain_cf (f':flags_t) (f:flags_t) = flag_cf f' == flag_cf f /\ valid_cf f' == valid_cf f let maintain_of (f':flags_t) (f:flags_t) = flag_of f' == flag_of f /\ valid_of f' == valid_of f //-- reveal_flags val reveal_flags : f:flags_t -> Lemma (requires true) (ensures (flag_cf f = 1 == Vale.X64.Decls.cf f /\ flag_of f = 1 == Vale.X64.Decls.overflow f)) //-- //-- lemma_add_hi_lo64 val lemma_add_hi_lo64 : dummy:int -> Lemma (requires true) (ensures (forall (a:nat64) (b:nat64) (c:nat1) . {:pattern(add_lo a b c); (add_hi a b c)}Vale.Bignum.Defs.add_lo a b c + va_mul_nat pow2_64 (Vale.Bignum.Defs.add_hi a b c) == a + b + c)) //-- //-- Adcx_64 val va_code_Adcx_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code val va_codegen_success_Adcx_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool val va_lemma_Adcx_64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Adcx_64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ adx_enabled /\ Vale.X64.Decls.valid_cf (va_get_flags va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.Bignum.Defs.add_lo (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0)) /\ update_cf (va_get_flags va_sM) (Vale.Bignum.Defs.add_hi (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0))) /\ maintain_of (va_get_flags va_sM) (va_get_flags va_s0) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))) [@ va_qattr] let va_wp_Adcx_64 (dst:va_operand_dst_opr64) (src:va_operand_opr64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ adx_enabled /\ Vale.X64.Decls.valid_cf (va_get_flags va_s0) /\ (forall (va_x_dst:va_value_dst_opr64) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_dst_opr64 dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.Bignum.Defs.add_lo (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0)) /\ update_cf (va_get_flags va_sM) (Vale.Bignum.Defs.add_hi (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0))) /\ maintain_of (va_get_flags va_sM) (va_get_flags va_s0) ==> va_k va_sM (()))) val va_wpProof_Adcx_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Adcx_64 dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Adcx_64 dst src) ([va_Mod_flags; va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Adcx_64 (dst:va_operand_dst_opr64) (src:va_operand_opr64) : (va_quickCode unit (va_code_Adcx_64 dst src)) = (va_QProc (va_code_Adcx_64 dst src) ([va_Mod_flags; va_mod_dst_opr64 dst]) (va_wp_Adcx_64 dst src) (va_wpProof_Adcx_64 dst src)) //-- //-- Adox_64 val va_code_Adox_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code val va_codegen_success_Adox_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool val va_lemma_Adox_64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Adox_64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ adx_enabled /\ Vale.X64.Decls.valid_of (va_get_flags va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.Bignum.Defs.add_lo (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_of (va_get_flags va_s0)) /\ update_of (va_get_flags va_sM) (Vale.Bignum.Defs.add_hi (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_of (va_get_flags va_s0))) /\ maintain_cf (va_get_flags va_sM) (va_get_flags va_s0) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))) [@ va_qattr] let va_wp_Adox_64 (dst:va_operand_dst_opr64) (src:va_operand_opr64) (va_s0:va_state)
false
true
Vale.Bignum.X64.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 va_wp_Adox_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.Bignum.X64.va_wp_Adox_64
{ "file_name": "obj/Vale.Bignum.X64.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 46, "end_line": 112, "start_col": 2, "start_line": 105 }
Prims.Tot
val va_quick_Adcx_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) : (va_quickCode unit (va_code_Adcx_64 dst src))
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_Adcx_64 (dst:va_operand_dst_opr64) (src:va_operand_opr64) : (va_quickCode unit (va_code_Adcx_64 dst src)) = (va_QProc (va_code_Adcx_64 dst src) ([va_Mod_flags; va_mod_dst_opr64 dst]) (va_wp_Adcx_64 dst src) (va_wpProof_Adcx_64 dst src))
val va_quick_Adcx_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) : (va_quickCode unit (va_code_Adcx_64 dst src)) let va_quick_Adcx_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) : (va_quickCode unit (va_code_Adcx_64 dst src)) =
false
null
false
(va_QProc (va_code_Adcx_64 dst src) ([va_Mod_flags; va_mod_dst_opr64 dst]) (va_wp_Adcx_64 dst src) (va_wpProof_Adcx_64 dst src))
{ "checked_file": "Vale.Bignum.X64.fsti.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Bignum.Defs.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.Bignum.X64.fsti" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_operand_opr64", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.Bignum.X64.va_code_Adcx_64", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_mod_dst_opr64", "Prims.Nil", "Vale.Bignum.X64.va_wp_Adcx_64", "Vale.Bignum.X64.va_wpProof_Adcx_64", "Vale.X64.QuickCode.va_quickCode" ]
[]
module Vale.Bignum.X64 open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsStack open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s open Vale.Bignum.Defs let flags_t = Vale.X64.Flags.t val flag_cf (f:flags_t) : nat1 val flag_of (f:flags_t) : nat1 let update_cf (f':flags_t) (c:nat1) = flag_cf f' == c /\ valid_cf f' let update_of (f':flags_t) (o:nat1) = flag_of f' == o /\ valid_of f' let maintain_cf (f':flags_t) (f:flags_t) = flag_cf f' == flag_cf f /\ valid_cf f' == valid_cf f let maintain_of (f':flags_t) (f:flags_t) = flag_of f' == flag_of f /\ valid_of f' == valid_of f //-- reveal_flags val reveal_flags : f:flags_t -> Lemma (requires true) (ensures (flag_cf f = 1 == Vale.X64.Decls.cf f /\ flag_of f = 1 == Vale.X64.Decls.overflow f)) //-- //-- lemma_add_hi_lo64 val lemma_add_hi_lo64 : dummy:int -> Lemma (requires true) (ensures (forall (a:nat64) (b:nat64) (c:nat1) . {:pattern(add_lo a b c); (add_hi a b c)}Vale.Bignum.Defs.add_lo a b c + va_mul_nat pow2_64 (Vale.Bignum.Defs.add_hi a b c) == a + b + c)) //-- //-- Adcx_64 val va_code_Adcx_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code val va_codegen_success_Adcx_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool val va_lemma_Adcx_64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Adcx_64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ adx_enabled /\ Vale.X64.Decls.valid_cf (va_get_flags va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.Bignum.Defs.add_lo (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0)) /\ update_cf (va_get_flags va_sM) (Vale.Bignum.Defs.add_hi (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0))) /\ maintain_of (va_get_flags va_sM) (va_get_flags va_s0) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))) [@ va_qattr] let va_wp_Adcx_64 (dst:va_operand_dst_opr64) (src:va_operand_opr64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ adx_enabled /\ Vale.X64.Decls.valid_cf (va_get_flags va_s0) /\ (forall (va_x_dst:va_value_dst_opr64) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_dst_opr64 dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.Bignum.Defs.add_lo (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0)) /\ update_cf (va_get_flags va_sM) (Vale.Bignum.Defs.add_hi (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0))) /\ maintain_of (va_get_flags va_sM) (va_get_flags va_s0) ==> va_k va_sM (()))) val va_wpProof_Adcx_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Adcx_64 dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Adcx_64 dst src) ([va_Mod_flags; va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Adcx_64 (dst:va_operand_dst_opr64) (src:va_operand_opr64) : (va_quickCode unit
false
false
Vale.Bignum.X64.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 va_quick_Adcx_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) : (va_quickCode unit (va_code_Adcx_64 dst src))
[]
Vale.Bignum.X64.va_quick_Adcx_64
{ "file_name": "obj/Vale.Bignum.X64.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.Bignum.X64.va_code_Adcx_64 dst src)
{ "end_col": 38, "end_line": 81, "start_col": 2, "start_line": 80 }
Prims.Tot
val va_quick_Adox_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) : (va_quickCode unit (va_code_Adox_64 dst src))
[ { "abbrev": false, "full_module": "Vale.Bignum.Defs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "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": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Vale.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_Adox_64 (dst:va_operand_dst_opr64) (src:va_operand_opr64) : (va_quickCode unit (va_code_Adox_64 dst src)) = (va_QProc (va_code_Adox_64 dst src) ([va_Mod_flags; va_mod_dst_opr64 dst]) (va_wp_Adox_64 dst src) (va_wpProof_Adox_64 dst src))
val va_quick_Adox_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) : (va_quickCode unit (va_code_Adox_64 dst src)) let va_quick_Adox_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) : (va_quickCode unit (va_code_Adox_64 dst src)) =
false
null
false
(va_QProc (va_code_Adox_64 dst src) ([va_Mod_flags; va_mod_dst_opr64 dst]) (va_wp_Adox_64 dst src) (va_wpProof_Adox_64 dst src))
{ "checked_file": "Vale.Bignum.X64.fsti.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Bignum.Defs.fsti.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Vale.Bignum.X64.fsti" }
[ "total" ]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_operand_opr64", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.Bignum.X64.va_code_Adox_64", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_mod_dst_opr64", "Prims.Nil", "Vale.Bignum.X64.va_wp_Adox_64", "Vale.Bignum.X64.va_wpProof_Adox_64", "Vale.X64.QuickCode.va_quickCode" ]
[]
module Vale.Bignum.X64 open Vale.Def.Words_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsStack open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.X64.CPU_Features_s open Vale.Bignum.Defs let flags_t = Vale.X64.Flags.t val flag_cf (f:flags_t) : nat1 val flag_of (f:flags_t) : nat1 let update_cf (f':flags_t) (c:nat1) = flag_cf f' == c /\ valid_cf f' let update_of (f':flags_t) (o:nat1) = flag_of f' == o /\ valid_of f' let maintain_cf (f':flags_t) (f:flags_t) = flag_cf f' == flag_cf f /\ valid_cf f' == valid_cf f let maintain_of (f':flags_t) (f:flags_t) = flag_of f' == flag_of f /\ valid_of f' == valid_of f //-- reveal_flags val reveal_flags : f:flags_t -> Lemma (requires true) (ensures (flag_cf f = 1 == Vale.X64.Decls.cf f /\ flag_of f = 1 == Vale.X64.Decls.overflow f)) //-- //-- lemma_add_hi_lo64 val lemma_add_hi_lo64 : dummy:int -> Lemma (requires true) (ensures (forall (a:nat64) (b:nat64) (c:nat1) . {:pattern(add_lo a b c); (add_hi a b c)}Vale.Bignum.Defs.add_lo a b c + va_mul_nat pow2_64 (Vale.Bignum.Defs.add_hi a b c) == a + b + c)) //-- //-- Adcx_64 val va_code_Adcx_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code val va_codegen_success_Adcx_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool val va_lemma_Adcx_64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Adcx_64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ adx_enabled /\ Vale.X64.Decls.valid_cf (va_get_flags va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.Bignum.Defs.add_lo (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0)) /\ update_cf (va_get_flags va_sM) (Vale.Bignum.Defs.add_hi (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0))) /\ maintain_of (va_get_flags va_sM) (va_get_flags va_s0) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))) [@ va_qattr] let va_wp_Adcx_64 (dst:va_operand_dst_opr64) (src:va_operand_opr64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ adx_enabled /\ Vale.X64.Decls.valid_cf (va_get_flags va_s0) /\ (forall (va_x_dst:va_value_dst_opr64) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_dst_opr64 dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.Bignum.Defs.add_lo (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0)) /\ update_cf (va_get_flags va_sM) (Vale.Bignum.Defs.add_hi (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_cf (va_get_flags va_s0))) /\ maintain_of (va_get_flags va_sM) (va_get_flags va_s0) ==> va_k va_sM (()))) val va_wpProof_Adcx_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Adcx_64 dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Adcx_64 dst src) ([va_Mod_flags; va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Adcx_64 (dst:va_operand_dst_opr64) (src:va_operand_opr64) : (va_quickCode unit (va_code_Adcx_64 dst src)) = (va_QProc (va_code_Adcx_64 dst src) ([va_Mod_flags; va_mod_dst_opr64 dst]) (va_wp_Adcx_64 dst src) (va_wpProof_Adcx_64 dst src)) //-- //-- Adox_64 val va_code_Adox_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code val va_codegen_success_Adox_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool val va_lemma_Adox_64 : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Adox_64 dst src) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ adx_enabled /\ Vale.X64.Decls.valid_of (va_get_flags va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.Bignum.Defs.add_lo (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_of (va_get_flags va_s0)) /\ update_of (va_get_flags va_sM) (Vale.Bignum.Defs.add_hi (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_of (va_get_flags va_s0))) /\ maintain_cf (va_get_flags va_sM) (va_get_flags va_s0) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))) [@ va_qattr] let va_wp_Adox_64 (dst:va_operand_dst_opr64) (src:va_operand_opr64) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_is_dst_dst_opr64 dst va_s0 /\ va_is_src_opr64 src va_s0 /\ va_get_ok va_s0 /\ adx_enabled /\ Vale.X64.Decls.valid_of (va_get_flags va_s0) /\ (forall (va_x_dst:va_value_dst_opr64) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_operand_dst_opr64 dst va_x_dst va_s0) in va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.Bignum.Defs.add_lo (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_of (va_get_flags va_s0)) /\ update_of (va_get_flags va_sM) (Vale.Bignum.Defs.add_hi (va_eval_dst_opr64 va_s0 dst) (va_eval_opr64 va_s0 src) (flag_of (va_get_flags va_s0))) /\ maintain_cf (va_get_flags va_sM) (va_get_flags va_s0) ==> va_k va_sM (()))) val va_wpProof_Adox_64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Adox_64 dst src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Adox_64 dst src) ([va_Mod_flags; va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_Adox_64 (dst:va_operand_dst_opr64) (src:va_operand_opr64) : (va_quickCode unit
false
false
Vale.Bignum.X64.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 va_quick_Adox_64 (dst: va_operand_dst_opr64) (src: va_operand_opr64) : (va_quickCode unit (va_code_Adox_64 dst src))
[]
Vale.Bignum.X64.va_quick_Adox_64
{ "file_name": "obj/Vale.Bignum.X64.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.Bignum.X64.va_code_Adox_64 dst src)
{ "end_col": 38, "end_line": 124, "start_col": 2, "start_line": 123 }
FStar.Pervasives.Lemma
val lemma_mod_264'': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) < pow2 264)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_mod_264'' a0 a1 a2 a3 a4 = assert_norm(pow2 40 = 0x10000000000); assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); assert_norm(pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000)
val lemma_mod_264'': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) < pow2 264) let lemma_mod_264'' a0 a1 a2 a3 a4 =
false
null
true
assert_norm (pow2 40 = 0x10000000000); assert_norm (pow2 56 = 0x100000000000000); assert_norm (pow2 112 = 0x10000000000000000000000000000); assert_norm (pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm (pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); assert_norm (pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Prims.nat", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.pow2", "Prims.unit" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; } val lemma_div264: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in wide_as_nat5 x / pow2 264 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div264 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow528 x; assert (v x9 < pow2 40); calc (==) { (let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 + pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x5 x5; lemma_div264_x6 x6 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x7 x7; lemma_div264_x8 x8 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x9 x9 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; (==) { lemma_div264_aux x } wide_as_nat5 x / pow2 264; } #pop-options #pop-options // "--z3cliopt smt.arith.nl=false" val lemma_mod_264_aux: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in (wide_as_nat5 t) % pow2 264 == (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264)) #push-options "--z3rlimit 150" let lemma_mod_264_aux t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in assert_norm (pow2 16 * pow2 264 == pow2 280); assert_norm (pow2 72 * pow2 264 == pow2 336); assert_norm (pow2 128 * pow2 264 == pow2 392); assert_norm (pow2 184 * pow2 264 == pow2 448); assert_norm (pow2 240 * pow2 264 == pow2 504); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224 + (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) (pow2 264)} ((v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) + ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.cancel_mul_mod (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; } #pop-options val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264) let lemma_as_nat_pow264 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_mod_264: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in qelem_fits5 res (1, 1, 1, 1, 1) /\ as_nat5 res == (wide_as_nat5 t) % pow2 264)) let lemma_mod_264 t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let t4' = t4 &. u64 0xffffffffff in let res = (t0, t1, t2, t3, t4') in assert_norm (pow2 40 < pow2 64); assert_norm (pow2 40 - 1 == 0xffffffffff); mod_mask_lemma t4 40ul; assert (v (mod_mask #U64 #SEC 40ul) == 0xffffffffff); assert (v (t4 &. u64 0xffffffffff) == v t4 % pow2 40); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { lemma_mod_264_aux t } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168) (v t4 * pow2 224) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 * pow2 224) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v t4) 264 224 } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224) % pow2 264; (==) { lemma_as_nat_pow264 res; FStar.Math.Lemmas.modulo_lemma (as_nat5 res) (pow2 264) } v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224; } val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40)) let lemma_as_nat_pow264_x4 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264) #push-options "--z3rlimit 50" let lemma_sub_mod_264_aux x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 40 * pow2 224 = pow2 264) #pop-options val lemma_sub_mod_264: x:qelem5 -> y:qelem5 -> t:qelem5 -> c5:uint64 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264 /\ as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264 /\ v c5 <= 1 /\ (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y)) (ensures (if as_nat5 x >= as_nat5 y then as_nat5 t == as_nat5 x - as_nat5 y else as_nat5 t == as_nat5 x - as_nat5 y + pow2 264)) #push-options "--z3rlimit 50" let lemma_sub_mod_264 x y t c5 = assert (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y); assert (as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264); if as_nat5 x >= as_nat5 y then assert (v c5 == 0 /\ as_nat5 t == as_nat5 x - as_nat5 y) else assert (v c5 == 1 /\ as_nat5 t == as_nat5 x - as_nat5 y + pow2 264) #pop-options let lemma_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4:nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) = assert ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) by (Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) val lemma_mul_5_low_264: x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma ( (x1 * y1) >= 0 /\ (x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) >= 0 /\ (x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) >= 0 /\ (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) >= 0 /\ ( let a0 = (x1 * y1) % pow2 56 in let a1 = ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) % pow2 56) in let a2 = ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) % pow2 56) in let a3 = ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in let a4 = (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5 + ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) in ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40))) private let lemma_mul_nat_is_nat (a:nat) (b:nat) : Lemma (a*b >= 0) = () private let lemma_div_nat_is_nat (a:nat) (b:pos) : Lemma (a/b >= 0) = () private val lemma_mul_5''': x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma (((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264) let lemma_mul_5''' x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 = calc (==) { ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x % pow2 264)); Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5) + (pow2 16 * x2 * y5 + pow2 16 * x3 * y4 + pow2 72 * x3 * y5 + pow2 16 * x4 * y3 + pow2 72 * x4 * y4 + pow2 128 * x4 * y5 + pow2 16 * x5 * y2 + pow2 72 * x5 * y3 + pow2 128 * x5 * y4 + pow2 184 * x5 * y5) * pow2 264) % pow2 264; (==) { _ by (Tactics.mapply (`eq_eq2); Tactics.mapply (`Math.Lemmas.lemma_mod_plus)) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264; } private val lemma_mod_264'': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) < pow2 264)
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_mod_264'': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) < pow2 264)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_mod_264''
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a0: Prims.nat -> a1: Prims.nat -> a2: Prims.nat -> a3: Prims.nat -> a4: Prims.nat -> FStar.Pervasives.Lemma (requires a0 < Hacl.Spec.BignumQ.Definitions.pow56 /\ a1 < Hacl.Spec.BignumQ.Definitions.pow56 /\ a2 < Hacl.Spec.BignumQ.Definitions.pow56 /\ a3 < Hacl.Spec.BignumQ.Definitions.pow56) (ensures a0 + Prims.pow2 56 * a1 + Prims.pow2 112 * a2 + Prims.pow2 168 * a3 + Prims.pow2 224 * (a4 % Prims.pow2 40) < Prims.pow2 264)
{ "end_col": 95, "end_line": 704, "start_col": 2, "start_line": 699 }
FStar.Pervasives.Lemma
val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_as_nat_pow264 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264)
val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264) let lemma_as_nat_pow264 x =
false
null
true
let x0, x1, x2, x3, x4 = x in assert_norm (pow2 40 * pow2 224 = pow2 264)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Hacl.Spec.BignumQ.Definitions.qelem5", "Lib.IntTypes.uint64", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Mul.op_Star", "Prims.pow2", "Prims.unit" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; } val lemma_div264: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in wide_as_nat5 x / pow2 264 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div264 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow528 x; assert (v x9 < pow2 40); calc (==) { (let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 + pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x5 x5; lemma_div264_x6 x6 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x7 x7; lemma_div264_x8 x8 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x9 x9 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; (==) { lemma_div264_aux x } wide_as_nat5 x / pow2 264; } #pop-options #pop-options // "--z3cliopt smt.arith.nl=false" val lemma_mod_264_aux: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in (wide_as_nat5 t) % pow2 264 == (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264)) #push-options "--z3rlimit 150" let lemma_mod_264_aux t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in assert_norm (pow2 16 * pow2 264 == pow2 280); assert_norm (pow2 72 * pow2 264 == pow2 336); assert_norm (pow2 128 * pow2 264 == pow2 392); assert_norm (pow2 184 * pow2 264 == pow2 448); assert_norm (pow2 240 * pow2 264 == pow2 504); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224 + (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) (pow2 264)} ((v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) + ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.cancel_mul_mod (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; } #pop-options val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264)
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_as_nat_pow264
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Hacl.Spec.BignumQ.Definitions.qelem5 -> FStar.Pervasives.Lemma (requires (let _ = x in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ x4 = _ in Hacl.Spec.BignumQ.Definitions.qelem_fits5 x (1, 1, 1, 1, 1) /\ Lib.IntTypes.v x4 < Prims.pow2 40) <: Type0)) (ensures Hacl.Spec.BignumQ.Definitions.as_nat5 x < Prims.pow2 264)
{ "end_col": 45, "end_line": 505, "start_col": 27, "start_line": 503 }
FStar.Pervasives.Lemma
val lemma_0 (x y: nat) (c: pos) : Lemma (requires (x >= y /\ x - y < c)) (ensures (x / c - y / c <= 1))
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_0 (x:nat) (y:nat) (c:pos) : Lemma (requires (x >= y /\ x - y < c)) (ensures (x / c - y / c <= 1)) = if x / c - y / c > 1 then ( Math.Lemmas.lemma_div_mod x c; Math.Lemmas.lemma_div_mod y c; Math.Lemmas.distributivity_sub_right c (x / c) (y / c); Math.Lemmas.lemma_div_mod (x-y) c; Math.Lemmas.small_div (x-y) c; Math.Lemmas.swap_mul c (x/c - y/c); Math.Lemmas.cancel_mul_div (x/c - y/c) c )
val lemma_0 (x y: nat) (c: pos) : Lemma (requires (x >= y /\ x - y < c)) (ensures (x / c - y / c <= 1)) let lemma_0 (x y: nat) (c: pos) : Lemma (requires (x >= y /\ x - y < c)) (ensures (x / c - y / c <= 1)) =
false
null
true
if x / c - y / c > 1 then (Math.Lemmas.lemma_div_mod x c; Math.Lemmas.lemma_div_mod y c; Math.Lemmas.distributivity_sub_right c (x / c) (y / c); Math.Lemmas.lemma_div_mod (x - y) c; Math.Lemmas.small_div (x - y) c; Math.Lemmas.swap_mul c (x / c - y / c); Math.Lemmas.cancel_mul_div (x / c - y / c) c)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Prims.nat", "Prims.pos", "Prims.op_GreaterThan", "Prims.op_Subtraction", "Prims.op_Division", "FStar.Math.Lemmas.cancel_mul_div", "Prims.unit", "FStar.Math.Lemmas.swap_mul", "FStar.Math.Lemmas.small_div", "FStar.Math.Lemmas.lemma_div_mod", "FStar.Math.Lemmas.distributivity_sub_right", "Prims.bool", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.squash", "Prims.op_LessThanOrEqual", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; } val lemma_div264: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in wide_as_nat5 x / pow2 264 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div264 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow528 x; assert (v x9 < pow2 40); calc (==) { (let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 + pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x5 x5; lemma_div264_x6 x6 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x7 x7; lemma_div264_x8 x8 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x9 x9 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; (==) { lemma_div264_aux x } wide_as_nat5 x / pow2 264; } #pop-options #pop-options // "--z3cliopt smt.arith.nl=false" val lemma_mod_264_aux: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in (wide_as_nat5 t) % pow2 264 == (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264)) #push-options "--z3rlimit 150" let lemma_mod_264_aux t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in assert_norm (pow2 16 * pow2 264 == pow2 280); assert_norm (pow2 72 * pow2 264 == pow2 336); assert_norm (pow2 128 * pow2 264 == pow2 392); assert_norm (pow2 184 * pow2 264 == pow2 448); assert_norm (pow2 240 * pow2 264 == pow2 504); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224 + (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) (pow2 264)} ((v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) + ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.cancel_mul_mod (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; } #pop-options val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264) let lemma_as_nat_pow264 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_mod_264: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in qelem_fits5 res (1, 1, 1, 1, 1) /\ as_nat5 res == (wide_as_nat5 t) % pow2 264)) let lemma_mod_264 t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let t4' = t4 &. u64 0xffffffffff in let res = (t0, t1, t2, t3, t4') in assert_norm (pow2 40 < pow2 64); assert_norm (pow2 40 - 1 == 0xffffffffff); mod_mask_lemma t4 40ul; assert (v (mod_mask #U64 #SEC 40ul) == 0xffffffffff); assert (v (t4 &. u64 0xffffffffff) == v t4 % pow2 40); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { lemma_mod_264_aux t } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168) (v t4 * pow2 224) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 * pow2 224) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v t4) 264 224 } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224) % pow2 264; (==) { lemma_as_nat_pow264 res; FStar.Math.Lemmas.modulo_lemma (as_nat5 res) (pow2 264) } v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224; } val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40)) let lemma_as_nat_pow264_x4 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264) #push-options "--z3rlimit 50" let lemma_sub_mod_264_aux x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 40 * pow2 224 = pow2 264) #pop-options val lemma_sub_mod_264: x:qelem5 -> y:qelem5 -> t:qelem5 -> c5:uint64 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264 /\ as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264 /\ v c5 <= 1 /\ (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y)) (ensures (if as_nat5 x >= as_nat5 y then as_nat5 t == as_nat5 x - as_nat5 y else as_nat5 t == as_nat5 x - as_nat5 y + pow2 264)) #push-options "--z3rlimit 50" let lemma_sub_mod_264 x y t c5 = assert (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y); assert (as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264); if as_nat5 x >= as_nat5 y then assert (v c5 == 0 /\ as_nat5 t == as_nat5 x - as_nat5 y) else assert (v c5 == 1 /\ as_nat5 t == as_nat5 x - as_nat5 y + pow2 264) #pop-options let lemma_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4:nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) = assert ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) by (Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) val lemma_mul_5_low_264: x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma ( (x1 * y1) >= 0 /\ (x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) >= 0 /\ (x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) >= 0 /\ (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) >= 0 /\ ( let a0 = (x1 * y1) % pow2 56 in let a1 = ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) % pow2 56) in let a2 = ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) % pow2 56) in let a3 = ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in let a4 = (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5 + ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) in ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40))) private let lemma_mul_nat_is_nat (a:nat) (b:nat) : Lemma (a*b >= 0) = () private let lemma_div_nat_is_nat (a:nat) (b:pos) : Lemma (a/b >= 0) = () private val lemma_mul_5''': x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma (((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264) let lemma_mul_5''' x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 = calc (==) { ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x % pow2 264)); Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5) + (pow2 16 * x2 * y5 + pow2 16 * x3 * y4 + pow2 72 * x3 * y5 + pow2 16 * x4 * y3 + pow2 72 * x4 * y4 + pow2 128 * x4 * y5 + pow2 16 * x5 * y2 + pow2 72 * x5 * y3 + pow2 128 * x5 * y4 + pow2 184 * x5 * y5) * pow2 264) % pow2 264; (==) { _ by (Tactics.mapply (`eq_eq2); Tactics.mapply (`Math.Lemmas.lemma_mod_plus)) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264; } private val lemma_mod_264'': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) < pow2 264) let lemma_mod_264'' a0 a1 a2 a3 a4 = assert_norm(pow2 40 = 0x10000000000); assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); assert_norm(pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000) private val lemma_mod_264': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) ) let lemma_mod_264' a0 a1 a2 a3 a4 = assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); Math.Lemmas.lemma_mod_plus_distr_l (pow2 224 * a4) (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3) (pow2 264); Math.Lemmas.pow2_multiplication_modulo_lemma_2 a4 264 224; lemma_mod_264'' a0 a1 a2 a3 a4; Math.Lemmas.modulo_lemma (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40)) (pow2 264) private let lemma_aux_0 (a:nat) (b:nat) (n:nat) : Lemma (pow2 n * a + pow2 (n+56) * b = pow2 n * (a % pow2 56) + pow2 (n+56) * (b + a / pow2 56)) = Math.Lemmas.lemma_div_mod a (pow2 56); Math.Lemmas.pow2_plus n 56; assert(a = pow2 56 * (a / pow2 56) + (a % pow2 56)); Math.Lemmas.distributivity_add_right (pow2 n) (pow2 56 * (a / pow2 56)) (a % pow2 56); Math.Lemmas.paren_mul_right (pow2 n) (pow2 56) (a / pow2 56); Math.Lemmas.distributivity_add_right (pow2 (n+56)) b (a / pow2 56) private val lemma_mod_264_small: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ( (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * (a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56))) (* These silly lemmas needed to guide the proof below... *) private let aux_nat_over_pos (p : nat) (q : pos) : Lemma (p / q >= 0) = () private let aux_nat_plus_nat (p : nat) (q : nat) : Lemma (p + q >= 0) = () let lemma_mod_264_small a0 a1 a2 a3 a4 = Math.Lemmas.lemma_div_mod a0 (pow2 56); Math.Lemmas.distributivity_add_right (pow2 56) a1 (a0 / pow2 56); (**) aux_nat_over_pos a0 (pow2 56); (**) aux_nat_plus_nat a1 (a0 / pow2 56); let a1':nat = (a1 + (a0 / pow2 56)) in (**) aux_nat_over_pos a1' (pow2 56); (**) aux_nat_plus_nat a2 (a1' / pow2 56); let a2':nat = (a2 + (a1' / pow2 56)) in (**) aux_nat_over_pos a2' (pow2 56); (**) aux_nat_plus_nat a3 (a2' / pow2 56); let a3':nat = (a3 + (a2' / pow2 56)) in lemma_aux_0 a1' a2 56; lemma_aux_0 a2' a3 112; lemma_aux_0 a3' a4 168 private val lemma_mod_264_: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ((a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * ((a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 40)) let lemma_mod_264_ a0 a1 a2 a3 a4 = lemma_mod_264_small a0 a1 a2 a3 a4; let x0 = a0 % pow2 56 in assert (x0 < pow56); let x1 = ((a1 + (a0 / pow2 56)) % pow2 56) in assert (x1 < pow56); let x2 = ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) in assert (x2 < pow56); let x3 = ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in assert (x3 < pow56); lemma_mod_264' x0 x1 x2 x3 (a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) #push-options "--z3rlimit 50" let lemma_mul_5_low_264 x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 = lemma_div_nat_is_nat (x1 * y1) (pow2 56); lemma_div_nat_is_nat (x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) (pow2 56); lemma_div_nat_is_nat (x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) (pow2 56); lemma_div_nat_is_nat (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) (pow2 56); lemma_mul_5''' x1 x2 x3 x4 x5 y1 y2 y3 y4 y5; lemma_mod_264_ (x1 * y1) (x2 * y1 + x1 * y2) (x3 * y1 + x2 * y2 + x1 * y3) (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5) #pop-options private val lemma_optimized_barrett_reduce: a:nat{a < pow2 512} -> Lemma (a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q < 2 * S.q /\ a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q >= 0) #push-options "--z3rlimit 50" let lemma_optimized_barrett_reduce a = assert_norm (pow2 248 = 0x100000000000000000000000000000000000000000000000000000000000000); assert_norm (pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000); assert_norm (S.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); assert_norm (0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 == pow2 512) #pop-options private val lemma_optimized_barrett_reduce2: a:nat{a < pow2 512} -> Lemma (a - ((a * (pow2 512 / S.q)) / pow2 512) * S.q < pow2 264 /\ a - ((a * (pow2 512 / S.q)) / pow2 512) * S.q >= 0) #push-options "--z3rlimit 50" let lemma_optimized_barrett_reduce2 a = assert_norm (pow2 248 = 0x100000000000000000000000000000000000000000000000000000000000000); assert_norm (pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000); assert_norm (S.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); assert_norm (0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 == pow2 512) #pop-options #push-options "--fuel 0 --z3cliopt smt.arith.nl=true --smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native --z3rlimit 30" private let lemma_0 (x:nat) (y:nat) (c:pos) : Lemma (requires (x >= y /\ x - y < c))
false
false
Hacl.Spec.BignumQ.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "native", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=true" ], "z3refresh": false, "z3rlimit": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_0 (x y: nat) (c: pos) : Lemma (requires (x >= y /\ x - y < c)) (ensures (x / c - y / c <= 1))
[]
Hacl.Spec.BignumQ.Lemmas.lemma_0
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Prims.nat -> y: Prims.nat -> c: Prims.pos -> FStar.Pervasives.Lemma (requires x >= y /\ x - y < c) (ensures x / c - y / c <= 1)
{ "end_col": 7, "end_line": 843, "start_col": 4, "start_line": 835 }
FStar.Pervasives.Lemma
val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40))
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_as_nat_pow264_x4 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264)
val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40)) let lemma_as_nat_pow264_x4 x =
false
null
true
let x0, x1, x2, x3, x4 = x in assert_norm (pow2 40 * pow2 224 = pow2 264)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Hacl.Spec.BignumQ.Definitions.qelem5", "Lib.IntTypes.uint64", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Mul.op_Star", "Prims.pow2", "Prims.unit" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; } val lemma_div264: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in wide_as_nat5 x / pow2 264 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div264 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow528 x; assert (v x9 < pow2 40); calc (==) { (let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 + pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x5 x5; lemma_div264_x6 x6 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x7 x7; lemma_div264_x8 x8 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x9 x9 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; (==) { lemma_div264_aux x } wide_as_nat5 x / pow2 264; } #pop-options #pop-options // "--z3cliopt smt.arith.nl=false" val lemma_mod_264_aux: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in (wide_as_nat5 t) % pow2 264 == (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264)) #push-options "--z3rlimit 150" let lemma_mod_264_aux t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in assert_norm (pow2 16 * pow2 264 == pow2 280); assert_norm (pow2 72 * pow2 264 == pow2 336); assert_norm (pow2 128 * pow2 264 == pow2 392); assert_norm (pow2 184 * pow2 264 == pow2 448); assert_norm (pow2 240 * pow2 264 == pow2 504); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224 + (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) (pow2 264)} ((v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) + ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.cancel_mul_mod (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; } #pop-options val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264) let lemma_as_nat_pow264 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_mod_264: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in qelem_fits5 res (1, 1, 1, 1, 1) /\ as_nat5 res == (wide_as_nat5 t) % pow2 264)) let lemma_mod_264 t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let t4' = t4 &. u64 0xffffffffff in let res = (t0, t1, t2, t3, t4') in assert_norm (pow2 40 < pow2 64); assert_norm (pow2 40 - 1 == 0xffffffffff); mod_mask_lemma t4 40ul; assert (v (mod_mask #U64 #SEC 40ul) == 0xffffffffff); assert (v (t4 &. u64 0xffffffffff) == v t4 % pow2 40); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { lemma_mod_264_aux t } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168) (v t4 * pow2 224) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 * pow2 224) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v t4) 264 224 } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224) % pow2 264; (==) { lemma_as_nat_pow264 res; FStar.Math.Lemmas.modulo_lemma (as_nat5 res) (pow2 264) } v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224; } val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40))
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40))
[]
Hacl.Spec.BignumQ.Lemmas.lemma_as_nat_pow264_x4
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Hacl.Spec.BignumQ.Definitions.qelem5 -> FStar.Pervasives.Lemma (requires Hacl.Spec.BignumQ.Definitions.qelem_fits5 x (1, 1, 1, 1, 1) /\ Hacl.Spec.BignumQ.Definitions.as_nat5 x < Prims.pow2 264) (ensures (let _ = x in (let FStar.Pervasives.Native.Mktuple5 #_ #_ #_ #_ #_ _ _ _ _ x4 = _ in Lib.IntTypes.v x4 < Prims.pow2 40) <: Type0))
{ "end_col": 45, "end_line": 552, "start_col": 30, "start_line": 550 }
FStar.Pervasives.Lemma
val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280)
val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f =
false
null
true
assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Hacl.Spec.BignumQ.Definitions.qelem5", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Mul.op_Star", "Prims.pow2", "Prims.unit" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_as_nat5
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Hacl.Spec.BignumQ.Definitions.qelem5 -> FStar.Pervasives.Lemma (requires Hacl.Spec.BignumQ.Definitions.qelem_fits5 f (1, 1, 1, 1, 1)) (ensures Hacl.Spec.BignumQ.Definitions.as_nat5 f < Prims.pow2 280)
{ "end_col": 45, "end_line": 36, "start_col": 2, "start_line": 33 }
FStar.Pervasives.Lemma
val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2
val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 =
false
null
true
let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Lib.IntTypes.uint64", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.logxor_lemma", "Prims.unit", "Prims._assert", "Prims.eq2", "Lib.IntTypes.range_t", "Prims.op_Equality", "Prims.int", "Lib.IntTypes.u64", "Prims.bool", "Lib.IntTypes.op_Hat_Dot", "Lib.IntTypes.int_t", "Prims.l_imp", "Lib.IntTypes.logand_lemma", "Lib.IntTypes.op_Amp_Dot", "Prims.op_Subtraction", "Prims.pow2", "Lib.IntTypes.op_Subtraction_Dot" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y)
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_choose_step
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
bit: Lib.IntTypes.uint64{Lib.IntTypes.v bit <= 1} -> x: Lib.IntTypes.uint64 -> y: Lib.IntTypes.uint64 -> FStar.Pervasives.Lemma (ensures (let mask = bit -. Lib.IntTypes.u64 1 in let z = x ^. (mask &. x ^. y) in (match Lib.IntTypes.v bit = 1 with | true -> z == x | _ -> z == y) <: Type0))
{ "end_col": 20, "end_line": 58, "start_col": 33, "start_line": 48 }
FStar.Pervasives.Lemma
val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56)
val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 =
false
null
true
assert_norm (pow2 32 * pow2 24 = pow2 56)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Lib.IntTypes.uint64", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Mul.op_Star", "Prims.pow2", "Prims.unit" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32)
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_div248_x5
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x5: Lib.IntTypes.uint64 -> FStar.Pervasives.Lemma (ensures Prims.pow2 32 * (Lib.IntTypes.v x5 % Prims.pow2 24) + (Lib.IntTypes.v x5 / Prims.pow2 24) * Prims.pow2 56 == Lib.IntTypes.v x5 * Prims.pow2 32)
{ "end_col": 43, "end_line": 157, "start_col": 2, "start_line": 157 }
FStar.Pervasives.Lemma
val lemma_1 (x y: nat) (c: pos) : Lemma (requires (x - y < c /\ x >= y)) (ensures (x - y = (if (x % c) - (y % c) < 0 then c + (x % c) - (y % c) else (x % c) - (y % c))))
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_1 (x:nat) (y:nat) (c:pos) : Lemma (requires (x - y < c /\ x >= y)) (ensures (x - y = (if (x % c) - (y % c) < 0 then c + (x % c) - (y % c) else (x % c) - (y % c)))) = Math.Lemmas.lemma_div_mod x c; Math.Lemmas.lemma_div_mod y c; Math.Lemmas.distributivity_sub_right c (y/c) (x/c); assert( (x%c) - (y%c) = x - y - c*((x/c) - (y/c))); lemma_0 x y c
val lemma_1 (x y: nat) (c: pos) : Lemma (requires (x - y < c /\ x >= y)) (ensures (x - y = (if (x % c) - (y % c) < 0 then c + (x % c) - (y % c) else (x % c) - (y % c)))) let lemma_1 (x y: nat) (c: pos) : Lemma (requires (x - y < c /\ x >= y)) (ensures (x - y = (if (x % c) - (y % c) < 0 then c + (x % c) - (y % c) else (x % c) - (y % c)))) =
false
null
true
Math.Lemmas.lemma_div_mod x c; Math.Lemmas.lemma_div_mod y c; Math.Lemmas.distributivity_sub_right c (y / c) (x / c); assert ((x % c) - (y % c) = x - y - c * ((x / c) - (y / c))); lemma_0 x y c
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Prims.nat", "Prims.pos", "Hacl.Spec.BignumQ.Lemmas.lemma_0", "Prims.unit", "Prims._assert", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Subtraction", "Prims.op_Modulus", "FStar.Mul.op_Star", "Prims.op_Division", "FStar.Math.Lemmas.distributivity_sub_right", "FStar.Math.Lemmas.lemma_div_mod", "Prims.l_and", "Prims.op_LessThan", "Prims.op_GreaterThanOrEqual", "Prims.squash", "Prims.op_Addition", "Prims.bool", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; } val lemma_div264: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in wide_as_nat5 x / pow2 264 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div264 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow528 x; assert (v x9 < pow2 40); calc (==) { (let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 + pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x5 x5; lemma_div264_x6 x6 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x7 x7; lemma_div264_x8 x8 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x9 x9 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; (==) { lemma_div264_aux x } wide_as_nat5 x / pow2 264; } #pop-options #pop-options // "--z3cliopt smt.arith.nl=false" val lemma_mod_264_aux: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in (wide_as_nat5 t) % pow2 264 == (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264)) #push-options "--z3rlimit 150" let lemma_mod_264_aux t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in assert_norm (pow2 16 * pow2 264 == pow2 280); assert_norm (pow2 72 * pow2 264 == pow2 336); assert_norm (pow2 128 * pow2 264 == pow2 392); assert_norm (pow2 184 * pow2 264 == pow2 448); assert_norm (pow2 240 * pow2 264 == pow2 504); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224 + (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) (pow2 264)} ((v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) + ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.cancel_mul_mod (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; } #pop-options val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264) let lemma_as_nat_pow264 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_mod_264: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in qelem_fits5 res (1, 1, 1, 1, 1) /\ as_nat5 res == (wide_as_nat5 t) % pow2 264)) let lemma_mod_264 t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let t4' = t4 &. u64 0xffffffffff in let res = (t0, t1, t2, t3, t4') in assert_norm (pow2 40 < pow2 64); assert_norm (pow2 40 - 1 == 0xffffffffff); mod_mask_lemma t4 40ul; assert (v (mod_mask #U64 #SEC 40ul) == 0xffffffffff); assert (v (t4 &. u64 0xffffffffff) == v t4 % pow2 40); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { lemma_mod_264_aux t } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168) (v t4 * pow2 224) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 * pow2 224) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v t4) 264 224 } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224) % pow2 264; (==) { lemma_as_nat_pow264 res; FStar.Math.Lemmas.modulo_lemma (as_nat5 res) (pow2 264) } v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224; } val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40)) let lemma_as_nat_pow264_x4 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264) #push-options "--z3rlimit 50" let lemma_sub_mod_264_aux x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 40 * pow2 224 = pow2 264) #pop-options val lemma_sub_mod_264: x:qelem5 -> y:qelem5 -> t:qelem5 -> c5:uint64 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264 /\ as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264 /\ v c5 <= 1 /\ (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y)) (ensures (if as_nat5 x >= as_nat5 y then as_nat5 t == as_nat5 x - as_nat5 y else as_nat5 t == as_nat5 x - as_nat5 y + pow2 264)) #push-options "--z3rlimit 50" let lemma_sub_mod_264 x y t c5 = assert (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y); assert (as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264); if as_nat5 x >= as_nat5 y then assert (v c5 == 0 /\ as_nat5 t == as_nat5 x - as_nat5 y) else assert (v c5 == 1 /\ as_nat5 t == as_nat5 x - as_nat5 y + pow2 264) #pop-options let lemma_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4:nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) = assert ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) by (Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) val lemma_mul_5_low_264: x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma ( (x1 * y1) >= 0 /\ (x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) >= 0 /\ (x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) >= 0 /\ (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) >= 0 /\ ( let a0 = (x1 * y1) % pow2 56 in let a1 = ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) % pow2 56) in let a2 = ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) % pow2 56) in let a3 = ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in let a4 = (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5 + ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) in ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40))) private let lemma_mul_nat_is_nat (a:nat) (b:nat) : Lemma (a*b >= 0) = () private let lemma_div_nat_is_nat (a:nat) (b:pos) : Lemma (a/b >= 0) = () private val lemma_mul_5''': x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma (((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264) let lemma_mul_5''' x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 = calc (==) { ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x % pow2 264)); Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5) + (pow2 16 * x2 * y5 + pow2 16 * x3 * y4 + pow2 72 * x3 * y5 + pow2 16 * x4 * y3 + pow2 72 * x4 * y4 + pow2 128 * x4 * y5 + pow2 16 * x5 * y2 + pow2 72 * x5 * y3 + pow2 128 * x5 * y4 + pow2 184 * x5 * y5) * pow2 264) % pow2 264; (==) { _ by (Tactics.mapply (`eq_eq2); Tactics.mapply (`Math.Lemmas.lemma_mod_plus)) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264; } private val lemma_mod_264'': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) < pow2 264) let lemma_mod_264'' a0 a1 a2 a3 a4 = assert_norm(pow2 40 = 0x10000000000); assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); assert_norm(pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000) private val lemma_mod_264': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) ) let lemma_mod_264' a0 a1 a2 a3 a4 = assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); Math.Lemmas.lemma_mod_plus_distr_l (pow2 224 * a4) (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3) (pow2 264); Math.Lemmas.pow2_multiplication_modulo_lemma_2 a4 264 224; lemma_mod_264'' a0 a1 a2 a3 a4; Math.Lemmas.modulo_lemma (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40)) (pow2 264) private let lemma_aux_0 (a:nat) (b:nat) (n:nat) : Lemma (pow2 n * a + pow2 (n+56) * b = pow2 n * (a % pow2 56) + pow2 (n+56) * (b + a / pow2 56)) = Math.Lemmas.lemma_div_mod a (pow2 56); Math.Lemmas.pow2_plus n 56; assert(a = pow2 56 * (a / pow2 56) + (a % pow2 56)); Math.Lemmas.distributivity_add_right (pow2 n) (pow2 56 * (a / pow2 56)) (a % pow2 56); Math.Lemmas.paren_mul_right (pow2 n) (pow2 56) (a / pow2 56); Math.Lemmas.distributivity_add_right (pow2 (n+56)) b (a / pow2 56) private val lemma_mod_264_small: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ( (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * (a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56))) (* These silly lemmas needed to guide the proof below... *) private let aux_nat_over_pos (p : nat) (q : pos) : Lemma (p / q >= 0) = () private let aux_nat_plus_nat (p : nat) (q : nat) : Lemma (p + q >= 0) = () let lemma_mod_264_small a0 a1 a2 a3 a4 = Math.Lemmas.lemma_div_mod a0 (pow2 56); Math.Lemmas.distributivity_add_right (pow2 56) a1 (a0 / pow2 56); (**) aux_nat_over_pos a0 (pow2 56); (**) aux_nat_plus_nat a1 (a0 / pow2 56); let a1':nat = (a1 + (a0 / pow2 56)) in (**) aux_nat_over_pos a1' (pow2 56); (**) aux_nat_plus_nat a2 (a1' / pow2 56); let a2':nat = (a2 + (a1' / pow2 56)) in (**) aux_nat_over_pos a2' (pow2 56); (**) aux_nat_plus_nat a3 (a2' / pow2 56); let a3':nat = (a3 + (a2' / pow2 56)) in lemma_aux_0 a1' a2 56; lemma_aux_0 a2' a3 112; lemma_aux_0 a3' a4 168 private val lemma_mod_264_: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ((a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * ((a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 40)) let lemma_mod_264_ a0 a1 a2 a3 a4 = lemma_mod_264_small a0 a1 a2 a3 a4; let x0 = a0 % pow2 56 in assert (x0 < pow56); let x1 = ((a1 + (a0 / pow2 56)) % pow2 56) in assert (x1 < pow56); let x2 = ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) in assert (x2 < pow56); let x3 = ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in assert (x3 < pow56); lemma_mod_264' x0 x1 x2 x3 (a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) #push-options "--z3rlimit 50" let lemma_mul_5_low_264 x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 = lemma_div_nat_is_nat (x1 * y1) (pow2 56); lemma_div_nat_is_nat (x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) (pow2 56); lemma_div_nat_is_nat (x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) (pow2 56); lemma_div_nat_is_nat (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) (pow2 56); lemma_mul_5''' x1 x2 x3 x4 x5 y1 y2 y3 y4 y5; lemma_mod_264_ (x1 * y1) (x2 * y1 + x1 * y2) (x3 * y1 + x2 * y2 + x1 * y3) (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5) #pop-options private val lemma_optimized_barrett_reduce: a:nat{a < pow2 512} -> Lemma (a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q < 2 * S.q /\ a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q >= 0) #push-options "--z3rlimit 50" let lemma_optimized_barrett_reduce a = assert_norm (pow2 248 = 0x100000000000000000000000000000000000000000000000000000000000000); assert_norm (pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000); assert_norm (S.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); assert_norm (0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 == pow2 512) #pop-options private val lemma_optimized_barrett_reduce2: a:nat{a < pow2 512} -> Lemma (a - ((a * (pow2 512 / S.q)) / pow2 512) * S.q < pow2 264 /\ a - ((a * (pow2 512 / S.q)) / pow2 512) * S.q >= 0) #push-options "--z3rlimit 50" let lemma_optimized_barrett_reduce2 a = assert_norm (pow2 248 = 0x100000000000000000000000000000000000000000000000000000000000000); assert_norm (pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000); assert_norm (S.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); assert_norm (0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 == pow2 512) #pop-options #push-options "--fuel 0 --z3cliopt smt.arith.nl=true --smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native --z3rlimit 30" private let lemma_0 (x:nat) (y:nat) (c:pos) : Lemma (requires (x >= y /\ x - y < c)) (ensures (x / c - y / c <= 1)) = if x / c - y / c > 1 then ( Math.Lemmas.lemma_div_mod x c; Math.Lemmas.lemma_div_mod y c; Math.Lemmas.distributivity_sub_right c (x / c) (y / c); Math.Lemmas.lemma_div_mod (x-y) c; Math.Lemmas.small_div (x-y) c; Math.Lemmas.swap_mul c (x/c - y/c); Math.Lemmas.cancel_mul_div (x/c - y/c) c ) #pop-options #push-options "--z3rlimit 30" private let lemma_1 (x:nat) (y:nat) (c:pos) : Lemma (requires (x - y < c /\ x >= y)) (ensures (x - y = (if (x % c) - (y % c) < 0 then c + (x % c) - (y % c)
false
false
Hacl.Spec.BignumQ.Lemmas.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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_1 (x y: nat) (c: pos) : Lemma (requires (x - y < c /\ x >= y)) (ensures (x - y = (if (x % c) - (y % c) < 0 then c + (x % c) - (y % c) else (x % c) - (y % c))))
[]
Hacl.Spec.BignumQ.Lemmas.lemma_1
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Prims.nat -> y: Prims.nat -> c: Prims.pos -> FStar.Pervasives.Lemma (requires x - y < c /\ x >= y) (ensures x - y = (match x % c - y % c < 0 with | true -> c + x % c - y % c | _ -> x % c - y % c))
{ "end_col": 17, "end_line": 856, "start_col": 4, "start_line": 852 }
FStar.Pervasives.Lemma
val lemma_mod_264_: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ((a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * ((a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 40))
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_mod_264_ a0 a1 a2 a3 a4 = lemma_mod_264_small a0 a1 a2 a3 a4; let x0 = a0 % pow2 56 in assert (x0 < pow56); let x1 = ((a1 + (a0 / pow2 56)) % pow2 56) in assert (x1 < pow56); let x2 = ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) in assert (x2 < pow56); let x3 = ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in assert (x3 < pow56); lemma_mod_264' x0 x1 x2 x3 (a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56))
val lemma_mod_264_: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ((a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * ((a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 40)) let lemma_mod_264_ a0 a1 a2 a3 a4 =
false
null
true
lemma_mod_264_small a0 a1 a2 a3 a4; let x0 = a0 % pow2 56 in assert (x0 < pow56); let x1 = ((a1 + (a0 / pow2 56)) % pow2 56) in assert (x1 < pow56); let x2 = ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) in assert (x2 < pow56); let x3 = ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in assert (x3 < pow56); lemma_mod_264' x0 x1 x2 x3 (a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56))
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Prims.nat", "Hacl.Spec.BignumQ.Lemmas.lemma_mod_264'", "Prims.op_Addition", "Prims.op_Division", "Prims.pow2", "Prims.unit", "Prims._assert", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.BignumQ.Definitions.pow56", "Prims.int", "Prims.op_Modulus", "Hacl.Spec.BignumQ.Lemmas.lemma_mod_264_small" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; } val lemma_div264: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in wide_as_nat5 x / pow2 264 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div264 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow528 x; assert (v x9 < pow2 40); calc (==) { (let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 + pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x5 x5; lemma_div264_x6 x6 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x7 x7; lemma_div264_x8 x8 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x9 x9 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; (==) { lemma_div264_aux x } wide_as_nat5 x / pow2 264; } #pop-options #pop-options // "--z3cliopt smt.arith.nl=false" val lemma_mod_264_aux: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in (wide_as_nat5 t) % pow2 264 == (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264)) #push-options "--z3rlimit 150" let lemma_mod_264_aux t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in assert_norm (pow2 16 * pow2 264 == pow2 280); assert_norm (pow2 72 * pow2 264 == pow2 336); assert_norm (pow2 128 * pow2 264 == pow2 392); assert_norm (pow2 184 * pow2 264 == pow2 448); assert_norm (pow2 240 * pow2 264 == pow2 504); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224 + (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) (pow2 264)} ((v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) + ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.cancel_mul_mod (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; } #pop-options val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264) let lemma_as_nat_pow264 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_mod_264: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in qelem_fits5 res (1, 1, 1, 1, 1) /\ as_nat5 res == (wide_as_nat5 t) % pow2 264)) let lemma_mod_264 t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let t4' = t4 &. u64 0xffffffffff in let res = (t0, t1, t2, t3, t4') in assert_norm (pow2 40 < pow2 64); assert_norm (pow2 40 - 1 == 0xffffffffff); mod_mask_lemma t4 40ul; assert (v (mod_mask #U64 #SEC 40ul) == 0xffffffffff); assert (v (t4 &. u64 0xffffffffff) == v t4 % pow2 40); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { lemma_mod_264_aux t } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168) (v t4 * pow2 224) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 * pow2 224) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v t4) 264 224 } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224) % pow2 264; (==) { lemma_as_nat_pow264 res; FStar.Math.Lemmas.modulo_lemma (as_nat5 res) (pow2 264) } v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224; } val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40)) let lemma_as_nat_pow264_x4 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264) #push-options "--z3rlimit 50" let lemma_sub_mod_264_aux x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 40 * pow2 224 = pow2 264) #pop-options val lemma_sub_mod_264: x:qelem5 -> y:qelem5 -> t:qelem5 -> c5:uint64 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264 /\ as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264 /\ v c5 <= 1 /\ (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y)) (ensures (if as_nat5 x >= as_nat5 y then as_nat5 t == as_nat5 x - as_nat5 y else as_nat5 t == as_nat5 x - as_nat5 y + pow2 264)) #push-options "--z3rlimit 50" let lemma_sub_mod_264 x y t c5 = assert (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y); assert (as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264); if as_nat5 x >= as_nat5 y then assert (v c5 == 0 /\ as_nat5 t == as_nat5 x - as_nat5 y) else assert (v c5 == 1 /\ as_nat5 t == as_nat5 x - as_nat5 y + pow2 264) #pop-options let lemma_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4:nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) = assert ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) by (Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) val lemma_mul_5_low_264: x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma ( (x1 * y1) >= 0 /\ (x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) >= 0 /\ (x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) >= 0 /\ (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) >= 0 /\ ( let a0 = (x1 * y1) % pow2 56 in let a1 = ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) % pow2 56) in let a2 = ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) % pow2 56) in let a3 = ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in let a4 = (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5 + ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) in ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40))) private let lemma_mul_nat_is_nat (a:nat) (b:nat) : Lemma (a*b >= 0) = () private let lemma_div_nat_is_nat (a:nat) (b:pos) : Lemma (a/b >= 0) = () private val lemma_mul_5''': x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma (((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264) let lemma_mul_5''' x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 = calc (==) { ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x % pow2 264)); Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5) + (pow2 16 * x2 * y5 + pow2 16 * x3 * y4 + pow2 72 * x3 * y5 + pow2 16 * x4 * y3 + pow2 72 * x4 * y4 + pow2 128 * x4 * y5 + pow2 16 * x5 * y2 + pow2 72 * x5 * y3 + pow2 128 * x5 * y4 + pow2 184 * x5 * y5) * pow2 264) % pow2 264; (==) { _ by (Tactics.mapply (`eq_eq2); Tactics.mapply (`Math.Lemmas.lemma_mod_plus)) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264; } private val lemma_mod_264'': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) < pow2 264) let lemma_mod_264'' a0 a1 a2 a3 a4 = assert_norm(pow2 40 = 0x10000000000); assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); assert_norm(pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000) private val lemma_mod_264': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) ) let lemma_mod_264' a0 a1 a2 a3 a4 = assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); Math.Lemmas.lemma_mod_plus_distr_l (pow2 224 * a4) (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3) (pow2 264); Math.Lemmas.pow2_multiplication_modulo_lemma_2 a4 264 224; lemma_mod_264'' a0 a1 a2 a3 a4; Math.Lemmas.modulo_lemma (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40)) (pow2 264) private let lemma_aux_0 (a:nat) (b:nat) (n:nat) : Lemma (pow2 n * a + pow2 (n+56) * b = pow2 n * (a % pow2 56) + pow2 (n+56) * (b + a / pow2 56)) = Math.Lemmas.lemma_div_mod a (pow2 56); Math.Lemmas.pow2_plus n 56; assert(a = pow2 56 * (a / pow2 56) + (a % pow2 56)); Math.Lemmas.distributivity_add_right (pow2 n) (pow2 56 * (a / pow2 56)) (a % pow2 56); Math.Lemmas.paren_mul_right (pow2 n) (pow2 56) (a / pow2 56); Math.Lemmas.distributivity_add_right (pow2 (n+56)) b (a / pow2 56) private val lemma_mod_264_small: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ( (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * (a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56))) (* These silly lemmas needed to guide the proof below... *) private let aux_nat_over_pos (p : nat) (q : pos) : Lemma (p / q >= 0) = () private let aux_nat_plus_nat (p : nat) (q : nat) : Lemma (p + q >= 0) = () let lemma_mod_264_small a0 a1 a2 a3 a4 = Math.Lemmas.lemma_div_mod a0 (pow2 56); Math.Lemmas.distributivity_add_right (pow2 56) a1 (a0 / pow2 56); (**) aux_nat_over_pos a0 (pow2 56); (**) aux_nat_plus_nat a1 (a0 / pow2 56); let a1':nat = (a1 + (a0 / pow2 56)) in (**) aux_nat_over_pos a1' (pow2 56); (**) aux_nat_plus_nat a2 (a1' / pow2 56); let a2':nat = (a2 + (a1' / pow2 56)) in (**) aux_nat_over_pos a2' (pow2 56); (**) aux_nat_plus_nat a3 (a2' / pow2 56); let a3':nat = (a3 + (a2' / pow2 56)) in lemma_aux_0 a1' a2 56; lemma_aux_0 a2' a3 112; lemma_aux_0 a3' a4 168 private val lemma_mod_264_: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ((a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * ((a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 40))
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_mod_264_: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ((a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * ((a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 40))
[]
Hacl.Spec.BignumQ.Lemmas.lemma_mod_264_
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a0: Prims.nat -> a1: Prims.nat -> a2: Prims.nat -> a3: Prims.nat -> a4: Prims.nat -> FStar.Pervasives.Lemma (ensures (a0 + Prims.pow2 56 * a1 + Prims.pow2 112 * a2 + Prims.pow2 168 * a3 + Prims.pow2 224 * a4) % Prims.pow2 264 = a0 % Prims.pow2 56 + Prims.pow2 56 * ((a1 + a0 / Prims.pow2 56) % Prims.pow2 56) + Prims.pow2 112 * ((a2 + (a1 + a0 / Prims.pow2 56) / Prims.pow2 56) % Prims.pow2 56) + Prims.pow2 168 * ((a3 + (a2 + (a1 + a0 / Prims.pow2 56) / Prims.pow2 56) / Prims.pow2 56) % Prims.pow2 56) + Prims.pow2 224 * ((a4 + (a3 + (a2 + (a1 + a0 / Prims.pow2 56) / Prims.pow2 56) / Prims.pow2 56) / Prims.pow2 56 ) % Prims.pow2 40))
{ "end_col": 107, "end_line": 790, "start_col": 2, "start_line": 781 }
FStar.Pervasives.Lemma
val lemma_aux_0 (a b n: nat) : Lemma (pow2 n * a + pow2 (n + 56) * b = pow2 n * (a % pow2 56) + pow2 (n + 56) * (b + a / pow2 56))
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_aux_0 (a:nat) (b:nat) (n:nat) : Lemma (pow2 n * a + pow2 (n+56) * b = pow2 n * (a % pow2 56) + pow2 (n+56) * (b + a / pow2 56)) = Math.Lemmas.lemma_div_mod a (pow2 56); Math.Lemmas.pow2_plus n 56; assert(a = pow2 56 * (a / pow2 56) + (a % pow2 56)); Math.Lemmas.distributivity_add_right (pow2 n) (pow2 56 * (a / pow2 56)) (a % pow2 56); Math.Lemmas.paren_mul_right (pow2 n) (pow2 56) (a / pow2 56); Math.Lemmas.distributivity_add_right (pow2 (n+56)) b (a / pow2 56)
val lemma_aux_0 (a b n: nat) : Lemma (pow2 n * a + pow2 (n + 56) * b = pow2 n * (a % pow2 56) + pow2 (n + 56) * (b + a / pow2 56)) let lemma_aux_0 (a b n: nat) : Lemma (pow2 n * a + pow2 (n + 56) * b = pow2 n * (a % pow2 56) + pow2 (n + 56) * (b + a / pow2 56)) =
false
null
true
Math.Lemmas.lemma_div_mod a (pow2 56); Math.Lemmas.pow2_plus n 56; assert (a = pow2 56 * (a / pow2 56) + (a % pow2 56)); Math.Lemmas.distributivity_add_right (pow2 n) (pow2 56 * (a / pow2 56)) (a % pow2 56); Math.Lemmas.paren_mul_right (pow2 n) (pow2 56) (a / pow2 56); Math.Lemmas.distributivity_add_right (pow2 (n + 56)) b (a / pow2 56)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Prims.nat", "FStar.Math.Lemmas.distributivity_add_right", "Prims.pow2", "Prims.op_Addition", "Prims.op_Division", "Prims.unit", "FStar.Math.Lemmas.paren_mul_right", "FStar.Mul.op_Star", "Prims.op_Modulus", "Prims._assert", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Math.Lemmas.pow2_plus", "FStar.Math.Lemmas.lemma_div_mod", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; } val lemma_div264: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in wide_as_nat5 x / pow2 264 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div264 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow528 x; assert (v x9 < pow2 40); calc (==) { (let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 + pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x5 x5; lemma_div264_x6 x6 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x7 x7; lemma_div264_x8 x8 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x9 x9 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; (==) { lemma_div264_aux x } wide_as_nat5 x / pow2 264; } #pop-options #pop-options // "--z3cliopt smt.arith.nl=false" val lemma_mod_264_aux: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in (wide_as_nat5 t) % pow2 264 == (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264)) #push-options "--z3rlimit 150" let lemma_mod_264_aux t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in assert_norm (pow2 16 * pow2 264 == pow2 280); assert_norm (pow2 72 * pow2 264 == pow2 336); assert_norm (pow2 128 * pow2 264 == pow2 392); assert_norm (pow2 184 * pow2 264 == pow2 448); assert_norm (pow2 240 * pow2 264 == pow2 504); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224 + (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) (pow2 264)} ((v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) + ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.cancel_mul_mod (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; } #pop-options val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264) let lemma_as_nat_pow264 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_mod_264: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in qelem_fits5 res (1, 1, 1, 1, 1) /\ as_nat5 res == (wide_as_nat5 t) % pow2 264)) let lemma_mod_264 t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let t4' = t4 &. u64 0xffffffffff in let res = (t0, t1, t2, t3, t4') in assert_norm (pow2 40 < pow2 64); assert_norm (pow2 40 - 1 == 0xffffffffff); mod_mask_lemma t4 40ul; assert (v (mod_mask #U64 #SEC 40ul) == 0xffffffffff); assert (v (t4 &. u64 0xffffffffff) == v t4 % pow2 40); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { lemma_mod_264_aux t } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168) (v t4 * pow2 224) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 * pow2 224) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v t4) 264 224 } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224) % pow2 264; (==) { lemma_as_nat_pow264 res; FStar.Math.Lemmas.modulo_lemma (as_nat5 res) (pow2 264) } v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224; } val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40)) let lemma_as_nat_pow264_x4 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264) #push-options "--z3rlimit 50" let lemma_sub_mod_264_aux x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 40 * pow2 224 = pow2 264) #pop-options val lemma_sub_mod_264: x:qelem5 -> y:qelem5 -> t:qelem5 -> c5:uint64 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264 /\ as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264 /\ v c5 <= 1 /\ (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y)) (ensures (if as_nat5 x >= as_nat5 y then as_nat5 t == as_nat5 x - as_nat5 y else as_nat5 t == as_nat5 x - as_nat5 y + pow2 264)) #push-options "--z3rlimit 50" let lemma_sub_mod_264 x y t c5 = assert (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y); assert (as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264); if as_nat5 x >= as_nat5 y then assert (v c5 == 0 /\ as_nat5 t == as_nat5 x - as_nat5 y) else assert (v c5 == 1 /\ as_nat5 t == as_nat5 x - as_nat5 y + pow2 264) #pop-options let lemma_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4:nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) = assert ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) by (Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) val lemma_mul_5_low_264: x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma ( (x1 * y1) >= 0 /\ (x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) >= 0 /\ (x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) >= 0 /\ (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) >= 0 /\ ( let a0 = (x1 * y1) % pow2 56 in let a1 = ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) % pow2 56) in let a2 = ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) % pow2 56) in let a3 = ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in let a4 = (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5 + ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) in ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40))) private let lemma_mul_nat_is_nat (a:nat) (b:nat) : Lemma (a*b >= 0) = () private let lemma_div_nat_is_nat (a:nat) (b:pos) : Lemma (a/b >= 0) = () private val lemma_mul_5''': x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma (((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264) let lemma_mul_5''' x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 = calc (==) { ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x % pow2 264)); Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5) + (pow2 16 * x2 * y5 + pow2 16 * x3 * y4 + pow2 72 * x3 * y5 + pow2 16 * x4 * y3 + pow2 72 * x4 * y4 + pow2 128 * x4 * y5 + pow2 16 * x5 * y2 + pow2 72 * x5 * y3 + pow2 128 * x5 * y4 + pow2 184 * x5 * y5) * pow2 264) % pow2 264; (==) { _ by (Tactics.mapply (`eq_eq2); Tactics.mapply (`Math.Lemmas.lemma_mod_plus)) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264; } private val lemma_mod_264'': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) < pow2 264) let lemma_mod_264'' a0 a1 a2 a3 a4 = assert_norm(pow2 40 = 0x10000000000); assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); assert_norm(pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000) private val lemma_mod_264': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) ) let lemma_mod_264' a0 a1 a2 a3 a4 = assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); Math.Lemmas.lemma_mod_plus_distr_l (pow2 224 * a4) (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3) (pow2 264); Math.Lemmas.pow2_multiplication_modulo_lemma_2 a4 264 224; lemma_mod_264'' a0 a1 a2 a3 a4; Math.Lemmas.modulo_lemma (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40)) (pow2 264) private let lemma_aux_0 (a:nat) (b:nat) (n:nat) : Lemma
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_aux_0 (a b n: nat) : Lemma (pow2 n * a + pow2 (n + 56) * b = pow2 n * (a % pow2 56) + pow2 (n + 56) * (b + a / pow2 56))
[]
Hacl.Spec.BignumQ.Lemmas.lemma_aux_0
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Prims.nat -> b: Prims.nat -> n: Prims.nat -> FStar.Pervasives.Lemma (ensures Prims.pow2 n * a + Prims.pow2 (n + 56) * b = Prims.pow2 n * (a % Prims.pow2 56) + Prims.pow2 (n + 56) * (b + a / Prims.pow2 56))
{ "end_col": 70, "end_line": 738, "start_col": 4, "start_line": 733 }
FStar.Pervasives.Lemma
val lemma_mod_264': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) )
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_mod_264' a0 a1 a2 a3 a4 = assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); Math.Lemmas.lemma_mod_plus_distr_l (pow2 224 * a4) (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3) (pow2 264); Math.Lemmas.pow2_multiplication_modulo_lemma_2 a4 264 224; lemma_mod_264'' a0 a1 a2 a3 a4; Math.Lemmas.modulo_lemma (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40)) (pow2 264)
val lemma_mod_264': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) ) let lemma_mod_264' a0 a1 a2 a3 a4 =
false
null
true
assert_norm (pow2 56 = 0x100000000000000); assert_norm (pow2 112 = 0x10000000000000000000000000000); assert_norm (pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm (pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); Math.Lemmas.lemma_mod_plus_distr_l (pow2 224 * a4) (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3) (pow2 264); Math.Lemmas.pow2_multiplication_modulo_lemma_2 a4 264 224; lemma_mod_264'' a0 a1 a2 a3 a4; Math.Lemmas.modulo_lemma (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40)) (pow2 264)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Prims.nat", "FStar.Math.Lemmas.modulo_lemma", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Modulus", "Prims.unit", "Hacl.Spec.BignumQ.Lemmas.lemma_mod_264''", "FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2", "FStar.Math.Lemmas.lemma_mod_plus_distr_l", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; } val lemma_div264: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in wide_as_nat5 x / pow2 264 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div264 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow528 x; assert (v x9 < pow2 40); calc (==) { (let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 + pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x5 x5; lemma_div264_x6 x6 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x7 x7; lemma_div264_x8 x8 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x9 x9 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; (==) { lemma_div264_aux x } wide_as_nat5 x / pow2 264; } #pop-options #pop-options // "--z3cliopt smt.arith.nl=false" val lemma_mod_264_aux: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in (wide_as_nat5 t) % pow2 264 == (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264)) #push-options "--z3rlimit 150" let lemma_mod_264_aux t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in assert_norm (pow2 16 * pow2 264 == pow2 280); assert_norm (pow2 72 * pow2 264 == pow2 336); assert_norm (pow2 128 * pow2 264 == pow2 392); assert_norm (pow2 184 * pow2 264 == pow2 448); assert_norm (pow2 240 * pow2 264 == pow2 504); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224 + (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) (pow2 264)} ((v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) + ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.cancel_mul_mod (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; } #pop-options val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264) let lemma_as_nat_pow264 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_mod_264: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in qelem_fits5 res (1, 1, 1, 1, 1) /\ as_nat5 res == (wide_as_nat5 t) % pow2 264)) let lemma_mod_264 t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let t4' = t4 &. u64 0xffffffffff in let res = (t0, t1, t2, t3, t4') in assert_norm (pow2 40 < pow2 64); assert_norm (pow2 40 - 1 == 0xffffffffff); mod_mask_lemma t4 40ul; assert (v (mod_mask #U64 #SEC 40ul) == 0xffffffffff); assert (v (t4 &. u64 0xffffffffff) == v t4 % pow2 40); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { lemma_mod_264_aux t } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168) (v t4 * pow2 224) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 * pow2 224) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v t4) 264 224 } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224) % pow2 264; (==) { lemma_as_nat_pow264 res; FStar.Math.Lemmas.modulo_lemma (as_nat5 res) (pow2 264) } v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224; } val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40)) let lemma_as_nat_pow264_x4 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264) #push-options "--z3rlimit 50" let lemma_sub_mod_264_aux x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 40 * pow2 224 = pow2 264) #pop-options val lemma_sub_mod_264: x:qelem5 -> y:qelem5 -> t:qelem5 -> c5:uint64 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264 /\ as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264 /\ v c5 <= 1 /\ (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y)) (ensures (if as_nat5 x >= as_nat5 y then as_nat5 t == as_nat5 x - as_nat5 y else as_nat5 t == as_nat5 x - as_nat5 y + pow2 264)) #push-options "--z3rlimit 50" let lemma_sub_mod_264 x y t c5 = assert (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y); assert (as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264); if as_nat5 x >= as_nat5 y then assert (v c5 == 0 /\ as_nat5 t == as_nat5 x - as_nat5 y) else assert (v c5 == 1 /\ as_nat5 t == as_nat5 x - as_nat5 y + pow2 264) #pop-options let lemma_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4:nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) = assert ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) by (Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) val lemma_mul_5_low_264: x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma ( (x1 * y1) >= 0 /\ (x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) >= 0 /\ (x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) >= 0 /\ (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) >= 0 /\ ( let a0 = (x1 * y1) % pow2 56 in let a1 = ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) % pow2 56) in let a2 = ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) % pow2 56) in let a3 = ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in let a4 = (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5 + ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) in ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40))) private let lemma_mul_nat_is_nat (a:nat) (b:nat) : Lemma (a*b >= 0) = () private let lemma_div_nat_is_nat (a:nat) (b:pos) : Lemma (a/b >= 0) = () private val lemma_mul_5''': x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma (((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264) let lemma_mul_5''' x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 = calc (==) { ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x % pow2 264)); Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5) + (pow2 16 * x2 * y5 + pow2 16 * x3 * y4 + pow2 72 * x3 * y5 + pow2 16 * x4 * y3 + pow2 72 * x4 * y4 + pow2 128 * x4 * y5 + pow2 16 * x5 * y2 + pow2 72 * x5 * y3 + pow2 128 * x5 * y4 + pow2 184 * x5 * y5) * pow2 264) % pow2 264; (==) { _ by (Tactics.mapply (`eq_eq2); Tactics.mapply (`Math.Lemmas.lemma_mod_plus)) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264; } private val lemma_mod_264'': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) < pow2 264) let lemma_mod_264'' a0 a1 a2 a3 a4 = assert_norm(pow2 40 = 0x10000000000); assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); assert_norm(pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000) private val lemma_mod_264': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) )
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_mod_264': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) )
[]
Hacl.Spec.BignumQ.Lemmas.lemma_mod_264'
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a0: Prims.nat -> a1: Prims.nat -> a2: Prims.nat -> a3: Prims.nat -> a4: Prims.nat -> FStar.Pervasives.Lemma (requires a0 < Hacl.Spec.BignumQ.Definitions.pow56 /\ a1 < Hacl.Spec.BignumQ.Definitions.pow56 /\ a2 < Hacl.Spec.BignumQ.Definitions.pow56 /\ a3 < Hacl.Spec.BignumQ.Definitions.pow56) (ensures (a0 + Prims.pow2 56 * a1 + Prims.pow2 112 * a2 + Prims.pow2 168 * a3 + Prims.pow2 224 * a4) % Prims.pow2 264 = a0 + Prims.pow2 56 * a1 + Prims.pow2 112 * a2 + Prims.pow2 168 * a3 + Prims.pow2 224 * (a4 % Prims.pow2 40))
{ "end_col": 117, "end_line": 729, "start_col": 2, "start_line": 722 }
FStar.Pervasives.Lemma
val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_sub_mod_264_aux x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 40 * pow2 224 = pow2 264)
val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264) let lemma_sub_mod_264_aux x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 =
false
null
true
assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 40 * pow2 224 = pow2 264)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Prims.nat", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Mul.op_Star", "Prims.pow2", "Prims.unit" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; } val lemma_div264: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in wide_as_nat5 x / pow2 264 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div264 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow528 x; assert (v x9 < pow2 40); calc (==) { (let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 + pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x5 x5; lemma_div264_x6 x6 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x7 x7; lemma_div264_x8 x8 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x9 x9 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; (==) { lemma_div264_aux x } wide_as_nat5 x / pow2 264; } #pop-options #pop-options // "--z3cliopt smt.arith.nl=false" val lemma_mod_264_aux: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in (wide_as_nat5 t) % pow2 264 == (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264)) #push-options "--z3rlimit 150" let lemma_mod_264_aux t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in assert_norm (pow2 16 * pow2 264 == pow2 280); assert_norm (pow2 72 * pow2 264 == pow2 336); assert_norm (pow2 128 * pow2 264 == pow2 392); assert_norm (pow2 184 * pow2 264 == pow2 448); assert_norm (pow2 240 * pow2 264 == pow2 504); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224 + (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) (pow2 264)} ((v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) + ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.cancel_mul_mod (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; } #pop-options val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264) let lemma_as_nat_pow264 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_mod_264: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in qelem_fits5 res (1, 1, 1, 1, 1) /\ as_nat5 res == (wide_as_nat5 t) % pow2 264)) let lemma_mod_264 t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let t4' = t4 &. u64 0xffffffffff in let res = (t0, t1, t2, t3, t4') in assert_norm (pow2 40 < pow2 64); assert_norm (pow2 40 - 1 == 0xffffffffff); mod_mask_lemma t4 40ul; assert (v (mod_mask #U64 #SEC 40ul) == 0xffffffffff); assert (v (t4 &. u64 0xffffffffff) == v t4 % pow2 40); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { lemma_mod_264_aux t } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168) (v t4 * pow2 224) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 * pow2 224) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v t4) 264 224 } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224) % pow2 264; (==) { lemma_as_nat_pow264 res; FStar.Math.Lemmas.modulo_lemma (as_nat5 res) (pow2 264) } v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224; } val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40)) let lemma_as_nat_pow264_x4 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264) #push-options "--z3rlimit 50"
false
false
Hacl.Spec.BignumQ.Lemmas.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_sub_mod_264_aux
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x0: Prims.nat -> x1: Prims.nat -> x2: Prims.nat -> x3: Prims.nat -> x4: Prims.nat -> y0: Prims.nat -> y1: Prims.nat -> y2: Prims.nat -> y3: Prims.nat -> y4: Prims.nat -> c1: Prims.nat -> c2: Prims.nat -> c3: Prims.nat -> c4: Prims.nat -> c5: Prims.nat -> FStar.Pervasives.Lemma (ensures x0 - y0 + c1 * Hacl.Spec.BignumQ.Definitions.pow56 + (x1 - y1 - c1 + c2 * Hacl.Spec.BignumQ.Definitions.pow56) * Hacl.Spec.BignumQ.Definitions.pow56 + (x2 - y2 - c2 + c3 * Hacl.Spec.BignumQ.Definitions.pow56) * Hacl.Spec.BignumQ.Definitions.pow112 + (x3 - y3 - c3 + c4 * Hacl.Spec.BignumQ.Definitions.pow56) * Hacl.Spec.BignumQ.Definitions.pow168 + (x4 - y4 - c4 + Prims.pow2 40 * c5) * Hacl.Spec.BignumQ.Definitions.pow224 == x0 + x1 * Prims.pow2 56 + x2 * Prims.pow2 112 + x3 * Prims.pow2 168 + x4 * Prims.pow2 224 - (y0 + y1 * Prims.pow2 56 + y2 * Prims.pow2 112 + y3 * Prims.pow2 168 + y4 * Prims.pow2 224) + c5 * Prims.pow2 264)
{ "end_col": 45, "end_line": 573, "start_col": 2, "start_line": 570 }
FStar.Pervasives.Lemma
val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q))
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q
val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t =
false
null
true
assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then (FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Hacl.Spec.BignumQ.Definitions.qelem5", "FStar.Math.Lemmas.small_mod", "Spec.Ed25519.q", "Prims.unit", "Prims.op_GreaterThanOrEqual", "Hacl.Spec.BignumQ.Definitions.as_nat5", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Math.Lemmas.sub_div_mod_1", "Prims.bool", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Subtraction", "Prims.op_Addition" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q))
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q))
[]
Hacl.Spec.BignumQ.Lemmas.lemma_add_modq5
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Hacl.Spec.BignumQ.Definitions.qelem5 -> y: Hacl.Spec.BignumQ.Definitions.qelem5 -> t: Hacl.Spec.BignumQ.Definitions.qelem5 -> FStar.Pervasives.Lemma (requires Hacl.Spec.BignumQ.Definitions.qelem_fits5 x (1, 1, 1, 1, 1) /\ Hacl.Spec.BignumQ.Definitions.qelem_fits5 y (1, 1, 1, 1, 1) /\ Hacl.Spec.BignumQ.Definitions.qelem_fits5 t (1, 1, 1, 1, 1) /\ Hacl.Spec.BignumQ.Definitions.as_nat5 x < Spec.Ed25519.q /\ Hacl.Spec.BignumQ.Definitions.as_nat5 y < Spec.Ed25519.q /\ Hacl.Spec.BignumQ.Definitions.as_nat5 t == Hacl.Spec.BignumQ.Definitions.as_nat5 x + Hacl.Spec.BignumQ.Definitions.as_nat5 y) (ensures (let res = (match Hacl.Spec.BignumQ.Definitions.as_nat5 t >= Spec.Ed25519.q with | true -> Hacl.Spec.BignumQ.Definitions.as_nat5 t - Spec.Ed25519.q | _ -> Hacl.Spec.BignumQ.Definitions.as_nat5 t) <: Prims.int in res < Spec.Ed25519.q /\ res == (Hacl.Spec.BignumQ.Definitions.as_nat5 x + Hacl.Spec.BignumQ.Definitions.as_nat5 y) % Spec.Ed25519.q))
{ "end_col": 37, "end_line": 298, "start_col": 2, "start_line": 289 }
FStar.Pervasives.Lemma
val lemma_sub_mod_264: x:qelem5 -> y:qelem5 -> t:qelem5 -> c5:uint64 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264 /\ as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264 /\ v c5 <= 1 /\ (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y)) (ensures (if as_nat5 x >= as_nat5 y then as_nat5 t == as_nat5 x - as_nat5 y else as_nat5 t == as_nat5 x - as_nat5 y + pow2 264))
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_sub_mod_264 x y t c5 = assert (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y); assert (as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264); if as_nat5 x >= as_nat5 y then assert (v c5 == 0 /\ as_nat5 t == as_nat5 x - as_nat5 y) else assert (v c5 == 1 /\ as_nat5 t == as_nat5 x - as_nat5 y + pow2 264)
val lemma_sub_mod_264: x:qelem5 -> y:qelem5 -> t:qelem5 -> c5:uint64 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264 /\ as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264 /\ v c5 <= 1 /\ (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y)) (ensures (if as_nat5 x >= as_nat5 y then as_nat5 t == as_nat5 x - as_nat5 y else as_nat5 t == as_nat5 x - as_nat5 y + pow2 264)) let lemma_sub_mod_264 x y t c5 =
false
null
true
assert (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y); assert (as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264); if as_nat5 x >= as_nat5 y then assert (v c5 == 0 /\ as_nat5 t == as_nat5 x - as_nat5 y) else assert (v c5 == 1 /\ as_nat5 t == as_nat5 x - as_nat5 y + pow2 264)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Hacl.Spec.BignumQ.Definitions.qelem5", "Lib.IntTypes.uint64", "Prims.op_GreaterThanOrEqual", "Hacl.Spec.BignumQ.Definitions.as_nat5", "Prims._assert", "Prims.l_and", "Prims.eq2", "Prims.int", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.op_Subtraction", "Prims.bool", "Prims.op_Addition", "Prims.pow2", "Prims.unit", "FStar.Mul.op_Star", "Prims.op_Equality", "Prims.b2t", "Prims.op_LessThan" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; } val lemma_div264: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in wide_as_nat5 x / pow2 264 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div264 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow528 x; assert (v x9 < pow2 40); calc (==) { (let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 + pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x5 x5; lemma_div264_x6 x6 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x7 x7; lemma_div264_x8 x8 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x9 x9 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; (==) { lemma_div264_aux x } wide_as_nat5 x / pow2 264; } #pop-options #pop-options // "--z3cliopt smt.arith.nl=false" val lemma_mod_264_aux: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in (wide_as_nat5 t) % pow2 264 == (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264)) #push-options "--z3rlimit 150" let lemma_mod_264_aux t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in assert_norm (pow2 16 * pow2 264 == pow2 280); assert_norm (pow2 72 * pow2 264 == pow2 336); assert_norm (pow2 128 * pow2 264 == pow2 392); assert_norm (pow2 184 * pow2 264 == pow2 448); assert_norm (pow2 240 * pow2 264 == pow2 504); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224 + (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) (pow2 264)} ((v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) + ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.cancel_mul_mod (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; } #pop-options val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264) let lemma_as_nat_pow264 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_mod_264: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in qelem_fits5 res (1, 1, 1, 1, 1) /\ as_nat5 res == (wide_as_nat5 t) % pow2 264)) let lemma_mod_264 t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let t4' = t4 &. u64 0xffffffffff in let res = (t0, t1, t2, t3, t4') in assert_norm (pow2 40 < pow2 64); assert_norm (pow2 40 - 1 == 0xffffffffff); mod_mask_lemma t4 40ul; assert (v (mod_mask #U64 #SEC 40ul) == 0xffffffffff); assert (v (t4 &. u64 0xffffffffff) == v t4 % pow2 40); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { lemma_mod_264_aux t } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168) (v t4 * pow2 224) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 * pow2 224) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v t4) 264 224 } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224) % pow2 264; (==) { lemma_as_nat_pow264 res; FStar.Math.Lemmas.modulo_lemma (as_nat5 res) (pow2 264) } v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224; } val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40)) let lemma_as_nat_pow264_x4 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264) #push-options "--z3rlimit 50" let lemma_sub_mod_264_aux x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 40 * pow2 224 = pow2 264) #pop-options val lemma_sub_mod_264: x:qelem5 -> y:qelem5 -> t:qelem5 -> c5:uint64 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264 /\ as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264 /\ v c5 <= 1 /\ (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y)) (ensures (if as_nat5 x >= as_nat5 y then as_nat5 t == as_nat5 x - as_nat5 y else as_nat5 t == as_nat5 x - as_nat5 y + pow2 264)) #push-options "--z3rlimit 50"
false
false
Hacl.Spec.BignumQ.Lemmas.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_sub_mod_264: x:qelem5 -> y:qelem5 -> t:qelem5 -> c5:uint64 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264 /\ as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264 /\ v c5 <= 1 /\ (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y)) (ensures (if as_nat5 x >= as_nat5 y then as_nat5 t == as_nat5 x - as_nat5 y else as_nat5 t == as_nat5 x - as_nat5 y + pow2 264))
[]
Hacl.Spec.BignumQ.Lemmas.lemma_sub_mod_264
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Hacl.Spec.BignumQ.Definitions.qelem5 -> y: Hacl.Spec.BignumQ.Definitions.qelem5 -> t: Hacl.Spec.BignumQ.Definitions.qelem5 -> c5: Lib.IntTypes.uint64 -> FStar.Pervasives.Lemma (requires Hacl.Spec.BignumQ.Definitions.qelem_fits5 x (1, 1, 1, 1, 1) /\ Hacl.Spec.BignumQ.Definitions.qelem_fits5 y (1, 1, 1, 1, 1) /\ Hacl.Spec.BignumQ.Definitions.qelem_fits5 t (1, 1, 1, 1, 1) /\ Hacl.Spec.BignumQ.Definitions.as_nat5 x < Prims.pow2 264 /\ Hacl.Spec.BignumQ.Definitions.as_nat5 y < Prims.pow2 264 /\ Hacl.Spec.BignumQ.Definitions.as_nat5 t == Hacl.Spec.BignumQ.Definitions.as_nat5 x - Hacl.Spec.BignumQ.Definitions.as_nat5 y + Lib.IntTypes.v c5 * Prims.pow2 264 /\ Lib.IntTypes.v c5 <= 1 /\ (match Lib.IntTypes.v c5 = 0 with | true -> Hacl.Spec.BignumQ.Definitions.as_nat5 x >= Hacl.Spec.BignumQ.Definitions.as_nat5 y | _ -> Hacl.Spec.BignumQ.Definitions.as_nat5 x < Hacl.Spec.BignumQ.Definitions.as_nat5 y)) (ensures ((match Hacl.Spec.BignumQ.Definitions.as_nat5 x >= Hacl.Spec.BignumQ.Definitions.as_nat5 y with | true -> Hacl.Spec.BignumQ.Definitions.as_nat5 t == Hacl.Spec.BignumQ.Definitions.as_nat5 x - Hacl.Spec.BignumQ.Definitions.as_nat5 y | _ -> Hacl.Spec.BignumQ.Definitions.as_nat5 t == Hacl.Spec.BignumQ.Definitions.as_nat5 x - Hacl.Spec.BignumQ.Definitions.as_nat5 y + Prims.pow2 264) <: Type0))
{ "end_col": 71, "end_line": 602, "start_col": 2, "start_line": 597 }
FStar.Pervasives.Lemma
val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24))
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24)
val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x =
false
null
true
let x0, x1, x2, x3, x4, x5, x6, x7, x8, x9 = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Hacl.Spec.BignumQ.Definitions.qelem_wide5", "Lib.IntTypes.uint64", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.unit", "Prims._assert", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Math.Lemmas.pow2_minus", "Prims.op_Equality", "Prims.int", "FStar.Mul.op_Star" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24))
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24))
[]
Hacl.Spec.BignumQ.Lemmas.lemma_wide_as_nat_pow512
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Hacl.Spec.BignumQ.Definitions.qelem_wide5 -> FStar.Pervasives.Lemma (requires Hacl.Spec.BignumQ.Definitions.qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ Hacl.Spec.BignumQ.Definitions.wide_as_nat5 x < Prims.pow2 512) (ensures (let _ = x in (let FStar.Pervasives.Native.Mktuple10 #_ #_ #_ #_ #_ #_ #_ #_ #_ #_ _ _ _ _ _ _ _ _ _ x9 = _ in Lib.IntTypes.v x9 < Prims.pow2 24) <: Type0))
{ "end_col": 32, "end_line": 221, "start_col": 32, "start_line": 216 }
FStar.Pervasives.Lemma
val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40))
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40)
val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x =
false
null
true
let x0, x1, x2, x3, x4, x5, x6, x7, x8, x9 = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Hacl.Spec.BignumQ.Definitions.qelem_wide5", "Lib.IntTypes.uint64", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.unit", "Prims._assert", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.Math.Lemmas.pow2_minus", "Prims.op_Equality", "Prims.int", "FStar.Mul.op_Star" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40))
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40))
[]
Hacl.Spec.BignumQ.Lemmas.lemma_wide_as_nat_pow528
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Hacl.Spec.BignumQ.Definitions.qelem_wide5 -> FStar.Pervasives.Lemma (requires Hacl.Spec.BignumQ.Definitions.qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ Hacl.Spec.BignumQ.Definitions.wide_as_nat5 x < Prims.pow2 528) (ensures (let _ = x in (let FStar.Pervasives.Native.Mktuple10 #_ #_ #_ #_ #_ #_ #_ #_ #_ #_ _ _ _ _ _ _ _ _ _ x9 = _ in Lib.IntTypes.v x9 < Prims.pow2 40) <: Type0))
{ "end_col": 33, "end_line": 315, "start_col": 32, "start_line": 310 }
FStar.Pervasives.Lemma
val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; }
val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 =
false
null
true
assert_norm (0 < pow2 24); calc ( == ) { pow2 16 * (v x5 % pow2 40) + (v x5 / pow2 40) * pow2 56; ( == ) { FStar.Tactics.Effect.synth_by_tactic (fun _ -> (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ())) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; ( == ) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; }
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Lib.IntTypes.uint64", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Modulus", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.op_Division", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Tactics.CanonCommSemiring.semiring_reflect", "FStar.Tactics.CanonCommSemiring.int_cr", "FStar.Pervasives.Native.Mktuple2", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.nat", "FStar.Pervasives.Native.snd", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.sec_int_v", "FStar.Reflection.V2.Data.var", "FStar.Tactics.CanonCommSemiring.Pplus", "FStar.Tactics.CanonCommSemiring.Pmult", "FStar.Tactics.CanonCommSemiring.Pvar", "Prims.squash", "FStar.Math.Lemmas.euclidean_division_definition", "FStar.Pervasives.assert_norm", "Prims.op_LessThan" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16)
false
false
Hacl.Spec.BignumQ.Lemmas.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_div264_x5
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x5: Lib.IntTypes.uint64 -> FStar.Pervasives.Lemma (ensures Prims.pow2 16 * (Lib.IntTypes.v x5 % Prims.pow2 40) + (Lib.IntTypes.v x5 / Prims.pow2 40) * Prims.pow2 56 == Lib.IntTypes.v x5 * Prims.pow2 16)
{ "end_col": 3, "end_line": 361, "start_col": 2, "start_line": 354 }
FStar.Pervasives.Lemma
val lemma_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4: nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4:nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) = assert ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) by (Tactics.norm [zeta; iota; delta; primops]; int_semiring ())
val lemma_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4: nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) let lemma_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4: nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) =
false
null
true
FStar.Tactics.Effect.assert_by_tactic ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) (fun _ -> (); (Tactics.norm [zeta; iota; delta; primops]; int_semiring ()))
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Prims.nat", "FStar.Tactics.Effect.assert_by_tactic", "Prims.eq2", "Prims.int", "FStar.Mul.op_Star", "Prims.op_Addition", "Prims.pow2", "Hacl.Spec.BignumQ.Definitions.pow56", "Hacl.Spec.BignumQ.Definitions.pow112", "Hacl.Spec.BignumQ.Definitions.pow168", "Hacl.Spec.BignumQ.Definitions.pow224", "Hacl.Spec.BignumQ.Definitions.pow280", "Hacl.Spec.BignumQ.Definitions.pow336", "Hacl.Spec.BignumQ.Definitions.pow392", "Hacl.Spec.BignumQ.Definitions.pow448", "Prims.unit", "FStar.Tactics.CanonCommSemiring.int_semiring", "FStar.Tactics.V1.Builtins.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.zeta", "FStar.Pervasives.iota", "FStar.Pervasives.delta", "FStar.Pervasives.primops", "Prims.Nil", "Prims.l_True", "Prims.squash", "FStar.Pervasives.pattern" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; } val lemma_div264: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in wide_as_nat5 x / pow2 264 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div264 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow528 x; assert (v x9 < pow2 40); calc (==) { (let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 + pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x5 x5; lemma_div264_x6 x6 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x7 x7; lemma_div264_x8 x8 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x9 x9 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; (==) { lemma_div264_aux x } wide_as_nat5 x / pow2 264; } #pop-options #pop-options // "--z3cliopt smt.arith.nl=false" val lemma_mod_264_aux: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in (wide_as_nat5 t) % pow2 264 == (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264)) #push-options "--z3rlimit 150" let lemma_mod_264_aux t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in assert_norm (pow2 16 * pow2 264 == pow2 280); assert_norm (pow2 72 * pow2 264 == pow2 336); assert_norm (pow2 128 * pow2 264 == pow2 392); assert_norm (pow2 184 * pow2 264 == pow2 448); assert_norm (pow2 240 * pow2 264 == pow2 504); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224 + (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) (pow2 264)} ((v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) + ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.cancel_mul_mod (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; } #pop-options val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264) let lemma_as_nat_pow264 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_mod_264: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in qelem_fits5 res (1, 1, 1, 1, 1) /\ as_nat5 res == (wide_as_nat5 t) % pow2 264)) let lemma_mod_264 t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let t4' = t4 &. u64 0xffffffffff in let res = (t0, t1, t2, t3, t4') in assert_norm (pow2 40 < pow2 64); assert_norm (pow2 40 - 1 == 0xffffffffff); mod_mask_lemma t4 40ul; assert (v (mod_mask #U64 #SEC 40ul) == 0xffffffffff); assert (v (t4 &. u64 0xffffffffff) == v t4 % pow2 40); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { lemma_mod_264_aux t } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168) (v t4 * pow2 224) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 * pow2 224) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v t4) 264 224 } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224) % pow2 264; (==) { lemma_as_nat_pow264 res; FStar.Math.Lemmas.modulo_lemma (as_nat5 res) (pow2 264) } v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224; } val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40)) let lemma_as_nat_pow264_x4 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264) #push-options "--z3rlimit 50" let lemma_sub_mod_264_aux x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 40 * pow2 224 = pow2 264) #pop-options val lemma_sub_mod_264: x:qelem5 -> y:qelem5 -> t:qelem5 -> c5:uint64 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264 /\ as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264 /\ v c5 <= 1 /\ (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y)) (ensures (if as_nat5 x >= as_nat5 y then as_nat5 t == as_nat5 x - as_nat5 y else as_nat5 t == as_nat5 x - as_nat5 y + pow2 264)) #push-options "--z3rlimit 50" let lemma_sub_mod_264 x y t c5 = assert (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y); assert (as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264); if as_nat5 x >= as_nat5 y then assert (v c5 == 0 /\ as_nat5 t == as_nat5 x - as_nat5 y) else assert (v c5 == 1 /\ as_nat5 t == as_nat5 x - as_nat5 y + pow2 264) #pop-options let lemma_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4:nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448)
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4: nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_mul_qelem5
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x0: Prims.nat -> x1: Prims.nat -> x2: Prims.nat -> x3: Prims.nat -> x4: Prims.nat -> y0: Prims.nat -> y1: Prims.nat -> y2: Prims.nat -> y3: Prims.nat -> y4: Prims.nat -> FStar.Pervasives.Lemma (ensures (x0 + x1 * Prims.pow2 56 + x2 * Prims.pow2 112 + x3 * Prims.pow2 168 + x4 * Prims.pow2 224) * (y0 + y1 * Prims.pow2 56 + y2 * Prims.pow2 112 + y3 * Prims.pow2 168 + y4 * Prims.pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * Hacl.Spec.BignumQ.Definitions.pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * Hacl.Spec.BignumQ.Definitions.pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * Hacl.Spec.BignumQ.Definitions.pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * Hacl.Spec.BignumQ.Definitions.pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * Hacl.Spec.BignumQ.Definitions.pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * Hacl.Spec.BignumQ.Definitions.pow336 + (x3 * y4 + x4 * y3) * Hacl.Spec.BignumQ.Definitions.pow392 + (x4 * y4) * Hacl.Spec.BignumQ.Definitions.pow448)
{ "end_col": 65, "end_line": 629, "start_col": 2, "start_line": 618 }
FStar.Pervasives.Lemma
val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; }
val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 =
false
null
true
calc ( == ) { (pow2 32 * (v x6 % pow2 24)) * pow2 56 + (v x6 / pow2 24) * pow2 112; ( == ) { FStar.Tactics.Effect.synth_by_tactic (fun _ -> (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ())) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; ( == ) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; }
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Lib.IntTypes.uint64", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Modulus", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.op_Division", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Tactics.CanonCommSemiring.semiring_reflect", "FStar.Tactics.CanonCommSemiring.int_cr", "FStar.Pervasives.Native.Mktuple2", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.nat", "FStar.Pervasives.Native.snd", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.sec_int_v", "FStar.Reflection.V2.Data.var", "FStar.Tactics.CanonCommSemiring.Pplus", "FStar.Tactics.CanonCommSemiring.Pmult", "FStar.Tactics.CanonCommSemiring.Pvar", "Prims.squash", "FStar.Math.Lemmas.euclidean_division_definition" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88)
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_div248_x6
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x6: Lib.IntTypes.uint64 -> FStar.Pervasives.Lemma (ensures (Prims.pow2 32 * (Lib.IntTypes.v x6 % Prims.pow2 24)) * Prims.pow2 56 + (Lib.IntTypes.v x6 / Prims.pow2 24) * Prims.pow2 112 == Lib.IntTypes.v x6 * Prims.pow2 88)
{ "end_col": 3, "end_line": 168, "start_col": 2, "start_line": 162 }
FStar.Pervasives.Lemma
val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; }
val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 =
false
null
true
calc ( == ) { (pow2 16 * (v x6 % pow2 40)) * pow2 56 + (v x6 / pow2 40) * pow2 112; ( == ) { FStar.Tactics.Effect.synth_by_tactic (fun _ -> (Tactics.norm [delta; primops]; int_semiring ())) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; ( == ) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; }
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Lib.IntTypes.uint64", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Modulus", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.op_Division", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Tactics.CanonCommSemiring.semiring_reflect", "FStar.Tactics.CanonCommSemiring.int_cr", "FStar.Pervasives.Native.Mktuple2", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.nat", "FStar.Pervasives.Native.snd", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.sec_int_v", "FStar.Reflection.V2.Data.var", "FStar.Tactics.CanonCommSemiring.Pplus", "FStar.Tactics.CanonCommSemiring.Pmult", "FStar.Tactics.CanonCommSemiring.Pvar", "Prims.op_Multiply", "Prims.l_and", "Prims.bool", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Lib.IntTypes.bits", "Prims.squash", "FStar.Math.Lemmas.euclidean_division_definition" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72)
false
false
Hacl.Spec.BignumQ.Lemmas.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_div264_x6
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x6: Lib.IntTypes.uint64 -> FStar.Pervasives.Lemma (ensures (Prims.pow2 16 * (Lib.IntTypes.v x6 % Prims.pow2 40)) * Prims.pow2 56 + (Lib.IntTypes.v x6 / Prims.pow2 40) * Prims.pow2 112 == Lib.IntTypes.v x6 * Prims.pow2 72)
{ "end_col": 3, "end_line": 373, "start_col": 2, "start_line": 367 }
FStar.Pervasives.Lemma
val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; }
val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 =
false
null
true
calc ( == ) { (pow2 32 * (v x7 % pow2 24)) * pow2 112 + (v x7 / pow2 24) * pow2 168; ( == ) { FStar.Tactics.Effect.synth_by_tactic (fun _ -> (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ())) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; ( == ) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; }
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Lib.IntTypes.uint64", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Modulus", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.op_Division", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Tactics.CanonCommSemiring.semiring_reflect", "FStar.Tactics.CanonCommSemiring.int_cr", "FStar.Pervasives.Native.Mktuple2", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.nat", "FStar.Pervasives.Native.snd", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.sec_int_v", "FStar.Reflection.V2.Data.var", "FStar.Tactics.CanonCommSemiring.Pplus", "FStar.Tactics.CanonCommSemiring.Pmult", "FStar.Tactics.CanonCommSemiring.Pvar", "Prims.squash", "FStar.Math.Lemmas.euclidean_division_definition" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144)
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_div248_x7
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x7: Lib.IntTypes.uint64 -> FStar.Pervasives.Lemma (ensures (Prims.pow2 32 * (Lib.IntTypes.v x7 % Prims.pow2 24)) * Prims.pow2 112 + (Lib.IntTypes.v x7 / Prims.pow2 24) * Prims.pow2 168 == Lib.IntTypes.v x7 * Prims.pow2 144)
{ "end_col": 3, "end_line": 180, "start_col": 2, "start_line": 174 }
FStar.Pervasives.Lemma
val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; }
val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 =
false
null
true
calc ( == ) { (pow2 16 * (v x7 % pow2 40)) * pow2 112 + (v x7 / pow2 40) * pow2 168; ( == ) { FStar.Tactics.Effect.synth_by_tactic (fun _ -> (Tactics.norm [delta; primops]; int_semiring ())) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; ( == ) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; }
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Lib.IntTypes.uint64", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Modulus", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.op_Division", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Tactics.CanonCommSemiring.semiring_reflect", "FStar.Tactics.CanonCommSemiring.int_cr", "FStar.Pervasives.Native.Mktuple2", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.nat", "FStar.Pervasives.Native.snd", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.sec_int_v", "FStar.Reflection.V2.Data.var", "FStar.Tactics.CanonCommSemiring.Pplus", "FStar.Tactics.CanonCommSemiring.Pmult", "FStar.Tactics.CanonCommSemiring.Pvar", "Prims.op_Multiply", "Prims.l_and", "Prims.bool", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Lib.IntTypes.bits", "Prims.squash", "FStar.Math.Lemmas.euclidean_division_definition" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128)
false
false
Hacl.Spec.BignumQ.Lemmas.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_div264_x7
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x7: Lib.IntTypes.uint64 -> FStar.Pervasives.Lemma (ensures (Prims.pow2 16 * (Lib.IntTypes.v x7 % Prims.pow2 40)) * Prims.pow2 112 + (Lib.IntTypes.v x7 / Prims.pow2 40) * Prims.pow2 168 == Lib.IntTypes.v x7 * Prims.pow2 128)
{ "end_col": 3, "end_line": 385, "start_col": 2, "start_line": 379 }
FStar.Pervasives.Lemma
val lemma_optimized_barrett_reduce2: a:nat{a < pow2 512} -> Lemma (a - ((a * (pow2 512 / S.q)) / pow2 512) * S.q < pow2 264 /\ a - ((a * (pow2 512 / S.q)) / pow2 512) * S.q >= 0)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_optimized_barrett_reduce2 a = assert_norm (pow2 248 = 0x100000000000000000000000000000000000000000000000000000000000000); assert_norm (pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000); assert_norm (S.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); assert_norm (0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 == pow2 512)
val lemma_optimized_barrett_reduce2: a:nat{a < pow2 512} -> Lemma (a - ((a * (pow2 512 / S.q)) / pow2 512) * S.q < pow2 264 /\ a - ((a * (pow2 512 / S.q)) / pow2 512) * S.q >= 0) let lemma_optimized_barrett_reduce2 a =
false
null
true
assert_norm (pow2 248 = 0x100000000000000000000000000000000000000000000000000000000000000); assert_norm (pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000); assert_norm (S.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); assert_norm (0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 == pow2 512)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.unit", "Spec.Ed25519.q", "Prims.op_Equality" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; } val lemma_div264: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in wide_as_nat5 x / pow2 264 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div264 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow528 x; assert (v x9 < pow2 40); calc (==) { (let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 + pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x5 x5; lemma_div264_x6 x6 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x7 x7; lemma_div264_x8 x8 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x9 x9 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; (==) { lemma_div264_aux x } wide_as_nat5 x / pow2 264; } #pop-options #pop-options // "--z3cliopt smt.arith.nl=false" val lemma_mod_264_aux: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in (wide_as_nat5 t) % pow2 264 == (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264)) #push-options "--z3rlimit 150" let lemma_mod_264_aux t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in assert_norm (pow2 16 * pow2 264 == pow2 280); assert_norm (pow2 72 * pow2 264 == pow2 336); assert_norm (pow2 128 * pow2 264 == pow2 392); assert_norm (pow2 184 * pow2 264 == pow2 448); assert_norm (pow2 240 * pow2 264 == pow2 504); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224 + (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) (pow2 264)} ((v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) + ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.cancel_mul_mod (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; } #pop-options val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264) let lemma_as_nat_pow264 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_mod_264: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in qelem_fits5 res (1, 1, 1, 1, 1) /\ as_nat5 res == (wide_as_nat5 t) % pow2 264)) let lemma_mod_264 t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let t4' = t4 &. u64 0xffffffffff in let res = (t0, t1, t2, t3, t4') in assert_norm (pow2 40 < pow2 64); assert_norm (pow2 40 - 1 == 0xffffffffff); mod_mask_lemma t4 40ul; assert (v (mod_mask #U64 #SEC 40ul) == 0xffffffffff); assert (v (t4 &. u64 0xffffffffff) == v t4 % pow2 40); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { lemma_mod_264_aux t } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168) (v t4 * pow2 224) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 * pow2 224) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v t4) 264 224 } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224) % pow2 264; (==) { lemma_as_nat_pow264 res; FStar.Math.Lemmas.modulo_lemma (as_nat5 res) (pow2 264) } v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224; } val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40)) let lemma_as_nat_pow264_x4 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264) #push-options "--z3rlimit 50" let lemma_sub_mod_264_aux x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 40 * pow2 224 = pow2 264) #pop-options val lemma_sub_mod_264: x:qelem5 -> y:qelem5 -> t:qelem5 -> c5:uint64 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264 /\ as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264 /\ v c5 <= 1 /\ (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y)) (ensures (if as_nat5 x >= as_nat5 y then as_nat5 t == as_nat5 x - as_nat5 y else as_nat5 t == as_nat5 x - as_nat5 y + pow2 264)) #push-options "--z3rlimit 50" let lemma_sub_mod_264 x y t c5 = assert (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y); assert (as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264); if as_nat5 x >= as_nat5 y then assert (v c5 == 0 /\ as_nat5 t == as_nat5 x - as_nat5 y) else assert (v c5 == 1 /\ as_nat5 t == as_nat5 x - as_nat5 y + pow2 264) #pop-options let lemma_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4:nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) = assert ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) by (Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) val lemma_mul_5_low_264: x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma ( (x1 * y1) >= 0 /\ (x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) >= 0 /\ (x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) >= 0 /\ (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) >= 0 /\ ( let a0 = (x1 * y1) % pow2 56 in let a1 = ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) % pow2 56) in let a2 = ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) % pow2 56) in let a3 = ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in let a4 = (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5 + ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) in ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40))) private let lemma_mul_nat_is_nat (a:nat) (b:nat) : Lemma (a*b >= 0) = () private let lemma_div_nat_is_nat (a:nat) (b:pos) : Lemma (a/b >= 0) = () private val lemma_mul_5''': x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma (((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264) let lemma_mul_5''' x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 = calc (==) { ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x % pow2 264)); Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5) + (pow2 16 * x2 * y5 + pow2 16 * x3 * y4 + pow2 72 * x3 * y5 + pow2 16 * x4 * y3 + pow2 72 * x4 * y4 + pow2 128 * x4 * y5 + pow2 16 * x5 * y2 + pow2 72 * x5 * y3 + pow2 128 * x5 * y4 + pow2 184 * x5 * y5) * pow2 264) % pow2 264; (==) { _ by (Tactics.mapply (`eq_eq2); Tactics.mapply (`Math.Lemmas.lemma_mod_plus)) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264; } private val lemma_mod_264'': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) < pow2 264) let lemma_mod_264'' a0 a1 a2 a3 a4 = assert_norm(pow2 40 = 0x10000000000); assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); assert_norm(pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000) private val lemma_mod_264': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) ) let lemma_mod_264' a0 a1 a2 a3 a4 = assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); Math.Lemmas.lemma_mod_plus_distr_l (pow2 224 * a4) (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3) (pow2 264); Math.Lemmas.pow2_multiplication_modulo_lemma_2 a4 264 224; lemma_mod_264'' a0 a1 a2 a3 a4; Math.Lemmas.modulo_lemma (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40)) (pow2 264) private let lemma_aux_0 (a:nat) (b:nat) (n:nat) : Lemma (pow2 n * a + pow2 (n+56) * b = pow2 n * (a % pow2 56) + pow2 (n+56) * (b + a / pow2 56)) = Math.Lemmas.lemma_div_mod a (pow2 56); Math.Lemmas.pow2_plus n 56; assert(a = pow2 56 * (a / pow2 56) + (a % pow2 56)); Math.Lemmas.distributivity_add_right (pow2 n) (pow2 56 * (a / pow2 56)) (a % pow2 56); Math.Lemmas.paren_mul_right (pow2 n) (pow2 56) (a / pow2 56); Math.Lemmas.distributivity_add_right (pow2 (n+56)) b (a / pow2 56) private val lemma_mod_264_small: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ( (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * (a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56))) (* These silly lemmas needed to guide the proof below... *) private let aux_nat_over_pos (p : nat) (q : pos) : Lemma (p / q >= 0) = () private let aux_nat_plus_nat (p : nat) (q : nat) : Lemma (p + q >= 0) = () let lemma_mod_264_small a0 a1 a2 a3 a4 = Math.Lemmas.lemma_div_mod a0 (pow2 56); Math.Lemmas.distributivity_add_right (pow2 56) a1 (a0 / pow2 56); (**) aux_nat_over_pos a0 (pow2 56); (**) aux_nat_plus_nat a1 (a0 / pow2 56); let a1':nat = (a1 + (a0 / pow2 56)) in (**) aux_nat_over_pos a1' (pow2 56); (**) aux_nat_plus_nat a2 (a1' / pow2 56); let a2':nat = (a2 + (a1' / pow2 56)) in (**) aux_nat_over_pos a2' (pow2 56); (**) aux_nat_plus_nat a3 (a2' / pow2 56); let a3':nat = (a3 + (a2' / pow2 56)) in lemma_aux_0 a1' a2 56; lemma_aux_0 a2' a3 112; lemma_aux_0 a3' a4 168 private val lemma_mod_264_: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ((a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * ((a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 40)) let lemma_mod_264_ a0 a1 a2 a3 a4 = lemma_mod_264_small a0 a1 a2 a3 a4; let x0 = a0 % pow2 56 in assert (x0 < pow56); let x1 = ((a1 + (a0 / pow2 56)) % pow2 56) in assert (x1 < pow56); let x2 = ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) in assert (x2 < pow56); let x3 = ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in assert (x3 < pow56); lemma_mod_264' x0 x1 x2 x3 (a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) #push-options "--z3rlimit 50" let lemma_mul_5_low_264 x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 = lemma_div_nat_is_nat (x1 * y1) (pow2 56); lemma_div_nat_is_nat (x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) (pow2 56); lemma_div_nat_is_nat (x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) (pow2 56); lemma_div_nat_is_nat (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) (pow2 56); lemma_mul_5''' x1 x2 x3 x4 x5 y1 y2 y3 y4 y5; lemma_mod_264_ (x1 * y1) (x2 * y1 + x1 * y2) (x3 * y1 + x2 * y2 + x1 * y3) (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5) #pop-options private val lemma_optimized_barrett_reduce: a:nat{a < pow2 512} -> Lemma (a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q < 2 * S.q /\ a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q >= 0) #push-options "--z3rlimit 50" let lemma_optimized_barrett_reduce a = assert_norm (pow2 248 = 0x100000000000000000000000000000000000000000000000000000000000000); assert_norm (pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000); assert_norm (S.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); assert_norm (0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 == pow2 512) #pop-options private val lemma_optimized_barrett_reduce2: a:nat{a < pow2 512} -> Lemma (a - ((a * (pow2 512 / S.q)) / pow2 512) * S.q < pow2 264 /\ a - ((a * (pow2 512 / S.q)) / pow2 512) * S.q >= 0) #push-options "--z3rlimit 50"
false
false
Hacl.Spec.BignumQ.Lemmas.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_optimized_barrett_reduce2: a:nat{a < pow2 512} -> Lemma (a - ((a * (pow2 512 / S.q)) / pow2 512) * S.q < pow2 264 /\ a - ((a * (pow2 512 / S.q)) / pow2 512) * S.q >= 0)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_optimized_barrett_reduce2
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Prims.nat{a < Prims.pow2 512} -> FStar.Pervasives.Lemma (ensures a - (a * (Prims.pow2 512 / Spec.Ed25519.q) / Prims.pow2 512) * Spec.Ed25519.q < Prims.pow2 264 /\ a - (a * (Prims.pow2 512 / Spec.Ed25519.q) / Prims.pow2 512) * Spec.Ed25519.q >= 0)
{ "end_col": 159, "end_line": 827, "start_col": 2, "start_line": 824 }
FStar.Pervasives.Lemma
val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; }
val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 =
false
null
true
calc ( == ) { (pow2 16 * (v x9 % pow2 40)) * pow2 224; ( == ) { Math.Lemmas.small_mod (v x9) (pow2 40) } (pow2 16 * v x9) * pow2 224; ( == ) { FStar.Tactics.Effect.synth_by_tactic (fun _ -> (Tactics.norm [delta; primops]; int_semiring ())) } v x9 * pow2 240; }
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Lib.IntTypes.uint64", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.pow2", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "FStar.Mul.op_Star", "Prims.op_Modulus", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.small_mod", "Prims.squash", "FStar.Tactics.CanonCommSemiring.semiring_reflect", "FStar.Tactics.CanonCommSemiring.int_cr", "FStar.Pervasives.Native.Mktuple2", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.nat", "FStar.Pervasives.Native.snd", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.sec_int_v", "FStar.Reflection.V2.Data.var", "FStar.Tactics.CanonCommSemiring.Pmult", "FStar.Tactics.CanonCommSemiring.Pvar", "Prims.op_Multiply", "Prims.l_and", "Prims.bool", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Lib.IntTypes.bits" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240)
false
false
Hacl.Spec.BignumQ.Lemmas.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_div264_x9
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x9: Lib.IntTypes.uint64{Lib.IntTypes.v x9 < Prims.pow2 40} -> FStar.Pervasives.Lemma (ensures (Prims.pow2 16 * (Lib.IntTypes.v x9 % Prims.pow2 40)) * Prims.pow2 224 == Lib.IntTypes.v x9 * Prims.pow2 240)
{ "end_col": 3, "end_line": 408, "start_col": 2, "start_line": 402 }
FStar.Pervasives.Lemma
val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; }
val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 =
false
null
true
calc ( == ) { (pow2 32 * (v x9 % pow2 24)) * pow2 224; ( == ) { Math.Lemmas.small_mod (v x9) (pow2 24) } (pow2 32 * v x9) * pow2 224; ( == ) { FStar.Tactics.Effect.synth_by_tactic (fun _ -> (Tactics.norm [delta; primops]; int_semiring ())) } v x9 * pow2 256; }
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Lib.IntTypes.uint64", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.pow2", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "FStar.Mul.op_Star", "Prims.op_Modulus", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.small_mod", "Prims.squash", "FStar.Tactics.CanonCommSemiring.semiring_reflect", "FStar.Tactics.CanonCommSemiring.int_cr", "FStar.Pervasives.Native.Mktuple2", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.nat", "FStar.Pervasives.Native.snd", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.sec_int_v", "FStar.Reflection.V2.Data.var", "FStar.Tactics.CanonCommSemiring.Pmult", "FStar.Tactics.CanonCommSemiring.Pvar", "Prims.op_Multiply", "Prims.l_and", "Prims.bool", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Lib.IntTypes.bits" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256)
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_div248_x9
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x9: Lib.IntTypes.uint64{Lib.IntTypes.v x9 < Prims.pow2 24} -> FStar.Pervasives.Lemma (ensures (Prims.pow2 32 * (Lib.IntTypes.v x9 % Prims.pow2 24)) * Prims.pow2 224 == Lib.IntTypes.v x9 * Prims.pow2 256)
{ "end_col": 3, "end_line": 204, "start_col": 2, "start_line": 198 }
FStar.Pervasives.Lemma
val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; }
val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 =
false
null
true
calc ( == ) { (pow2 32 * (v x8 % pow2 24)) * pow2 168 + (v x8 / pow2 24) * pow2 224; ( == ) { FStar.Tactics.Effect.synth_by_tactic (fun _ -> (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ())) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; ( == ) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; }
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Lib.IntTypes.uint64", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Modulus", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.op_Division", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Tactics.CanonCommSemiring.semiring_reflect", "FStar.Tactics.CanonCommSemiring.int_cr", "FStar.Pervasives.Native.Mktuple2", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.nat", "FStar.Pervasives.Native.snd", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.sec_int_v", "FStar.Reflection.V2.Data.var", "FStar.Tactics.CanonCommSemiring.Pplus", "FStar.Tactics.CanonCommSemiring.Pmult", "FStar.Tactics.CanonCommSemiring.Pvar", "Prims.squash", "FStar.Math.Lemmas.euclidean_division_definition" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200)
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_div248_x8
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x8: Lib.IntTypes.uint64 -> FStar.Pervasives.Lemma (ensures (Prims.pow2 32 * (Lib.IntTypes.v x8 % Prims.pow2 24)) * Prims.pow2 168 + (Lib.IntTypes.v x8 / Prims.pow2 24) * Prims.pow2 224 == Lib.IntTypes.v x8 * Prims.pow2 200)
{ "end_col": 3, "end_line": 192, "start_col": 2, "start_line": 186 }
FStar.Pervasives.Lemma
val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; }
val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 =
false
null
true
calc ( == ) { (pow2 16 * (v x8 % pow2 40)) * pow2 168 + (v x8 / pow2 40) * pow2 224; ( == ) { FStar.Tactics.Effect.synth_by_tactic (fun _ -> (Tactics.norm [delta; primops]; int_semiring ())) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; ( == ) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; }
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Lib.IntTypes.uint64", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Modulus", "Lib.IntTypes.v", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Prims.op_Division", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Tactics.CanonCommSemiring.semiring_reflect", "FStar.Tactics.CanonCommSemiring.int_cr", "FStar.Pervasives.Native.Mktuple2", "Prims.list", "FStar.Pervasives.Native.tuple2", "Prims.nat", "FStar.Pervasives.Native.snd", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Lib.IntTypes.sec_int_v", "FStar.Reflection.V2.Data.var", "FStar.Tactics.CanonCommSemiring.Pplus", "FStar.Tactics.CanonCommSemiring.Pmult", "FStar.Tactics.CanonCommSemiring.Pvar", "Prims.op_Multiply", "Prims.l_and", "Prims.bool", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Lib.IntTypes.bits", "Prims.squash", "FStar.Math.Lemmas.euclidean_division_definition" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184)
false
false
Hacl.Spec.BignumQ.Lemmas.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_div264_x8
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x8: Lib.IntTypes.uint64 -> FStar.Pervasives.Lemma (ensures (Prims.pow2 16 * (Lib.IntTypes.v x8 % Prims.pow2 40)) * Prims.pow2 168 + (Lib.IntTypes.v x8 / Prims.pow2 40) * Prims.pow2 224 == Lib.IntTypes.v x8 * Prims.pow2 184)
{ "end_col": 3, "end_line": 397, "start_col": 2, "start_line": 391 }
FStar.Pervasives.Lemma
val lemma_barrett_reduce'' (u z x q: nat) : Lemma (requires u < 2 * S.q /\ u = x - q * S.q /\ z == (if u < S.q then u else u - S.q)) (ensures z == x % S.q)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_barrett_reduce'' (u:nat) (z:nat) (x:nat) (q:nat) : Lemma (requires u < 2 * S.q /\ u = x - q * S.q /\ z == (if u < S.q then u else u - S.q)) (ensures z == x % S.q) = if u >= S.q then ( calc (==) { z; (==) { Math.Lemmas.small_mod z S.q } (u - S.q) % S.q; (==) { } (x - (q * S.q + S.q)) % S.q; (==) { Math.Lemmas.distributivity_add_left q 1 S.q; assert_norm (1 * S.q == S.q) } (x - (q + 1) * S.q) % S.q; (==) { Math.Lemmas.lemma_mod_sub x S.q (q+1) } x % S.q; } ) else ( calc (==) { z; (==) { Math.Lemmas.small_mod z S.q } u % S.q; (==) { } (x - (q * S.q)) % S.q; (==) { Math.Lemmas.lemma_mod_sub x S.q q } x % S.q; } )
val lemma_barrett_reduce'' (u z x q: nat) : Lemma (requires u < 2 * S.q /\ u = x - q * S.q /\ z == (if u < S.q then u else u - S.q)) (ensures z == x % S.q) let lemma_barrett_reduce'' (u z x q: nat) : Lemma (requires u < 2 * S.q /\ u = x - q * S.q /\ z == (if u < S.q then u else u - S.q)) (ensures z == x % S.q) =
false
null
true
if u >= S.q then (calc ( == ) { z; ( == ) { Math.Lemmas.small_mod z S.q } (u - S.q) % S.q; ( == ) { () } (x - (q * S.q + S.q)) % S.q; ( == ) { (Math.Lemmas.distributivity_add_left q 1 S.q; assert_norm (1 * S.q == S.q)) } (x - (q + 1) * S.q) % S.q; ( == ) { Math.Lemmas.lemma_mod_sub x S.q (q + 1) } x % S.q; }) else (calc ( == ) { z; ( == ) { Math.Lemmas.small_mod z S.q } u % S.q; ( == ) { () } (x - (q * S.q)) % S.q; ( == ) { Math.Lemmas.lemma_mod_sub x S.q q } x % S.q; })
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Prims.nat", "Prims.op_GreaterThanOrEqual", "Spec.Ed25519.q", "FStar.Calc.calc_finish", "Prims.eq2", "Prims.op_Modulus", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Prims.op_Subtraction", "FStar.Mul.op_Star", "Prims.op_Addition", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.small_mod", "Prims.squash", "FStar.Pervasives.assert_norm", "Prims.int", "FStar.Math.Lemmas.distributivity_add_left", "FStar.Math.Lemmas.lemma_mod_sub", "Prims.bool", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Equality", "FStar.Pervasives.pattern" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; } val lemma_div264: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in wide_as_nat5 x / pow2 264 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div264 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow528 x; assert (v x9 < pow2 40); calc (==) { (let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 + pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x5 x5; lemma_div264_x6 x6 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x7 x7; lemma_div264_x8 x8 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x9 x9 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; (==) { lemma_div264_aux x } wide_as_nat5 x / pow2 264; } #pop-options #pop-options // "--z3cliopt smt.arith.nl=false" val lemma_mod_264_aux: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in (wide_as_nat5 t) % pow2 264 == (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264)) #push-options "--z3rlimit 150" let lemma_mod_264_aux t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in assert_norm (pow2 16 * pow2 264 == pow2 280); assert_norm (pow2 72 * pow2 264 == pow2 336); assert_norm (pow2 128 * pow2 264 == pow2 392); assert_norm (pow2 184 * pow2 264 == pow2 448); assert_norm (pow2 240 * pow2 264 == pow2 504); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224 + (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) (pow2 264)} ((v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) + ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.cancel_mul_mod (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; } #pop-options val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264) let lemma_as_nat_pow264 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_mod_264: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in qelem_fits5 res (1, 1, 1, 1, 1) /\ as_nat5 res == (wide_as_nat5 t) % pow2 264)) let lemma_mod_264 t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let t4' = t4 &. u64 0xffffffffff in let res = (t0, t1, t2, t3, t4') in assert_norm (pow2 40 < pow2 64); assert_norm (pow2 40 - 1 == 0xffffffffff); mod_mask_lemma t4 40ul; assert (v (mod_mask #U64 #SEC 40ul) == 0xffffffffff); assert (v (t4 &. u64 0xffffffffff) == v t4 % pow2 40); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { lemma_mod_264_aux t } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168) (v t4 * pow2 224) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 * pow2 224) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v t4) 264 224 } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224) % pow2 264; (==) { lemma_as_nat_pow264 res; FStar.Math.Lemmas.modulo_lemma (as_nat5 res) (pow2 264) } v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224; } val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40)) let lemma_as_nat_pow264_x4 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264) #push-options "--z3rlimit 50" let lemma_sub_mod_264_aux x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 40 * pow2 224 = pow2 264) #pop-options val lemma_sub_mod_264: x:qelem5 -> y:qelem5 -> t:qelem5 -> c5:uint64 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264 /\ as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264 /\ v c5 <= 1 /\ (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y)) (ensures (if as_nat5 x >= as_nat5 y then as_nat5 t == as_nat5 x - as_nat5 y else as_nat5 t == as_nat5 x - as_nat5 y + pow2 264)) #push-options "--z3rlimit 50" let lemma_sub_mod_264 x y t c5 = assert (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y); assert (as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264); if as_nat5 x >= as_nat5 y then assert (v c5 == 0 /\ as_nat5 t == as_nat5 x - as_nat5 y) else assert (v c5 == 1 /\ as_nat5 t == as_nat5 x - as_nat5 y + pow2 264) #pop-options let lemma_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4:nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) = assert ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) by (Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) val lemma_mul_5_low_264: x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma ( (x1 * y1) >= 0 /\ (x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) >= 0 /\ (x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) >= 0 /\ (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) >= 0 /\ ( let a0 = (x1 * y1) % pow2 56 in let a1 = ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) % pow2 56) in let a2 = ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) % pow2 56) in let a3 = ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in let a4 = (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5 + ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) in ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40))) private let lemma_mul_nat_is_nat (a:nat) (b:nat) : Lemma (a*b >= 0) = () private let lemma_div_nat_is_nat (a:nat) (b:pos) : Lemma (a/b >= 0) = () private val lemma_mul_5''': x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma (((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264) let lemma_mul_5''' x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 = calc (==) { ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x % pow2 264)); Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5) + (pow2 16 * x2 * y5 + pow2 16 * x3 * y4 + pow2 72 * x3 * y5 + pow2 16 * x4 * y3 + pow2 72 * x4 * y4 + pow2 128 * x4 * y5 + pow2 16 * x5 * y2 + pow2 72 * x5 * y3 + pow2 128 * x5 * y4 + pow2 184 * x5 * y5) * pow2 264) % pow2 264; (==) { _ by (Tactics.mapply (`eq_eq2); Tactics.mapply (`Math.Lemmas.lemma_mod_plus)) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264; } private val lemma_mod_264'': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) < pow2 264) let lemma_mod_264'' a0 a1 a2 a3 a4 = assert_norm(pow2 40 = 0x10000000000); assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); assert_norm(pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000) private val lemma_mod_264': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) ) let lemma_mod_264' a0 a1 a2 a3 a4 = assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); Math.Lemmas.lemma_mod_plus_distr_l (pow2 224 * a4) (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3) (pow2 264); Math.Lemmas.pow2_multiplication_modulo_lemma_2 a4 264 224; lemma_mod_264'' a0 a1 a2 a3 a4; Math.Lemmas.modulo_lemma (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40)) (pow2 264) private let lemma_aux_0 (a:nat) (b:nat) (n:nat) : Lemma (pow2 n * a + pow2 (n+56) * b = pow2 n * (a % pow2 56) + pow2 (n+56) * (b + a / pow2 56)) = Math.Lemmas.lemma_div_mod a (pow2 56); Math.Lemmas.pow2_plus n 56; assert(a = pow2 56 * (a / pow2 56) + (a % pow2 56)); Math.Lemmas.distributivity_add_right (pow2 n) (pow2 56 * (a / pow2 56)) (a % pow2 56); Math.Lemmas.paren_mul_right (pow2 n) (pow2 56) (a / pow2 56); Math.Lemmas.distributivity_add_right (pow2 (n+56)) b (a / pow2 56) private val lemma_mod_264_small: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ( (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * (a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56))) (* These silly lemmas needed to guide the proof below... *) private let aux_nat_over_pos (p : nat) (q : pos) : Lemma (p / q >= 0) = () private let aux_nat_plus_nat (p : nat) (q : nat) : Lemma (p + q >= 0) = () let lemma_mod_264_small a0 a1 a2 a3 a4 = Math.Lemmas.lemma_div_mod a0 (pow2 56); Math.Lemmas.distributivity_add_right (pow2 56) a1 (a0 / pow2 56); (**) aux_nat_over_pos a0 (pow2 56); (**) aux_nat_plus_nat a1 (a0 / pow2 56); let a1':nat = (a1 + (a0 / pow2 56)) in (**) aux_nat_over_pos a1' (pow2 56); (**) aux_nat_plus_nat a2 (a1' / pow2 56); let a2':nat = (a2 + (a1' / pow2 56)) in (**) aux_nat_over_pos a2' (pow2 56); (**) aux_nat_plus_nat a3 (a2' / pow2 56); let a3':nat = (a3 + (a2' / pow2 56)) in lemma_aux_0 a1' a2 56; lemma_aux_0 a2' a3 112; lemma_aux_0 a3' a4 168 private val lemma_mod_264_: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ((a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * ((a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 40)) let lemma_mod_264_ a0 a1 a2 a3 a4 = lemma_mod_264_small a0 a1 a2 a3 a4; let x0 = a0 % pow2 56 in assert (x0 < pow56); let x1 = ((a1 + (a0 / pow2 56)) % pow2 56) in assert (x1 < pow56); let x2 = ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) in assert (x2 < pow56); let x3 = ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in assert (x3 < pow56); lemma_mod_264' x0 x1 x2 x3 (a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) #push-options "--z3rlimit 50" let lemma_mul_5_low_264 x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 = lemma_div_nat_is_nat (x1 * y1) (pow2 56); lemma_div_nat_is_nat (x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) (pow2 56); lemma_div_nat_is_nat (x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) (pow2 56); lemma_div_nat_is_nat (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) (pow2 56); lemma_mul_5''' x1 x2 x3 x4 x5 y1 y2 y3 y4 y5; lemma_mod_264_ (x1 * y1) (x2 * y1 + x1 * y2) (x3 * y1 + x2 * y2 + x1 * y3) (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5) #pop-options private val lemma_optimized_barrett_reduce: a:nat{a < pow2 512} -> Lemma (a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q < 2 * S.q /\ a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q >= 0) #push-options "--z3rlimit 50" let lemma_optimized_barrett_reduce a = assert_norm (pow2 248 = 0x100000000000000000000000000000000000000000000000000000000000000); assert_norm (pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000); assert_norm (S.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); assert_norm (0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 == pow2 512) #pop-options private val lemma_optimized_barrett_reduce2: a:nat{a < pow2 512} -> Lemma (a - ((a * (pow2 512 / S.q)) / pow2 512) * S.q < pow2 264 /\ a - ((a * (pow2 512 / S.q)) / pow2 512) * S.q >= 0) #push-options "--z3rlimit 50" let lemma_optimized_barrett_reduce2 a = assert_norm (pow2 248 = 0x100000000000000000000000000000000000000000000000000000000000000); assert_norm (pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000); assert_norm (S.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); assert_norm (0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 == pow2 512) #pop-options #push-options "--fuel 0 --z3cliopt smt.arith.nl=true --smtencoding.elim_box true --smtencoding.l_arith_repr native --smtencoding.nl_arith_repr native --z3rlimit 30" private let lemma_0 (x:nat) (y:nat) (c:pos) : Lemma (requires (x >= y /\ x - y < c)) (ensures (x / c - y / c <= 1)) = if x / c - y / c > 1 then ( Math.Lemmas.lemma_div_mod x c; Math.Lemmas.lemma_div_mod y c; Math.Lemmas.distributivity_sub_right c (x / c) (y / c); Math.Lemmas.lemma_div_mod (x-y) c; Math.Lemmas.small_div (x-y) c; Math.Lemmas.swap_mul c (x/c - y/c); Math.Lemmas.cancel_mul_div (x/c - y/c) c ) #pop-options #push-options "--z3rlimit 30" private let lemma_1 (x:nat) (y:nat) (c:pos) : Lemma (requires (x - y < c /\ x >= y)) (ensures (x - y = (if (x % c) - (y % c) < 0 then c + (x % c) - (y % c) else (x % c) - (y % c)))) = Math.Lemmas.lemma_div_mod x c; Math.Lemmas.lemma_div_mod y c; Math.Lemmas.distributivity_sub_right c (y/c) (x/c); assert( (x%c) - (y%c) = x - y - c*((x/c) - (y/c))); lemma_0 x y c #pop-options val lemma_barrett_reduce': x:nat{x < pow2 512} -> Lemma (let r = x % pow2 264 in let qml = (((((x / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q) % pow2 264) in let u = if r < qml then pow2 264 + r - qml else r - qml in let z = if u < S.q then u else u - S.q in z = x % S.q) let lemma_barrett_reduce'' (u:nat) (z:nat) (x:nat) (q:nat) : Lemma (requires u < 2 * S.q /\ u = x - q * S.q /\ z == (if u < S.q then u else u - S.q)) (ensures z == x % S.q)
false
false
Hacl.Spec.BignumQ.Lemmas.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 lemma_barrett_reduce'' (u z x q: nat) : Lemma (requires u < 2 * S.q /\ u = x - q * S.q /\ z == (if u < S.q then u else u - S.q)) (ensures z == x % S.q)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_barrett_reduce''
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
u147: Prims.nat -> z: Prims.nat -> x: Prims.nat -> q: Prims.nat -> FStar.Pervasives.Lemma (requires u147 < 2 * Spec.Ed25519.q /\ u147 = x - q * Spec.Ed25519.q /\ z == (match u147 < Spec.Ed25519.q with | true -> u147 | _ -> u147 - Spec.Ed25519.q)) (ensures z == x % Spec.Ed25519.q)
{ "end_col": 3, "end_line": 893, "start_col": 2, "start_line": 871 }
FStar.Pervasives.Lemma
val lemma_optimized_barrett_reduce: a:nat{a < pow2 512} -> Lemma (a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q < 2 * S.q /\ a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q >= 0)
[ { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_optimized_barrett_reduce a = assert_norm (pow2 248 = 0x100000000000000000000000000000000000000000000000000000000000000); assert_norm (pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000); assert_norm (S.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); assert_norm (0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 == pow2 512)
val lemma_optimized_barrett_reduce: a:nat{a < pow2 512} -> Lemma (a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q < 2 * S.q /\ a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q >= 0) let lemma_optimized_barrett_reduce a =
false
null
true
assert_norm (pow2 248 = 0x100000000000000000000000000000000000000000000000000000000000000); assert_norm (pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000); assert_norm (S.q == 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed); assert_norm (0x100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 == pow2 512)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.unit", "Spec.Ed25519.q", "Prims.op_Equality" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50" let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) #pop-options val lemma_div224: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 224 == v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280)) #push-options "--z3rlimit 50" let lemma_div224 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert (wide_as_nat5 x == v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + v x4 * pow2 224 + v x5 * pow2 280 + v x6 * pow2 336 + v x7 * pow2 392 + v x8 * pow2 448 + v x9 * pow2 504); assert_norm (pow2 56 * pow2 224 == pow2 280); assert_norm (pow2 112 * pow2 224 == pow2 336); assert_norm (pow2 168 * pow2 224 == pow2 392); assert_norm (pow2 224 * pow2 224 == pow2 448); assert_norm (pow2 280 * pow2 224 == pow2 504); calc (==) { wide_as_nat5 x / pow2 224; (==) { } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168 + (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) * pow2 224) / pow2 224; (==) { FStar.Math.Lemmas.lemma_div_plus (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) (pow2 224) } (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) / pow2 224 + v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; (==) { FStar.Math.Lemmas.small_division_lemma_1 (v x0 + v x1 * pow2 56 + v x2 * pow2 112 + v x3 * pow2 168) (pow2 224) } v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280; } #pop-options val lemma_div248_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 248 == v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256)) open FStar.Tactics.CanonCommSemiring #push-options "--z3cliopt smt.arith.nl=false" let lemma_div248_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 248 == pow2 224 * pow2 24); assert_norm (pow2 56 == pow2 32 * pow2 24); assert_norm (pow2 112 == pow2 88 * pow2 24); assert_norm (pow2 168 == pow2 144 * pow2 24); assert_norm (pow2 224 == pow2 200 * pow2 24); assert_norm (pow2 280 == pow2 256 * pow2 24); assert_norm (0 < pow2 24); calc (==) { wide_as_nat5 x / pow2 248; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 24) } (wide_as_nat5 x / pow2 224) / pow2 24; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 24; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 24)); int_semiring ()) } (v x4 + (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) * pow2 24) / pow2 24; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256) (pow2 24) } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; } #pop-options val lemma_div248_x5: x5:uint64 -> Lemma ( pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 == v x5 * pow2 32) let lemma_div248_x5 x5 = assert_norm (pow2 32 * pow2 24 = pow2 56) val lemma_div248_x6: x6:uint64 -> Lemma (pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 == v x6 * pow2 88) let lemma_div248_x6 x6 = calc (==) { pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x6 / pow2 24) * pow2 24 + v x6 % pow2 24) * pow2 88; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x6) (pow2 24) } v x6 * pow2 88; } val lemma_div248_x7: x7:uint64 -> Lemma (pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 == v x7 * pow2 144) let lemma_div248_x7 x7 = calc (==) { pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x7 / pow2 24) * pow2 24 + v x7 % pow2 24) * pow2 144; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x7) (pow2 24) } v x7 * pow2 144; } val lemma_div248_x8: x8:uint64 -> Lemma (pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 == v x8 * pow2 200) let lemma_div248_x8 x8 = calc (==) { pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x8 / pow2 24) * pow2 24 + v x8 % pow2 24) * pow2 200; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x8) (pow2 24) } v x8 * pow2 200; } val lemma_div248_x9: x9:uint64{v x9 < pow2 24} -> Lemma (pow2 32 * (v x9 % pow2 24) * pow2 224 == v x9 * pow2 256) let lemma_div248_x9 x9 = calc (==) { pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 24) } pow2 32 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 256; } val lemma_wide_as_nat_pow512: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 24)) let lemma_wide_as_nat_pow512 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 8 = pow2 512); FStar.Math.Lemmas.pow2_minus 512 504; assert (v x9 < pow2 8); assert_norm (pow2 8 < pow2 24) val lemma_div248: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 512) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in wide_as_nat5 x / pow2 248 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div248 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow512 x; assert (v x9 < pow2 24); calc (==) { (let z0 = v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) in let z1 = v x5 / pow2 24 + pow2 32 * (v x6 % pow2 24) in let z2 = v x6 / pow2 24 + pow2 32 * (v x7 % pow2 24) in let z3 = v x7 / pow2 24 + pow2 32 * (v x8 % pow2 24) in let z4 = v x8 / pow2 24 + pow2 32 * (v x9 % pow2 24) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 24 + pow2 32 * (v x5 % pow2 24) + v x5 / pow2 24 * pow2 56 + pow2 32 * (v x6 % pow2 24) * pow2 56 + v x6 / pow2 24 * pow2 112 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x5 x5; lemma_div248_x6 x6 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + pow2 32 * (v x7 % pow2 24) * pow2 112 + v x7 / pow2 24 * pow2 168 + pow2 32 * (v x8 % pow2 24) * pow2 168 + v x8 / pow2 24 * pow2 224 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x7 x7; lemma_div248_x8 x8 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + pow2 32 * (v x9 % pow2 24) * pow2 224; (==) { lemma_div248_x9 x9 } v x4 / pow2 24 + v x5 * pow2 32 + v x6 * pow2 88 + v x7 * pow2 144 + v x8 * pow2 200 + v x9 * pow2 256; (==) { lemma_div248_aux x } wide_as_nat5 x / pow2 248; } #pop-options val lemma_add_modq5: x:qelem5 -> y:qelem5 -> t:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < S.q /\ as_nat5 y < S.q /\ as_nat5 t == as_nat5 x + as_nat5 y) (ensures (let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in res < S.q /\ res == (as_nat5 x + as_nat5 y) % S.q)) let lemma_add_modq5 x y t = assert (as_nat5 t == as_nat5 x + as_nat5 y); let res = if as_nat5 t >= S.q then as_nat5 t - S.q else as_nat5 t in assert (res < S.q); if as_nat5 t >= S.q then ( FStar.Math.Lemmas.sub_div_mod_1 (as_nat5 t) S.q; assert (res % S.q == as_nat5 t % S.q)) else assert (res % S.q == as_nat5 t % S.q); FStar.Math.Lemmas.small_mod res S.q val lemma_wide_as_nat_pow528: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in v x9 < pow2 40)) let lemma_wide_as_nat_pow528 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 504 * pow2 24 = pow2 528); FStar.Math.Lemmas.pow2_minus 528 504; assert (v x9 < pow2 24); assert_norm (pow2 24 < pow2 40) #push-options "--z3cliopt smt.arith.nl=false" val lemma_div264_aux: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in wide_as_nat5 x / pow2 264 == v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240)) let lemma_div264_aux x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in assert_norm (pow2 264 == pow2 224 * pow2 40); assert_norm (pow2 56 == pow2 16 * pow2 40); assert_norm (pow2 112 == pow2 72 * pow2 40); assert_norm (pow2 168 == pow2 128 * pow2 40); assert_norm (pow2 224 == pow2 184 * pow2 40); assert_norm (pow2 280 == pow2 240 * pow2 40); assert_norm (0 < pow2 40); calc (==) { wide_as_nat5 x / pow2 264; (==) { FStar.Math.Lemmas.division_multiplication_lemma (wide_as_nat5 x) (pow2 224) (pow2 40) } (wide_as_nat5 x / pow2 224) / pow2 40; (==) { lemma_div224 x } (v x4 + v x5 * pow2 56 + v x6 * pow2 112 + v x7 * pow2 168 + v x8 * pow2 224 + v x9 * pow2 280) / pow2 40; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x / pow2 40)); int_semiring ()) } (v x4 + (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) * pow2 40) / pow2 40; (==) { FStar.Math.Lemmas.lemma_div_plus (v x4) (v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240) (pow2 40) } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; } val lemma_div264_x5: x5:uint64 -> Lemma (pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 == v x5 * pow2 16) let lemma_div264_x5 x5 = assert_norm (0 < pow2 24); calc (==) { pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56; (==) { _ by (Tactics.norm [delta_only [`%pow2]; primops]; int_semiring ()) } ((v x5 / pow2 40) * pow2 40 + v x5 % pow2 40) * pow2 16; (==) { FStar.Math.Lemmas.euclidean_division_definition (v x5) (pow2 40) } v x5 * pow2 16; } val lemma_div264_x6: x6:uint64 -> Lemma (pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 == v x6 * pow2 72) let lemma_div264_x6 x6 = calc (==) { pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x6 / pow2 40) * pow2 40 + v x6 % pow2 40) * pow2 72; (==) { Math.Lemmas.euclidean_division_definition (v x6) (pow2 40) } v x6 * pow2 72; } val lemma_div264_x7: x7:uint64 -> Lemma (pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 == v x7 * pow2 128) let lemma_div264_x7 x7 = calc (==) { pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x7 / pow2 40) * pow2 40 + v x7 % pow2 40) * pow2 128; (==) { Math.Lemmas.euclidean_division_definition (v x7) (pow2 40) } v x7 * pow2 128; } val lemma_div264_x8: x8:uint64 -> Lemma (pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 == v x8 * pow2 184) let lemma_div264_x8 x8 = calc (==) { pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } ((v x8 / pow2 40) * pow2 40 + v x8 % pow2 40) * pow2 184; (==) { Math.Lemmas.euclidean_division_definition (v x8) (pow2 40) } v x8 * pow2 184; } val lemma_div264_x9: x9:uint64{v x9 < pow2 40} -> Lemma (pow2 16 * (v x9 % pow2 40) * pow2 224 == v x9 * pow2 240) let lemma_div264_x9 x9 = calc (==) { pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { Math.Lemmas.small_mod (v x9) (pow2 40) } pow2 16 * v x9 * pow2 224; (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x9 * pow2 240; } val lemma_div264: x:qelem_wide5 -> Lemma (requires qelem_wide_fits5 x (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) /\ wide_as_nat5 x < pow2 528) (ensures (let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in wide_as_nat5 x / pow2 264 == z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224)) #push-options "--z3rlimit 50" let lemma_div264 x = let (x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) = x in lemma_wide_as_nat_pow528 x; assert (v x9 < pow2 40); calc (==) { (let z0 = v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) in let z1 = v x5 / pow2 40 + pow2 16 * (v x6 % pow2 40) in let z2 = v x6 / pow2 40 + pow2 16 * (v x7 % pow2 40) in let z3 = v x7 / pow2 40 + pow2 16 * (v x8 % pow2 40) in let z4 = v x8 / pow2 40 + pow2 16 * (v x9 % pow2 40) in z0 + z1 * pow2 56 + z2 * pow2 112 + z3 * pow2 168 + z4 * pow2 224); (==) { _ by (Tactics.norm [delta; primops]; int_semiring ()) } v x4 / pow2 40 + pow2 16 * (v x5 % pow2 40) + v x5 / pow2 40 * pow2 56 + pow2 16 * (v x6 % pow2 40) * pow2 56 + v x6 / pow2 40 * pow2 112 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x5 x5; lemma_div264_x6 x6 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + pow2 16 * (v x7 % pow2 40) * pow2 112 + v x7 / pow2 40 * pow2 168 + pow2 16 * (v x8 % pow2 40) * pow2 168 + v x8 / pow2 40 * pow2 224 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x7 x7; lemma_div264_x8 x8 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + pow2 16 * (v x9 % pow2 40) * pow2 224; (==) { lemma_div264_x9 x9 } v x4 / pow2 40 + v x5 * pow2 16 + v x6 * pow2 72 + v x7 * pow2 128 + v x8 * pow2 184 + v x9 * pow2 240; (==) { lemma_div264_aux x } wide_as_nat5 x / pow2 264; } #pop-options #pop-options // "--z3cliopt smt.arith.nl=false" val lemma_mod_264_aux: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in (wide_as_nat5 t) % pow2 264 == (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264)) #push-options "--z3rlimit 150" let lemma_mod_264_aux t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in assert_norm (pow2 16 * pow2 264 == pow2 280); assert_norm (pow2 72 * pow2 264 == pow2 336); assert_norm (pow2 128 * pow2 264 == pow2 392); assert_norm (pow2 184 * pow2 264 == pow2 448); assert_norm (pow2 240 * pow2 264 == pow2 504); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224 + (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) (pow2 264)} ((v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) + ((v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) * pow2 264) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.cancel_mul_mod (v t5 * pow2 16 + v t6 * pow2 72 + v t7 * pow2 128 + v t8 * pow2 184 + v t9 * pow2 240) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; } #pop-options val lemma_as_nat_pow264: x:qelem5 -> Lemma (requires (let (x0, x1, x2, x3, x4) = x in qelem_fits5 x (1, 1, 1, 1, 1) /\ v x4 < pow2 40)) (ensures as_nat5 x < pow2 264) let lemma_as_nat_pow264 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_mod_264: t:qelem_wide5 -> Lemma (requires qelem_wide_fits5 t (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)) (ensures (let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let res = (t0, t1, t2, t3, t4 &. u64 0xffffffffff) in qelem_fits5 res (1, 1, 1, 1, 1) /\ as_nat5 res == (wide_as_nat5 t) % pow2 264)) let lemma_mod_264 t = let (t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) = t in let t4' = t4 &. u64 0xffffffffff in let res = (t0, t1, t2, t3, t4') in assert_norm (pow2 40 < pow2 64); assert_norm (pow2 40 - 1 == 0xffffffffff); mod_mask_lemma t4 40ul; assert (v (mod_mask #U64 #SEC 40ul) == 0xffffffffff); assert (v (t4 &. u64 0xffffffffff) == v t4 % pow2 40); calc (==) { (wide_as_nat5 t) % pow2 264; (==) { lemma_mod_264_aux t } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + v t4 * pow2 224) % pow2 264; (==) { FStar.Math.Lemmas.lemma_mod_add_distr (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168) (v t4 * pow2 224) (pow2 264) } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 * pow2 224) % pow2 264) % pow2 264; (==) { FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v t4) 264 224 } (v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224) % pow2 264; (==) { lemma_as_nat_pow264 res; FStar.Math.Lemmas.modulo_lemma (as_nat5 res) (pow2 264) } v t0 + v t1 * pow2 56 + v t2 * pow2 112 + v t3 * pow2 168 + (v t4 % pow2 40) * pow2 224; } val lemma_as_nat_pow264_x4: x:qelem5 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264) (ensures (let (x0, x1, x2, x3, x4) = x in v x4 < pow2 40)) let lemma_as_nat_pow264_x4 x = let (x0, x1, x2, x3, x4) = x in assert_norm (pow2 40 * pow2 224 = pow2 264) val lemma_sub_mod_264_aux: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> c1:nat -> c2:nat -> c3:nat -> c4:nat -> c5:nat -> Lemma ( x0 - y0 + c1 * pow56 + (x1 - y1 - c1 + c2 * pow56) * pow56 + (x2 - y2 - c2 + c3 * pow56) * pow112 + (x3 - y3 - c3 + c4 * pow56) * pow168 + (x4 - y4 - c4 + pow2 40 * c5) * pow224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + c5 * pow2 264) #push-options "--z3rlimit 50" let lemma_sub_mod_264_aux x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 40 * pow2 224 = pow2 264) #pop-options val lemma_sub_mod_264: x:qelem5 -> y:qelem5 -> t:qelem5 -> c5:uint64 -> Lemma (requires qelem_fits5 x (1, 1, 1, 1, 1) /\ qelem_fits5 y (1, 1, 1, 1, 1) /\ qelem_fits5 t (1, 1, 1, 1, 1) /\ as_nat5 x < pow2 264 /\ as_nat5 y < pow2 264 /\ as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264 /\ v c5 <= 1 /\ (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y)) (ensures (if as_nat5 x >= as_nat5 y then as_nat5 t == as_nat5 x - as_nat5 y else as_nat5 t == as_nat5 x - as_nat5 y + pow2 264)) #push-options "--z3rlimit 50" let lemma_sub_mod_264 x y t c5 = assert (if v c5 = 0 then as_nat5 x >= as_nat5 y else as_nat5 x < as_nat5 y); assert (as_nat5 t == as_nat5 x - as_nat5 y + v c5 * pow2 264); if as_nat5 x >= as_nat5 y then assert (v c5 == 0 /\ as_nat5 t == as_nat5 x - as_nat5 y) else assert (v c5 == 1 /\ as_nat5 t == as_nat5 x - as_nat5 y + pow2 264) #pop-options let lemma_mul_qelem5 (x0 x1 x2 x3 x4 y0 y1 y2 y3 y4:nat) : Lemma ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) = assert ((x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) * (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) == x0 * y0 + (x0 * y1 + x1 * y0) * pow56 + (x0 * y2 + x1 * y1 + x2 * y0) * pow112 + (x0 * y3 + x1 * y2 + x2 * y1 + x3 * y0) * pow168 + (x0 * y4 + x1 * y3 + x2 * y2 + x3 * y1 + x4 * y0) * pow224 + (x1 * y4 + x2 * y3 + x3 * y2 + x4 * y1) * pow280 + (x2 * y4 + x3 * y3 + x4 * y2) * pow336 + (x3 * y4 + x4 * y3) * pow392 + (x4 * y4) * pow448) by (Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) val lemma_mul_5_low_264: x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma ( (x1 * y1) >= 0 /\ (x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) >= 0 /\ (x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) >= 0 /\ (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) >= 0 /\ ( let a0 = (x1 * y1) % pow2 56 in let a1 = ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) % pow2 56) in let a2 = ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) % pow2 56) in let a3 = ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in let a4 = (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5 + ((x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) in ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40))) private let lemma_mul_nat_is_nat (a:nat) (b:nat) : Lemma (a*b >= 0) = () private let lemma_div_nat_is_nat (a:nat) (b:pos) : Lemma (a/b >= 0) = () private val lemma_mul_5''': x1:nat -> x2:nat -> x3:nat -> x4:nat -> x5:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> y5:nat -> Lemma (((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264 == (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264) let lemma_mul_5''' x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 = calc (==) { ((x1 + pow2 56 * x2 + pow2 112 * x3 + pow2 168 * x4 + pow2 224 * x5) * (y1 + pow2 56 * y2 + pow2 112 * y3 + pow2 168 * y4 + pow2 224 * y5)) % pow2 264; (==) { _ by (Tactics.mapply (`feq #int #int (fun x -> x % pow2 264)); Tactics.norm [zeta; iota; delta; primops]; int_semiring ()) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5) + (pow2 16 * x2 * y5 + pow2 16 * x3 * y4 + pow2 72 * x3 * y5 + pow2 16 * x4 * y3 + pow2 72 * x4 * y4 + pow2 128 * x4 * y5 + pow2 16 * x5 * y2 + pow2 72 * x5 * y3 + pow2 128 * x5 * y4 + pow2 184 * x5 * y5) * pow2 264) % pow2 264; (==) { _ by (Tactics.mapply (`eq_eq2); Tactics.mapply (`Math.Lemmas.lemma_mod_plus)) } (x1 * y1 + pow2 56 * (x2 * y1 + x1 * y2) + pow2 112 * (x3 * y1 + x2 * y2 + x1 * y3) + pow2 168 * (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) + pow2 224 * (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5)) % pow2 264; } private val lemma_mod_264'': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) < pow2 264) let lemma_mod_264'' a0 a1 a2 a3 a4 = assert_norm(pow2 40 = 0x10000000000); assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); assert_norm(pow2 264 = 0x1000000000000000000000000000000000000000000000000000000000000000000) private val lemma_mod_264': a0:nat -> a1:nat-> a2:nat -> a3:nat -> a4:nat -> Lemma (requires a0 < pow56 /\ a1 < pow56 /\ a2 < pow56 /\ a3 < pow56) (ensures (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40) ) let lemma_mod_264' a0 a1 a2 a3 a4 = assert_norm(pow2 56 = 0x100000000000000); assert_norm(pow2 112 = 0x10000000000000000000000000000); assert_norm(pow2 168 = 0x1000000000000000000000000000000000000000000); assert_norm(pow2 224 = 0x100000000000000000000000000000000000000000000000000000000); Math.Lemmas.lemma_mod_plus_distr_l (pow2 224 * a4) (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3) (pow2 264); Math.Lemmas.pow2_multiplication_modulo_lemma_2 a4 264 224; lemma_mod_264'' a0 a1 a2 a3 a4; Math.Lemmas.modulo_lemma (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * (a4 % pow2 40)) (pow2 264) private let lemma_aux_0 (a:nat) (b:nat) (n:nat) : Lemma (pow2 n * a + pow2 (n+56) * b = pow2 n * (a % pow2 56) + pow2 (n+56) * (b + a / pow2 56)) = Math.Lemmas.lemma_div_mod a (pow2 56); Math.Lemmas.pow2_plus n 56; assert(a = pow2 56 * (a / pow2 56) + (a % pow2 56)); Math.Lemmas.distributivity_add_right (pow2 n) (pow2 56 * (a / pow2 56)) (a % pow2 56); Math.Lemmas.paren_mul_right (pow2 n) (pow2 56) (a / pow2 56); Math.Lemmas.distributivity_add_right (pow2 (n+56)) b (a / pow2 56) private val lemma_mod_264_small: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ( (a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * (a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56))) (* These silly lemmas needed to guide the proof below... *) private let aux_nat_over_pos (p : nat) (q : pos) : Lemma (p / q >= 0) = () private let aux_nat_plus_nat (p : nat) (q : nat) : Lemma (p + q >= 0) = () let lemma_mod_264_small a0 a1 a2 a3 a4 = Math.Lemmas.lemma_div_mod a0 (pow2 56); Math.Lemmas.distributivity_add_right (pow2 56) a1 (a0 / pow2 56); (**) aux_nat_over_pos a0 (pow2 56); (**) aux_nat_plus_nat a1 (a0 / pow2 56); let a1':nat = (a1 + (a0 / pow2 56)) in (**) aux_nat_over_pos a1' (pow2 56); (**) aux_nat_plus_nat a2 (a1' / pow2 56); let a2':nat = (a2 + (a1' / pow2 56)) in (**) aux_nat_over_pos a2' (pow2 56); (**) aux_nat_plus_nat a3 (a2' / pow2 56); let a3':nat = (a3 + (a2' / pow2 56)) in lemma_aux_0 a1' a2 56; lemma_aux_0 a2' a3 112; lemma_aux_0 a3' a4 168 private val lemma_mod_264_: a0:nat -> a1:nat -> a2:nat -> a3:nat -> a4:nat -> Lemma ((a0 + pow2 56 * a1 + pow2 112 * a2 + pow2 168 * a3 + pow2 224 * a4) % pow2 264 = (a0 % pow2 56) + pow2 56 * ((a1 + (a0 / pow2 56)) % pow2 56) + pow2 112 * ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) + pow2 168 * ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) + pow2 224 * ((a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) % pow2 40)) let lemma_mod_264_ a0 a1 a2 a3 a4 = lemma_mod_264_small a0 a1 a2 a3 a4; let x0 = a0 % pow2 56 in assert (x0 < pow56); let x1 = ((a1 + (a0 / pow2 56)) % pow2 56) in assert (x1 < pow56); let x2 = ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) % pow2 56) in assert (x2 < pow56); let x3 = ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) % pow2 56) in assert (x3 < pow56); lemma_mod_264' x0 x1 x2 x3 (a4 + ((a3 + ((a2 + ((a1 + (a0 / pow2 56)) / pow2 56)) / pow2 56)) / pow2 56)) #push-options "--z3rlimit 50" let lemma_mul_5_low_264 x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 = lemma_div_nat_is_nat (x1 * y1) (pow2 56); lemma_div_nat_is_nat (x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) (pow2 56); lemma_div_nat_is_nat (x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) (pow2 56); lemma_div_nat_is_nat (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4 + ((x3 * y1 + x2 * y2 + x1 * y3 + ((x2 * y1 + x1 * y2 + ((x1 * y1) / pow2 56)) / pow2 56)) / pow2 56)) (pow2 56); lemma_mul_5''' x1 x2 x3 x4 x5 y1 y2 y3 y4 y5; lemma_mod_264_ (x1 * y1) (x2 * y1 + x1 * y2) (x3 * y1 + x2 * y2 + x1 * y3) (x4 * y1 + x3 * y2 + x2 * y3 + x1 * y4) (x5 * y1 + x4 * y2 + x3 * y3 + x2 * y4 + x1 * y5) #pop-options private val lemma_optimized_barrett_reduce: a:nat{a < pow2 512} -> Lemma (a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q < 2 * S.q /\ a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q >= 0) #push-options "--z3rlimit 50"
false
false
Hacl.Spec.BignumQ.Lemmas.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_optimized_barrett_reduce: a:nat{a < pow2 512} -> Lemma (a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q < 2 * S.q /\ a - (((a / pow2 248) * (pow2 512 / S.q)) / pow2 264) * S.q >= 0)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_optimized_barrett_reduce
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Prims.nat{a < Prims.pow2 512} -> FStar.Pervasives.Lemma (ensures a - ((a / Prims.pow2 248) * (Prims.pow2 512 / Spec.Ed25519.q) / Prims.pow2 264) * Spec.Ed25519.q < 2 * Spec.Ed25519.q /\ a - ((a / Prims.pow2 248) * (Prims.pow2 512 / Spec.Ed25519.q) / Prims.pow2 264) * Spec.Ed25519.q >= 0)
{ "end_col": 159, "end_line": 813, "start_col": 2, "start_line": 810 }
FStar.Pervasives.Lemma
val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280)
[ { "abbrev": false, "full_module": "Hacl.Spec.BignumQ.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Tactics.CanonCommSemiring", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.BignumQ", "short_module": null }, { "abbrev": false, "full_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_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 = assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280)
val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) let lemma_subm_conditional x0 x1 x2 x3 x4 y0 y1 y2 y3 y4 b0 b1 b2 b3 b4 =
false
null
true
assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280)
{ "checked_file": "Hacl.Spec.BignumQ.Lemmas.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.BignumQ.Definitions.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.BignumQ.Lemmas.fst" }
[ "lemma" ]
[ "Prims.nat", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Mul.op_Star", "Prims.pow2", "Prims.unit" ]
[]
module Hacl.Spec.BignumQ.Lemmas open FStar.Tactics.CanonCommSemiring open FStar.Mul open Lib.IntTypes module S = Spec.Ed25519 include Hacl.Spec.BignumQ.Definitions let feq (#a #b:Type) (f:(a -> b)) (x y:a) : Lemma (requires x == y) (ensures f x == f y) = () let eq_eq2 (#a:eqtype) (x y:a) : Lemma (requires x = y) (ensures x == y) = () val lemma_mul_lt:a:nat -> b:nat -> c:nat -> d:nat -> Lemma (requires a < b /\ c < d) (ensures a * c < b * d) let lemma_mul_lt a b c d = () val lemma_as_nat5: f:qelem5 -> Lemma (requires qelem_fits5 f (1, 1, 1, 1, 1)) (ensures as_nat5 f < pow2 280) let lemma_as_nat5 f = //let (f0, f1, f2, f3, f4) = f in //assert (as_nat5 f == v f0 + v f1 * pow56 + v f2 * pow112 + v f3 * pow168 + v f4 * pow224); assert_norm (pow2 56 * pow2 56 = pow2 112); assert_norm (pow2 56 * pow2 112 = pow2 168); assert_norm (pow2 56 * pow2 168 = pow2 224); assert_norm (pow2 56 * pow2 224 = pow2 280) val lemma_choose_step: bit:uint64{v bit <= 1} -> x:uint64 -> y:uint64 -> Lemma (let mask = bit -. u64 1 in let z = x ^. (mask &. (x ^. y)) in if v bit = 1 then z == x else z == y) let lemma_choose_step bit p1 p2 = let mask = bit -. u64 1 in assert (v bit == 0 ==> v mask == pow2 64 - 1); assert (v bit == 1 ==> v mask == 0); let dummy = mask &. (p1 ^. p2) in logand_lemma mask (p1 ^. p2); assert (v bit == 1 ==> v dummy == 0); assert (v bit == 0 ==> v dummy == v (p1 ^. p2)); let p1' = p1 ^. dummy in assert (v dummy == v (if v bit = 1 then u64 0 else (p1 ^. p2))); logxor_lemma p1 p2 val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280) #push-options "--z3rlimit 50"
false
false
Hacl.Spec.BignumQ.Lemmas.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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_subm_conditional: x0:nat -> x1:nat -> x2:nat -> x3:nat -> x4:nat -> y0:nat -> y1:nat -> y2:nat -> y3:nat -> y4:nat -> b0:nat -> b1:nat -> b2:nat -> b3:nat -> b4:nat -> Lemma ( x0 - y0 + b0 * pow2 56 + (x1 - y1 - b0 + b1 * pow2 56) * pow2 56 + (x2 - y2 - b1 + b2 * pow2 56) * pow2 112 + (x3 - y3 - b2 + b3 * pow2 56) * pow2 168 + (x4 - y4 - b3 + b4 * pow2 56) * pow2 224 == (x0 + x1 * pow2 56 + x2 * pow2 112 + x3 * pow2 168 + x4 * pow2 224) - (y0 + y1 * pow2 56 + y2 * pow2 112 + y3 * pow2 168 + y4 * pow2 224) + b4 * pow2 280)
[]
Hacl.Spec.BignumQ.Lemmas.lemma_subm_conditional
{ "file_name": "code/ed25519/Hacl.Spec.BignumQ.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x0: Prims.nat -> x1: Prims.nat -> x2: Prims.nat -> x3: Prims.nat -> x4: Prims.nat -> y0: Prims.nat -> y1: Prims.nat -> y2: Prims.nat -> y3: Prims.nat -> y4: Prims.nat -> b0: Prims.nat -> b1: Prims.nat -> b2: Prims.nat -> b3: Prims.nat -> b4: Prims.nat -> FStar.Pervasives.Lemma (ensures x0 - y0 + b0 * Prims.pow2 56 + (x1 - y1 - b0 + b1 * Prims.pow2 56) * Prims.pow2 56 + (x2 - y2 - b1 + b2 * Prims.pow2 56) * Prims.pow2 112 + (x3 - y3 - b2 + b3 * Prims.pow2 56) * Prims.pow2 168 + (x4 - y4 - b3 + b4 * Prims.pow2 56) * Prims.pow2 224 == x0 + x1 * Prims.pow2 56 + x2 * Prims.pow2 112 + x3 * Prims.pow2 168 + x4 * Prims.pow2 224 - (y0 + y1 * Prims.pow2 56 + y2 * Prims.pow2 112 + y3 * Prims.pow2 168 + y4 * Prims.pow2 224) + b4 * Prims.pow2 280)
{ "end_col": 45, "end_line": 79, "start_col": 2, "start_line": 76 }