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 sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sqr_mod x = S.qmul x x
val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x =
false
null
false
S.qmul x x
{ "checked_file": "Hacl.Spec.K256.Qinv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Qinv.fst" }
[ "total" ]
[ "Spec.K256.PointOps.qelem", "Spec.K256.PointOps.qmul" ]
[]
module Hacl.Spec.K256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.q let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y
false
true
Hacl.Spec.K256.Qinv.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 sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid
[]
Hacl.Spec.K256.Qinv.sqr_mod
{ "file_name": "code/k256/Hacl.Spec.K256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Exponentiation.sqr_st Spec.K256.PointOps.qelem Hacl.Spec.K256.Qinv.mk_to_nat_mod_comm_monoid
{ "end_col": 26, "end_line": 27, "start_col": 16, "start_line": 27 }
FStar.Pervasives.Lemma
val qinv_is_qinv_lemma: f:S.qelem -> Lemma (qinv f == S.qinv f)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qinv_is_qinv_lemma f = qinv_lemma f; assert (qinv f == M.pow f (S.q - 2) % S.q); M.lemma_pow_mod #S.q f (S.q - 2)
val qinv_is_qinv_lemma: f:S.qelem -> Lemma (qinv f == S.qinv f) let qinv_is_qinv_lemma f =
false
null
true
qinv_lemma f; assert (qinv f == M.pow f (S.q - 2) % S.q); M.lemma_pow_mod #S.q f (S.q - 2)
{ "checked_file": "Hacl.Spec.K256.Qinv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Qinv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.qelem", "Lib.NatMod.lemma_pow_mod", "Spec.K256.PointOps.q", "Prims.op_Subtraction", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.int", "Hacl.Spec.K256.Qinv.qinv", "Prims.op_Modulus", "Lib.NatMod.pow", "Hacl.Spec.K256.Qinv.qinv_lemma" ]
[]
module Hacl.Spec.K256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.q let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.q) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.q a (pow2 b) (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val qinv_r0_r1 (x14: S.qelem) : S.qelem let qinv_r0_r1 x14 = let x28 = S.qmul (qsquare_times x14 14) x14 in let x56 = S.qmul (qsquare_times x28 28) x28 in let r0 = S.qmul (qsquare_times x56 56) x56 in let r1 = S.qmul (qsquare_times r0 14) x14 in r1 val qinv_r2_r8 (r1 x_101 x_111 x_1011: S.qelem) : S.qelem let qinv_r2_r8 r1 x_101 x_111 x_1011 = let r2 = S.qmul (qsquare_times r1 3) x_101 in let r3 = S.qmul (qsquare_times r2 4) x_111 in let r4 = S.qmul (qsquare_times r3 4) x_101 in let r5 = S.qmul (qsquare_times r4 5) x_1011 in let r6 = S.qmul (qsquare_times r5 4) x_1011 in let r7 = S.qmul (qsquare_times r6 4) x_111 in let r8 = S.qmul (qsquare_times r7 5) x_111 in r8 val qinv_r9_r15 (r8 x_101 x_111 x_1001 x_1101: S.qelem) : S.qelem let qinv_r9_r15 r8 x_101 x_111 x_1001 x_1101 = let r9 = S.qmul (qsquare_times r8 6) x_1101 in let r10 = S.qmul (qsquare_times r9 4) x_101 in let r11 = S.qmul (qsquare_times r10 3) x_111 in let r12 = S.qmul (qsquare_times r11 5) x_1001 in let r13 = S.qmul (qsquare_times r12 6) x_101 in let r14 = S.qmul (qsquare_times r13 10) x_111 in let r15 = S.qmul (qsquare_times r14 4) x_111 in r15 val qinv_r16_r23 (r15 x8 x_11 x_1001 x_1011 x_1101: S.qelem) : S.qelem let qinv_r16_r23 r15 x8 x_11 x_1001 x_1011 x_1101 = let r16 = S.qmul (qsquare_times r15 9) x8 in let r17 = S.qmul (qsquare_times r16 5) x_1001 in let r18 = S.qmul (qsquare_times r17 6) x_1011 in let r19 = S.qmul (qsquare_times r18 4) x_1101 in let r20 = S.qmul (qsquare_times r19 5) x_11 in let r21 = S.qmul (qsquare_times r20 6) x_1101 in let r22 = S.qmul (qsquare_times r21 10) x_1101 in let r23 = S.qmul (qsquare_times r22 4) x_1001 in r23 val qinv_r24_r25 (r23 x_1 x6: S.qelem) : S.qelem let qinv_r24_r25 r23 x_1 x6 = let r24 = S.qmul (qsquare_times r23 6) x_1 in let r25 = S.qmul (qsquare_times r24 8) x6 in r25 val qinv_r0_r25 (x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101: S.qelem) : S.qelem let qinv_r0_r25 x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101 = let x6 = S.qmul (qsquare_times x_1101 2) x_1011 in let x8 = S.qmul (qsquare_times x6 2) x_11 in let x14 = S.qmul (qsquare_times x8 6) x6 in let r1 = qinv_r0_r1 x14 in let r8 = qinv_r2_r8 r1 x_101 x_111 x_1011 in let r15 = qinv_r9_r15 r8 x_101 x_111 x_1001 x_1101 in let r23 = qinv_r16_r23 r15 x8 x_11 x_1001 x_1011 x_1101 in qinv_r24_r25 r23 x_1 x6 val qinv: f:S.qelem -> S.qelem let qinv f = let x_1 = f in let x_10 = qsquare_times f 1 in let x_11 = S.qmul x_10 x_1 in let x_101 = S.qmul x_10 x_11 in let x_111 = S.qmul x_10 x_101 in let x_1001 = S.qmul x_10 x_111 in let x_1011 = S.qmul x_10 x_1001 in let x_1101 = S.qmul x_10 x_1011 in qinv_r0_r25 x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101 val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.q) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.q; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.q) val lemma_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.q) (M.pow f b % S.q) == M.pow f (a + b) % S.q) let lemma_pow_mod_mul f a b = calc (==) { S.qmul (M.pow f a % S.q) (M.pow f b % S.q); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.q) S.q; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.q } M.pow f a * M.pow f b % S.q; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.q; } val lemma_pow_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> c:nat -> Lemma (S.qmul (M.pow (M.pow f a % S.q) b % S.q) (M.pow f c % S.q) == M.pow f (a * b + c) % S.q) let lemma_pow_pow_mod_mul f a b c = calc (==) { S.qmul (M.pow (M.pow f a % S.q) b % S.q) (M.pow f c % S.q); (==) { M.lemma_pow_mod_base (M.pow f a) b S.q; Math.Lemmas.lemma_mod_mul_distr_l (M.pow (M.pow f a) b) (M.pow f c % S.q) S.q; Math.Lemmas.lemma_mod_mul_distr_r (M.pow (M.pow f a) b) (M.pow f c) S.q } M.pow (M.pow f a) b * M.pow f c % S.q; (==) { M.lemma_pow_mul f a b } M.pow f (a * b) * M.pow f c % S.q; (==) { M.lemma_pow_add f (a * b) c } M.pow f (a * b + c) % S.q; } // S.q - 2 = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413f val qinv_lemma: f:S.qelem -> Lemma (qinv f == M.pow f (S.q - 2) % S.q) let qinv_lemma f = let x_1 = f in let x_10 = qsquare_times f 1 in qsquare_times_lemma f 1; assert_norm (pow2 1 = 0x2); assert (x_10 == M.pow f 0x2 % S.q); let x_11 = S.qmul x_10 x_1 in lemma_pow_mod_1 f; lemma_pow_mod_mul f 0x2 0x1; assert (x_11 == M.pow f 0x3 % S.q); let x_101 = S.qmul x_10 x_11 in lemma_pow_mod_mul f 0x2 0x3; assert (x_101 == M.pow f 0x5 % S.q); let x_111 = S.qmul x_10 x_101 in lemma_pow_mod_mul f 0x2 0x5; assert (x_111 == M.pow f 0x7 % S.q); let x_1001 = S.qmul x_10 x_111 in lemma_pow_mod_mul f 0x2 0x7; assert (x_1001 == M.pow f 0x9 % S.q); let x_1011 = S.qmul x_10 x_1001 in lemma_pow_mod_mul f 0x2 0x9; assert (x_1011 == M.pow f 0xb % S.q); let x_1101 = S.qmul x_10 x_1011 in lemma_pow_mod_mul f 0x2 0xb; assert (x_1101 == M.pow f 0xd % S.q); let x6 = S.qmul (qsquare_times x_1101 2) x_1011 in qsquare_times_lemma x_1101 2; assert_norm (pow2 2 = 0x4); lemma_pow_pow_mod_mul f 0xd 0x4 0xb; assert (x6 == M.pow f 0x3f % S.q); let x8 = S.qmul (qsquare_times x6 2) x_11 in qsquare_times_lemma x6 2; lemma_pow_pow_mod_mul f 0x3f 0x4 0x3; assert (x8 == M.pow f 0xff % S.q); let x14 = S.qmul (qsquare_times x8 6) x6 in qsquare_times_lemma x8 6; assert_norm (pow2 6 = 0x40); lemma_pow_pow_mod_mul f 0xff 0x40 0x3f; assert (x14 == M.pow f 0x3fff % S.q); let x28 = S.qmul (qsquare_times x14 14) x14 in qsquare_times_lemma x14 14; assert_norm (pow2 14 = 0x4000); lemma_pow_pow_mod_mul f 0x3fff 0x4000 0x3fff; assert (x28 == M.pow f 0xfffffff % S.q); let x56 = S.qmul (qsquare_times x28 28) x28 in qsquare_times_lemma x28 28; assert_norm (pow2 28 = 0x10000000); lemma_pow_pow_mod_mul f 0xfffffff 0x10000000 0xfffffff; assert (x56 == M.pow f 0xffffffffffffff % S.q); let r0 = S.qmul (qsquare_times x56 56) x56 in qsquare_times_lemma x56 56; assert_norm (pow2 56 = 0x100000000000000); lemma_pow_pow_mod_mul f 0xffffffffffffff 0x100000000000000 0xffffffffffffff; assert (r0 == M.pow f 0xffffffffffffffffffffffffffff % S.q); let r1 = S.qmul (qsquare_times r0 14) x14 in qsquare_times_lemma r0 14; lemma_pow_pow_mod_mul f 0xffffffffffffffffffffffffffff 0x4000 0x3fff; assert (r1 == M.pow f 0x3fffffffffffffffffffffffffffffff % S.q); let r2 = S.qmul (qsquare_times r1 3) x_101 in qsquare_times_lemma r1 3; assert_norm (pow2 3 = 0x8); lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffff 0x8 0x5; assert (r2 == M.pow f 0x1fffffffffffffffffffffffffffffffd % S.q); let r3 = S.qmul (qsquare_times r2 4) x_111 in qsquare_times_lemma r2 4; assert_norm (pow2 4 = 0x10); lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd 0x10 0x7; assert (r3 == M.pow f 0x1fffffffffffffffffffffffffffffffd7 % S.q); let r4 = S.qmul (qsquare_times r3 4) x_101 in qsquare_times_lemma r3 4; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd7 0x10 0x5; assert (r4 == M.pow f 0x1fffffffffffffffffffffffffffffffd75 % S.q); let r5 = S.qmul (qsquare_times r4 5) x_1011 in qsquare_times_lemma r4 5; assert_norm (pow2 5 = 0x20); lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd75 0x20 0xb; assert (r5 == M.pow f 0x3fffffffffffffffffffffffffffffffaeab % S.q); let r6 = S.qmul (qsquare_times r5 4) x_1011 in qsquare_times_lemma r5 4; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeab 0x10 0xb; assert (r6 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb % S.q); let r7 = S.qmul (qsquare_times r6 4) x_111 in qsquare_times_lemma r6 4; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb 0x10 0x7; assert (r7 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb7 % S.q); let r8 = S.qmul (qsquare_times r7 5) x_111 in qsquare_times_lemma r7 5; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb7 0x20 0x7; assert (r8 == M.pow f 0x7fffffffffffffffffffffffffffffff5d576e7 % S.q); let r9 = S.qmul (qsquare_times r8 6) x_1101 in qsquare_times_lemma r8 6; lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffff5d576e7 0x40 0xd; assert (r9 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd % S.q); let r10 = S.qmul (qsquare_times r9 4) x_101 in qsquare_times_lemma r9 4; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd 0x10 0x5; assert (r10 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5 % S.q); let r11 = S.qmul (qsquare_times r10 3) x_111 in qsquare_times_lemma r10 3; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5 0x8 0x7; assert (r11 == M.pow f 0xfffffffffffffffffffffffffffffffebaaedce6af % S.q); let r12 = S.qmul (qsquare_times r11 5) x_1001 in qsquare_times_lemma r11 5; lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffebaaedce6af 0x20 0x9; assert (r12 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9 % S.q); let r13 = S.qmul (qsquare_times r12 6) x_101 in qsquare_times_lemma r12 6; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9 0x40 0x5; assert (r13 == M.pow f 0x7fffffffffffffffffffffffffffffff5d576e7357a45 % S.q); let r14 = S.qmul (qsquare_times r13 10) x_111 in qsquare_times_lemma r13 10; assert_norm (pow2 10 = 0x400); lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffff5d576e7357a45 0x400 0x7; assert (r14 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e91407 % S.q); let r15 = S.qmul (qsquare_times r14 4) x_111 in qsquare_times_lemma r14 4; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e91407 0x10 0x7; assert (r15 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e914077 % S.q); let r16 = S.qmul (qsquare_times r15 9) x8 in qsquare_times_lemma r15 9; assert_norm (pow2 9 = 0x200); lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e914077 0x200 0xff; assert (r16 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff % S.q); let r17 = S.qmul (qsquare_times r16 5) x_1001 in qsquare_times_lemma r16 5; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff 0x20 0x9; assert (r17 == M.pow f 0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe9 % S.q); let r18 = S.qmul (qsquare_times r17 6) x_1011 in qsquare_times_lemma r17 6; lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe9 0x40 0xb; assert (r18 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9140777fa4b % S.q); let r19 = S.qmul (qsquare_times r18 4) x_1101 in qsquare_times_lemma r18 4; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9140777fa4b 0x10 0xd; assert (r19 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9140777fa4bd % S.q); let r20 = S.qmul (qsquare_times r19 5) x_11 in qsquare_times_lemma r19 5; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9140777fa4bd 0x20 0x3; assert (r20 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3 % S.q); let r21 = S.qmul (qsquare_times r20 6) x_1101 in qsquare_times_lemma r20 6; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3 0x40 0xd; assert (r21 == M.pow f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd % S.q); let r22 = S.qmul (qsquare_times r21 10) x_1101 in qsquare_times_lemma r21 10; lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd 0x400 0xd; assert (r22 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3340d % S.q); let r23 = S.qmul (qsquare_times r22 4) x_1001 in qsquare_times_lemma r22 4; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3340d 0x10 0x9; assert (r23 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3340d9 % S.q); let r24 = S.qmul (qsquare_times r23 6) x_1 in qsquare_times_lemma r23 6; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3340d9 0x40 0x1; assert (r24 == M.pow f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641 % S.q); let r25 = S.qmul (qsquare_times r24 8) x6 in qsquare_times_lemma r24 8; assert_norm (pow2 8 = 0x100); lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641 0x100 0x3f; assert (r25 == M.pow f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413f % S.q) val qinv_is_qinv_lemma: f:S.qelem -> Lemma (qinv f == S.qinv f)
false
false
Hacl.Spec.K256.Qinv.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 qinv_is_qinv_lemma: f:S.qelem -> Lemma (qinv f == S.qinv f)
[]
Hacl.Spec.K256.Qinv.qinv_is_qinv_lemma
{ "file_name": "code/k256/Hacl.Spec.K256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.qelem -> FStar.Pervasives.Lemma (ensures Hacl.Spec.K256.Qinv.qinv f == Spec.K256.PointOps.qinv f)
{ "end_col": 34, "end_line": 378, "start_col": 2, "start_line": 376 }
Prims.Tot
val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_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_mod _ = 1
val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ =
false
null
false
1
{ "checked_file": "Hacl.Spec.K256.Qinv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Qinv.fst" }
[ "total" ]
[ "Prims.unit", "Spec.K256.PointOps.qelem" ]
[]
module Hacl.Spec.K256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.q let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); }
false
true
Hacl.Spec.K256.Qinv.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 one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid
[]
Hacl.Spec.K256.Qinv.one_mod
{ "file_name": "code/k256/Hacl.Spec.K256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Exponentiation.one_st Spec.K256.PointOps.qelem Hacl.Spec.K256.Qinv.mk_to_nat_mod_comm_monoid
{ "end_col": 17, "end_line": 21, "start_col": 16, "start_line": 21 }
FStar.Pervasives.Lemma
val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.q)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_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_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.q; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.q)
val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.q) let lemma_pow_mod_1 f =
false
null
true
M.lemma_pow1 f; Math.Lemmas.small_mod f S.q; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.q)
{ "checked_file": "Hacl.Spec.K256.Qinv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Qinv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.qelem", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Lib.NatMod.pow", "Spec.K256.PointOps.q", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.pow2", "FStar.Math.Lemmas.small_mod", "Lib.NatMod.lemma_pow1" ]
[]
module Hacl.Spec.K256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.q let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.q) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.q a (pow2 b) (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val qinv_r0_r1 (x14: S.qelem) : S.qelem let qinv_r0_r1 x14 = let x28 = S.qmul (qsquare_times x14 14) x14 in let x56 = S.qmul (qsquare_times x28 28) x28 in let r0 = S.qmul (qsquare_times x56 56) x56 in let r1 = S.qmul (qsquare_times r0 14) x14 in r1 val qinv_r2_r8 (r1 x_101 x_111 x_1011: S.qelem) : S.qelem let qinv_r2_r8 r1 x_101 x_111 x_1011 = let r2 = S.qmul (qsquare_times r1 3) x_101 in let r3 = S.qmul (qsquare_times r2 4) x_111 in let r4 = S.qmul (qsquare_times r3 4) x_101 in let r5 = S.qmul (qsquare_times r4 5) x_1011 in let r6 = S.qmul (qsquare_times r5 4) x_1011 in let r7 = S.qmul (qsquare_times r6 4) x_111 in let r8 = S.qmul (qsquare_times r7 5) x_111 in r8 val qinv_r9_r15 (r8 x_101 x_111 x_1001 x_1101: S.qelem) : S.qelem let qinv_r9_r15 r8 x_101 x_111 x_1001 x_1101 = let r9 = S.qmul (qsquare_times r8 6) x_1101 in let r10 = S.qmul (qsquare_times r9 4) x_101 in let r11 = S.qmul (qsquare_times r10 3) x_111 in let r12 = S.qmul (qsquare_times r11 5) x_1001 in let r13 = S.qmul (qsquare_times r12 6) x_101 in let r14 = S.qmul (qsquare_times r13 10) x_111 in let r15 = S.qmul (qsquare_times r14 4) x_111 in r15 val qinv_r16_r23 (r15 x8 x_11 x_1001 x_1011 x_1101: S.qelem) : S.qelem let qinv_r16_r23 r15 x8 x_11 x_1001 x_1011 x_1101 = let r16 = S.qmul (qsquare_times r15 9) x8 in let r17 = S.qmul (qsquare_times r16 5) x_1001 in let r18 = S.qmul (qsquare_times r17 6) x_1011 in let r19 = S.qmul (qsquare_times r18 4) x_1101 in let r20 = S.qmul (qsquare_times r19 5) x_11 in let r21 = S.qmul (qsquare_times r20 6) x_1101 in let r22 = S.qmul (qsquare_times r21 10) x_1101 in let r23 = S.qmul (qsquare_times r22 4) x_1001 in r23 val qinv_r24_r25 (r23 x_1 x6: S.qelem) : S.qelem let qinv_r24_r25 r23 x_1 x6 = let r24 = S.qmul (qsquare_times r23 6) x_1 in let r25 = S.qmul (qsquare_times r24 8) x6 in r25 val qinv_r0_r25 (x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101: S.qelem) : S.qelem let qinv_r0_r25 x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101 = let x6 = S.qmul (qsquare_times x_1101 2) x_1011 in let x8 = S.qmul (qsquare_times x6 2) x_11 in let x14 = S.qmul (qsquare_times x8 6) x6 in let r1 = qinv_r0_r1 x14 in let r8 = qinv_r2_r8 r1 x_101 x_111 x_1011 in let r15 = qinv_r9_r15 r8 x_101 x_111 x_1001 x_1101 in let r23 = qinv_r16_r23 r15 x8 x_11 x_1001 x_1011 x_1101 in qinv_r24_r25 r23 x_1 x6 val qinv: f:S.qelem -> S.qelem let qinv f = let x_1 = f in let x_10 = qsquare_times f 1 in let x_11 = S.qmul x_10 x_1 in let x_101 = S.qmul x_10 x_11 in let x_111 = S.qmul x_10 x_101 in let x_1001 = S.qmul x_10 x_111 in let x_1011 = S.qmul x_10 x_1001 in let x_1101 = S.qmul x_10 x_1011 in qinv_r0_r25 x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101 val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.q)
false
false
Hacl.Spec.K256.Qinv.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_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.q)
[]
Hacl.Spec.K256.Qinv.lemma_pow_mod_1
{ "file_name": "code/k256/Hacl.Spec.K256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.qelem -> FStar.Pervasives.Lemma (ensures f == Lib.NatMod.pow f 1 % Spec.K256.PointOps.q)
{ "end_col": 31, "end_line": 138, "start_col": 2, "start_line": 135 }
FStar.Pervasives.Lemma
val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.q)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.q a (pow2 b)
val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.q) let qsquare_times_lemma a b =
false
null
true
SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.q a (pow2 b)
{ "checked_file": "Hacl.Spec.K256.Qinv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Qinv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.qelem", "Prims.nat", "Lib.NatMod.lemma_pow_nat_mod_is_pow", "Spec.K256.PointOps.q", "Prims.pow2", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.l_or", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.K256.Qinv.qsquare_times", "Lib.Exponentiation.Definition.pow", "Lib.NatMod.nat_mod", "Hacl.Spec.K256.Qinv.nat_mod_comm_monoid", "Lib.Exponentiation.exp_pow2_lemma", "Spec.Exponentiation.exp_pow2_lemma", "Hacl.Spec.K256.Qinv.mk_nat_mod_concrete_ops" ]
[]
module Hacl.Spec.K256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.q let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.q)
false
false
Hacl.Spec.K256.Qinv.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 qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.q)
[]
Hacl.Spec.K256.Qinv.qsquare_times_lemma
{ "file_name": "code/k256/Hacl.Spec.K256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.K256.PointOps.qelem -> b: Prims.nat -> FStar.Pervasives.Lemma (ensures Hacl.Spec.K256.Qinv.qsquare_times a b == Lib.NatMod.pow a (Prims.pow2 b) % Spec.K256.PointOps.q)
{ "end_col": 44, "end_line": 45, "start_col": 2, "start_line": 42 }
FStar.Pervasives.Lemma
val lemma_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.q) (M.pow f b % S.q) == M.pow f (a + b) % S.q)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_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_pow_mod_mul f a b = calc (==) { S.qmul (M.pow f a % S.q) (M.pow f b % S.q); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.q) S.q; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.q } M.pow f a * M.pow f b % S.q; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.q; }
val lemma_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.q) (M.pow f b % S.q) == M.pow f (a + b) % S.q) let lemma_pow_mod_mul f a b =
false
null
true
calc ( == ) { S.qmul (M.pow f a % S.q) (M.pow f b % S.q); ( == ) { (Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.q) S.q; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.q) } M.pow f a * M.pow f b % S.q; ( == ) { M.lemma_pow_add f a b } M.pow f (a + b) % S.q; }
{ "checked_file": "Hacl.Spec.K256.Qinv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Qinv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.qelem", "Prims.nat", "FStar.Calc.calc_finish", "Prims.eq2", "Spec.K256.PointOps.qmul", "Prims.op_Modulus", "Lib.NatMod.pow", "Spec.K256.PointOps.q", "Prims.op_Addition", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Mul.op_Star", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.lemma_mod_mul_distr_r", "FStar.Math.Lemmas.lemma_mod_mul_distr_l", "Prims.squash", "Lib.NatMod.lemma_pow_add" ]
[]
module Hacl.Spec.K256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.q let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.q) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.q a (pow2 b) (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val qinv_r0_r1 (x14: S.qelem) : S.qelem let qinv_r0_r1 x14 = let x28 = S.qmul (qsquare_times x14 14) x14 in let x56 = S.qmul (qsquare_times x28 28) x28 in let r0 = S.qmul (qsquare_times x56 56) x56 in let r1 = S.qmul (qsquare_times r0 14) x14 in r1 val qinv_r2_r8 (r1 x_101 x_111 x_1011: S.qelem) : S.qelem let qinv_r2_r8 r1 x_101 x_111 x_1011 = let r2 = S.qmul (qsquare_times r1 3) x_101 in let r3 = S.qmul (qsquare_times r2 4) x_111 in let r4 = S.qmul (qsquare_times r3 4) x_101 in let r5 = S.qmul (qsquare_times r4 5) x_1011 in let r6 = S.qmul (qsquare_times r5 4) x_1011 in let r7 = S.qmul (qsquare_times r6 4) x_111 in let r8 = S.qmul (qsquare_times r7 5) x_111 in r8 val qinv_r9_r15 (r8 x_101 x_111 x_1001 x_1101: S.qelem) : S.qelem let qinv_r9_r15 r8 x_101 x_111 x_1001 x_1101 = let r9 = S.qmul (qsquare_times r8 6) x_1101 in let r10 = S.qmul (qsquare_times r9 4) x_101 in let r11 = S.qmul (qsquare_times r10 3) x_111 in let r12 = S.qmul (qsquare_times r11 5) x_1001 in let r13 = S.qmul (qsquare_times r12 6) x_101 in let r14 = S.qmul (qsquare_times r13 10) x_111 in let r15 = S.qmul (qsquare_times r14 4) x_111 in r15 val qinv_r16_r23 (r15 x8 x_11 x_1001 x_1011 x_1101: S.qelem) : S.qelem let qinv_r16_r23 r15 x8 x_11 x_1001 x_1011 x_1101 = let r16 = S.qmul (qsquare_times r15 9) x8 in let r17 = S.qmul (qsquare_times r16 5) x_1001 in let r18 = S.qmul (qsquare_times r17 6) x_1011 in let r19 = S.qmul (qsquare_times r18 4) x_1101 in let r20 = S.qmul (qsquare_times r19 5) x_11 in let r21 = S.qmul (qsquare_times r20 6) x_1101 in let r22 = S.qmul (qsquare_times r21 10) x_1101 in let r23 = S.qmul (qsquare_times r22 4) x_1001 in r23 val qinv_r24_r25 (r23 x_1 x6: S.qelem) : S.qelem let qinv_r24_r25 r23 x_1 x6 = let r24 = S.qmul (qsquare_times r23 6) x_1 in let r25 = S.qmul (qsquare_times r24 8) x6 in r25 val qinv_r0_r25 (x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101: S.qelem) : S.qelem let qinv_r0_r25 x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101 = let x6 = S.qmul (qsquare_times x_1101 2) x_1011 in let x8 = S.qmul (qsquare_times x6 2) x_11 in let x14 = S.qmul (qsquare_times x8 6) x6 in let r1 = qinv_r0_r1 x14 in let r8 = qinv_r2_r8 r1 x_101 x_111 x_1011 in let r15 = qinv_r9_r15 r8 x_101 x_111 x_1001 x_1101 in let r23 = qinv_r16_r23 r15 x8 x_11 x_1001 x_1011 x_1101 in qinv_r24_r25 r23 x_1 x6 val qinv: f:S.qelem -> S.qelem let qinv f = let x_1 = f in let x_10 = qsquare_times f 1 in let x_11 = S.qmul x_10 x_1 in let x_101 = S.qmul x_10 x_11 in let x_111 = S.qmul x_10 x_101 in let x_1001 = S.qmul x_10 x_111 in let x_1011 = S.qmul x_10 x_1001 in let x_1101 = S.qmul x_10 x_1011 in qinv_r0_r25 x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101 val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.q) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.q; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.q) val lemma_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.q) (M.pow f b % S.q) == M.pow f (a + b) % S.q)
false
false
Hacl.Spec.K256.Qinv.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_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.q) (M.pow f b % S.q) == M.pow f (a + b) % S.q)
[]
Hacl.Spec.K256.Qinv.lemma_pow_mod_mul
{ "file_name": "code/k256/Hacl.Spec.K256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.qelem -> a: Prims.nat -> b: Prims.nat -> FStar.Pervasives.Lemma (ensures Spec.K256.PointOps.qmul (Lib.NatMod.pow f a % Spec.K256.PointOps.q) (Lib.NatMod.pow f b % Spec.K256.PointOps.q) == Lib.NatMod.pow f (a + b) % Spec.K256.PointOps.q)
{ "end_col": 3, "end_line": 152, "start_col": 2, "start_line": 144 }
FStar.Pervasives.Lemma
val lemma_pow_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> c:nat -> Lemma (S.qmul (M.pow (M.pow f a % S.q) b % S.q) (M.pow f c % S.q) == M.pow f (a * b + c) % S.q)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_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_pow_pow_mod_mul f a b c = calc (==) { S.qmul (M.pow (M.pow f a % S.q) b % S.q) (M.pow f c % S.q); (==) { M.lemma_pow_mod_base (M.pow f a) b S.q; Math.Lemmas.lemma_mod_mul_distr_l (M.pow (M.pow f a) b) (M.pow f c % S.q) S.q; Math.Lemmas.lemma_mod_mul_distr_r (M.pow (M.pow f a) b) (M.pow f c) S.q } M.pow (M.pow f a) b * M.pow f c % S.q; (==) { M.lemma_pow_mul f a b } M.pow f (a * b) * M.pow f c % S.q; (==) { M.lemma_pow_add f (a * b) c } M.pow f (a * b + c) % S.q; }
val lemma_pow_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> c:nat -> Lemma (S.qmul (M.pow (M.pow f a % S.q) b % S.q) (M.pow f c % S.q) == M.pow f (a * b + c) % S.q) let lemma_pow_pow_mod_mul f a b c =
false
null
true
calc ( == ) { S.qmul (M.pow (M.pow f a % S.q) b % S.q) (M.pow f c % S.q); ( == ) { (M.lemma_pow_mod_base (M.pow f a) b S.q; Math.Lemmas.lemma_mod_mul_distr_l (M.pow (M.pow f a) b) (M.pow f c % S.q) S.q; Math.Lemmas.lemma_mod_mul_distr_r (M.pow (M.pow f a) b) (M.pow f c) S.q) } M.pow (M.pow f a) b * M.pow f c % S.q; ( == ) { M.lemma_pow_mul f a b } M.pow f (a * b) * M.pow f c % S.q; ( == ) { M.lemma_pow_add f (a * b) c } M.pow f (a * b + c) % S.q; }
{ "checked_file": "Hacl.Spec.K256.Qinv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Qinv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.qelem", "Prims.nat", "FStar.Calc.calc_finish", "Prims.eq2", "Spec.K256.PointOps.qmul", "Prims.op_Modulus", "Lib.NatMod.pow", "Spec.K256.PointOps.q", "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", "FStar.Math.Lemmas.lemma_mod_mul_distr_r", "FStar.Math.Lemmas.lemma_mod_mul_distr_l", "Lib.NatMod.lemma_pow_mod_base", "Prims.squash", "Lib.NatMod.lemma_pow_mul", "Lib.NatMod.lemma_pow_add" ]
[]
module Hacl.Spec.K256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.q let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.q) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.q a (pow2 b) (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val qinv_r0_r1 (x14: S.qelem) : S.qelem let qinv_r0_r1 x14 = let x28 = S.qmul (qsquare_times x14 14) x14 in let x56 = S.qmul (qsquare_times x28 28) x28 in let r0 = S.qmul (qsquare_times x56 56) x56 in let r1 = S.qmul (qsquare_times r0 14) x14 in r1 val qinv_r2_r8 (r1 x_101 x_111 x_1011: S.qelem) : S.qelem let qinv_r2_r8 r1 x_101 x_111 x_1011 = let r2 = S.qmul (qsquare_times r1 3) x_101 in let r3 = S.qmul (qsquare_times r2 4) x_111 in let r4 = S.qmul (qsquare_times r3 4) x_101 in let r5 = S.qmul (qsquare_times r4 5) x_1011 in let r6 = S.qmul (qsquare_times r5 4) x_1011 in let r7 = S.qmul (qsquare_times r6 4) x_111 in let r8 = S.qmul (qsquare_times r7 5) x_111 in r8 val qinv_r9_r15 (r8 x_101 x_111 x_1001 x_1101: S.qelem) : S.qelem let qinv_r9_r15 r8 x_101 x_111 x_1001 x_1101 = let r9 = S.qmul (qsquare_times r8 6) x_1101 in let r10 = S.qmul (qsquare_times r9 4) x_101 in let r11 = S.qmul (qsquare_times r10 3) x_111 in let r12 = S.qmul (qsquare_times r11 5) x_1001 in let r13 = S.qmul (qsquare_times r12 6) x_101 in let r14 = S.qmul (qsquare_times r13 10) x_111 in let r15 = S.qmul (qsquare_times r14 4) x_111 in r15 val qinv_r16_r23 (r15 x8 x_11 x_1001 x_1011 x_1101: S.qelem) : S.qelem let qinv_r16_r23 r15 x8 x_11 x_1001 x_1011 x_1101 = let r16 = S.qmul (qsquare_times r15 9) x8 in let r17 = S.qmul (qsquare_times r16 5) x_1001 in let r18 = S.qmul (qsquare_times r17 6) x_1011 in let r19 = S.qmul (qsquare_times r18 4) x_1101 in let r20 = S.qmul (qsquare_times r19 5) x_11 in let r21 = S.qmul (qsquare_times r20 6) x_1101 in let r22 = S.qmul (qsquare_times r21 10) x_1101 in let r23 = S.qmul (qsquare_times r22 4) x_1001 in r23 val qinv_r24_r25 (r23 x_1 x6: S.qelem) : S.qelem let qinv_r24_r25 r23 x_1 x6 = let r24 = S.qmul (qsquare_times r23 6) x_1 in let r25 = S.qmul (qsquare_times r24 8) x6 in r25 val qinv_r0_r25 (x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101: S.qelem) : S.qelem let qinv_r0_r25 x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101 = let x6 = S.qmul (qsquare_times x_1101 2) x_1011 in let x8 = S.qmul (qsquare_times x6 2) x_11 in let x14 = S.qmul (qsquare_times x8 6) x6 in let r1 = qinv_r0_r1 x14 in let r8 = qinv_r2_r8 r1 x_101 x_111 x_1011 in let r15 = qinv_r9_r15 r8 x_101 x_111 x_1001 x_1101 in let r23 = qinv_r16_r23 r15 x8 x_11 x_1001 x_1011 x_1101 in qinv_r24_r25 r23 x_1 x6 val qinv: f:S.qelem -> S.qelem let qinv f = let x_1 = f in let x_10 = qsquare_times f 1 in let x_11 = S.qmul x_10 x_1 in let x_101 = S.qmul x_10 x_11 in let x_111 = S.qmul x_10 x_101 in let x_1001 = S.qmul x_10 x_111 in let x_1011 = S.qmul x_10 x_1001 in let x_1101 = S.qmul x_10 x_1011 in qinv_r0_r25 x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101 val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.q) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.q; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.q) val lemma_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.q) (M.pow f b % S.q) == M.pow f (a + b) % S.q) let lemma_pow_mod_mul f a b = calc (==) { S.qmul (M.pow f a % S.q) (M.pow f b % S.q); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.q) S.q; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.q } M.pow f a * M.pow f b % S.q; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.q; } val lemma_pow_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> c:nat -> Lemma (S.qmul (M.pow (M.pow f a % S.q) b % S.q) (M.pow f c % S.q) == M.pow f (a * b + c) % S.q)
false
false
Hacl.Spec.K256.Qinv.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_pow_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> c:nat -> Lemma (S.qmul (M.pow (M.pow f a % S.q) b % S.q) (M.pow f c % S.q) == M.pow f (a * b + c) % S.q)
[]
Hacl.Spec.K256.Qinv.lemma_pow_pow_mod_mul
{ "file_name": "code/k256/Hacl.Spec.K256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.qelem -> a: Prims.nat -> b: Prims.nat -> c: Prims.nat -> FStar.Pervasives.Lemma (ensures Spec.K256.PointOps.qmul (Lib.NatMod.pow (Lib.NatMod.pow f a % Spec.K256.PointOps.q) b % Spec.K256.PointOps.q) (Lib.NatMod.pow f c % Spec.K256.PointOps.q) == Lib.NatMod.pow f (a * b + c) % Spec.K256.PointOps.q)
{ "end_col": 3, "end_line": 169, "start_col": 2, "start_line": 158 }
FStar.Pervasives.Lemma
val qinv_lemma: f:S.qelem -> Lemma (qinv f == M.pow f (S.q - 2) % S.q)
[ { "abbrev": true, "full_module": "Spec.K256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.K256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qinv_lemma f = let x_1 = f in let x_10 = qsquare_times f 1 in qsquare_times_lemma f 1; assert_norm (pow2 1 = 0x2); assert (x_10 == M.pow f 0x2 % S.q); let x_11 = S.qmul x_10 x_1 in lemma_pow_mod_1 f; lemma_pow_mod_mul f 0x2 0x1; assert (x_11 == M.pow f 0x3 % S.q); let x_101 = S.qmul x_10 x_11 in lemma_pow_mod_mul f 0x2 0x3; assert (x_101 == M.pow f 0x5 % S.q); let x_111 = S.qmul x_10 x_101 in lemma_pow_mod_mul f 0x2 0x5; assert (x_111 == M.pow f 0x7 % S.q); let x_1001 = S.qmul x_10 x_111 in lemma_pow_mod_mul f 0x2 0x7; assert (x_1001 == M.pow f 0x9 % S.q); let x_1011 = S.qmul x_10 x_1001 in lemma_pow_mod_mul f 0x2 0x9; assert (x_1011 == M.pow f 0xb % S.q); let x_1101 = S.qmul x_10 x_1011 in lemma_pow_mod_mul f 0x2 0xb; assert (x_1101 == M.pow f 0xd % S.q); let x6 = S.qmul (qsquare_times x_1101 2) x_1011 in qsquare_times_lemma x_1101 2; assert_norm (pow2 2 = 0x4); lemma_pow_pow_mod_mul f 0xd 0x4 0xb; assert (x6 == M.pow f 0x3f % S.q); let x8 = S.qmul (qsquare_times x6 2) x_11 in qsquare_times_lemma x6 2; lemma_pow_pow_mod_mul f 0x3f 0x4 0x3; assert (x8 == M.pow f 0xff % S.q); let x14 = S.qmul (qsquare_times x8 6) x6 in qsquare_times_lemma x8 6; assert_norm (pow2 6 = 0x40); lemma_pow_pow_mod_mul f 0xff 0x40 0x3f; assert (x14 == M.pow f 0x3fff % S.q); let x28 = S.qmul (qsquare_times x14 14) x14 in qsquare_times_lemma x14 14; assert_norm (pow2 14 = 0x4000); lemma_pow_pow_mod_mul f 0x3fff 0x4000 0x3fff; assert (x28 == M.pow f 0xfffffff % S.q); let x56 = S.qmul (qsquare_times x28 28) x28 in qsquare_times_lemma x28 28; assert_norm (pow2 28 = 0x10000000); lemma_pow_pow_mod_mul f 0xfffffff 0x10000000 0xfffffff; assert (x56 == M.pow f 0xffffffffffffff % S.q); let r0 = S.qmul (qsquare_times x56 56) x56 in qsquare_times_lemma x56 56; assert_norm (pow2 56 = 0x100000000000000); lemma_pow_pow_mod_mul f 0xffffffffffffff 0x100000000000000 0xffffffffffffff; assert (r0 == M.pow f 0xffffffffffffffffffffffffffff % S.q); let r1 = S.qmul (qsquare_times r0 14) x14 in qsquare_times_lemma r0 14; lemma_pow_pow_mod_mul f 0xffffffffffffffffffffffffffff 0x4000 0x3fff; assert (r1 == M.pow f 0x3fffffffffffffffffffffffffffffff % S.q); let r2 = S.qmul (qsquare_times r1 3) x_101 in qsquare_times_lemma r1 3; assert_norm (pow2 3 = 0x8); lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffff 0x8 0x5; assert (r2 == M.pow f 0x1fffffffffffffffffffffffffffffffd % S.q); let r3 = S.qmul (qsquare_times r2 4) x_111 in qsquare_times_lemma r2 4; assert_norm (pow2 4 = 0x10); lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd 0x10 0x7; assert (r3 == M.pow f 0x1fffffffffffffffffffffffffffffffd7 % S.q); let r4 = S.qmul (qsquare_times r3 4) x_101 in qsquare_times_lemma r3 4; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd7 0x10 0x5; assert (r4 == M.pow f 0x1fffffffffffffffffffffffffffffffd75 % S.q); let r5 = S.qmul (qsquare_times r4 5) x_1011 in qsquare_times_lemma r4 5; assert_norm (pow2 5 = 0x20); lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd75 0x20 0xb; assert (r5 == M.pow f 0x3fffffffffffffffffffffffffffffffaeab % S.q); let r6 = S.qmul (qsquare_times r5 4) x_1011 in qsquare_times_lemma r5 4; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeab 0x10 0xb; assert (r6 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb % S.q); let r7 = S.qmul (qsquare_times r6 4) x_111 in qsquare_times_lemma r6 4; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb 0x10 0x7; assert (r7 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb7 % S.q); let r8 = S.qmul (qsquare_times r7 5) x_111 in qsquare_times_lemma r7 5; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb7 0x20 0x7; assert (r8 == M.pow f 0x7fffffffffffffffffffffffffffffff5d576e7 % S.q); let r9 = S.qmul (qsquare_times r8 6) x_1101 in qsquare_times_lemma r8 6; lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffff5d576e7 0x40 0xd; assert (r9 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd % S.q); let r10 = S.qmul (qsquare_times r9 4) x_101 in qsquare_times_lemma r9 4; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd 0x10 0x5; assert (r10 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5 % S.q); let r11 = S.qmul (qsquare_times r10 3) x_111 in qsquare_times_lemma r10 3; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5 0x8 0x7; assert (r11 == M.pow f 0xfffffffffffffffffffffffffffffffebaaedce6af % S.q); let r12 = S.qmul (qsquare_times r11 5) x_1001 in qsquare_times_lemma r11 5; lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffebaaedce6af 0x20 0x9; assert (r12 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9 % S.q); let r13 = S.qmul (qsquare_times r12 6) x_101 in qsquare_times_lemma r12 6; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9 0x40 0x5; assert (r13 == M.pow f 0x7fffffffffffffffffffffffffffffff5d576e7357a45 % S.q); let r14 = S.qmul (qsquare_times r13 10) x_111 in qsquare_times_lemma r13 10; assert_norm (pow2 10 = 0x400); lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffff5d576e7357a45 0x400 0x7; assert (r14 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e91407 % S.q); let r15 = S.qmul (qsquare_times r14 4) x_111 in qsquare_times_lemma r14 4; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e91407 0x10 0x7; assert (r15 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e914077 % S.q); let r16 = S.qmul (qsquare_times r15 9) x8 in qsquare_times_lemma r15 9; assert_norm (pow2 9 = 0x200); lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e914077 0x200 0xff; assert (r16 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff % S.q); let r17 = S.qmul (qsquare_times r16 5) x_1001 in qsquare_times_lemma r16 5; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff 0x20 0x9; assert (r17 == M.pow f 0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe9 % S.q); let r18 = S.qmul (qsquare_times r17 6) x_1011 in qsquare_times_lemma r17 6; lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe9 0x40 0xb; assert (r18 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9140777fa4b % S.q); let r19 = S.qmul (qsquare_times r18 4) x_1101 in qsquare_times_lemma r18 4; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9140777fa4b 0x10 0xd; assert (r19 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9140777fa4bd % S.q); let r20 = S.qmul (qsquare_times r19 5) x_11 in qsquare_times_lemma r19 5; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9140777fa4bd 0x20 0x3; assert (r20 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3 % S.q); let r21 = S.qmul (qsquare_times r20 6) x_1101 in qsquare_times_lemma r20 6; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3 0x40 0xd; assert (r21 == M.pow f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd % S.q); let r22 = S.qmul (qsquare_times r21 10) x_1101 in qsquare_times_lemma r21 10; lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd 0x400 0xd; assert (r22 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3340d % S.q); let r23 = S.qmul (qsquare_times r22 4) x_1001 in qsquare_times_lemma r22 4; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3340d 0x10 0x9; assert (r23 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3340d9 % S.q); let r24 = S.qmul (qsquare_times r23 6) x_1 in qsquare_times_lemma r23 6; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3340d9 0x40 0x1; assert (r24 == M.pow f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641 % S.q); let r25 = S.qmul (qsquare_times r24 8) x6 in qsquare_times_lemma r24 8; assert_norm (pow2 8 = 0x100); lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641 0x100 0x3f; assert (r25 == M.pow f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413f % S.q)
val qinv_lemma: f:S.qelem -> Lemma (qinv f == M.pow f (S.q - 2) % S.q) let qinv_lemma f =
false
null
true
let x_1 = f in let x_10 = qsquare_times f 1 in qsquare_times_lemma f 1; assert_norm (pow2 1 = 0x2); assert (x_10 == M.pow f 0x2 % S.q); let x_11 = S.qmul x_10 x_1 in lemma_pow_mod_1 f; lemma_pow_mod_mul f 0x2 0x1; assert (x_11 == M.pow f 0x3 % S.q); let x_101 = S.qmul x_10 x_11 in lemma_pow_mod_mul f 0x2 0x3; assert (x_101 == M.pow f 0x5 % S.q); let x_111 = S.qmul x_10 x_101 in lemma_pow_mod_mul f 0x2 0x5; assert (x_111 == M.pow f 0x7 % S.q); let x_1001 = S.qmul x_10 x_111 in lemma_pow_mod_mul f 0x2 0x7; assert (x_1001 == M.pow f 0x9 % S.q); let x_1011 = S.qmul x_10 x_1001 in lemma_pow_mod_mul f 0x2 0x9; assert (x_1011 == M.pow f 0xb % S.q); let x_1101 = S.qmul x_10 x_1011 in lemma_pow_mod_mul f 0x2 0xb; assert (x_1101 == M.pow f 0xd % S.q); let x6 = S.qmul (qsquare_times x_1101 2) x_1011 in qsquare_times_lemma x_1101 2; assert_norm (pow2 2 = 0x4); lemma_pow_pow_mod_mul f 0xd 0x4 0xb; assert (x6 == M.pow f 0x3f % S.q); let x8 = S.qmul (qsquare_times x6 2) x_11 in qsquare_times_lemma x6 2; lemma_pow_pow_mod_mul f 0x3f 0x4 0x3; assert (x8 == M.pow f 0xff % S.q); let x14 = S.qmul (qsquare_times x8 6) x6 in qsquare_times_lemma x8 6; assert_norm (pow2 6 = 0x40); lemma_pow_pow_mod_mul f 0xff 0x40 0x3f; assert (x14 == M.pow f 0x3fff % S.q); let x28 = S.qmul (qsquare_times x14 14) x14 in qsquare_times_lemma x14 14; assert_norm (pow2 14 = 0x4000); lemma_pow_pow_mod_mul f 0x3fff 0x4000 0x3fff; assert (x28 == M.pow f 0xfffffff % S.q); let x56 = S.qmul (qsquare_times x28 28) x28 in qsquare_times_lemma x28 28; assert_norm (pow2 28 = 0x10000000); lemma_pow_pow_mod_mul f 0xfffffff 0x10000000 0xfffffff; assert (x56 == M.pow f 0xffffffffffffff % S.q); let r0 = S.qmul (qsquare_times x56 56) x56 in qsquare_times_lemma x56 56; assert_norm (pow2 56 = 0x100000000000000); lemma_pow_pow_mod_mul f 0xffffffffffffff 0x100000000000000 0xffffffffffffff; assert (r0 == M.pow f 0xffffffffffffffffffffffffffff % S.q); let r1 = S.qmul (qsquare_times r0 14) x14 in qsquare_times_lemma r0 14; lemma_pow_pow_mod_mul f 0xffffffffffffffffffffffffffff 0x4000 0x3fff; assert (r1 == M.pow f 0x3fffffffffffffffffffffffffffffff % S.q); let r2 = S.qmul (qsquare_times r1 3) x_101 in qsquare_times_lemma r1 3; assert_norm (pow2 3 = 0x8); lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffff 0x8 0x5; assert (r2 == M.pow f 0x1fffffffffffffffffffffffffffffffd % S.q); let r3 = S.qmul (qsquare_times r2 4) x_111 in qsquare_times_lemma r2 4; assert_norm (pow2 4 = 0x10); lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd 0x10 0x7; assert (r3 == M.pow f 0x1fffffffffffffffffffffffffffffffd7 % S.q); let r4 = S.qmul (qsquare_times r3 4) x_101 in qsquare_times_lemma r3 4; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd7 0x10 0x5; assert (r4 == M.pow f 0x1fffffffffffffffffffffffffffffffd75 % S.q); let r5 = S.qmul (qsquare_times r4 5) x_1011 in qsquare_times_lemma r4 5; assert_norm (pow2 5 = 0x20); lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd75 0x20 0xb; assert (r5 == M.pow f 0x3fffffffffffffffffffffffffffffffaeab % S.q); let r6 = S.qmul (qsquare_times r5 4) x_1011 in qsquare_times_lemma r5 4; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeab 0x10 0xb; assert (r6 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb % S.q); let r7 = S.qmul (qsquare_times r6 4) x_111 in qsquare_times_lemma r6 4; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb 0x10 0x7; assert (r7 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb7 % S.q); let r8 = S.qmul (qsquare_times r7 5) x_111 in qsquare_times_lemma r7 5; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb7 0x20 0x7; assert (r8 == M.pow f 0x7fffffffffffffffffffffffffffffff5d576e7 % S.q); let r9 = S.qmul (qsquare_times r8 6) x_1101 in qsquare_times_lemma r8 6; lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffff5d576e7 0x40 0xd; assert (r9 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd % S.q); let r10 = S.qmul (qsquare_times r9 4) x_101 in qsquare_times_lemma r9 4; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd 0x10 0x5; assert (r10 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5 % S.q); let r11 = S.qmul (qsquare_times r10 3) x_111 in qsquare_times_lemma r10 3; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5 0x8 0x7; assert (r11 == M.pow f 0xfffffffffffffffffffffffffffffffebaaedce6af % S.q); let r12 = S.qmul (qsquare_times r11 5) x_1001 in qsquare_times_lemma r11 5; lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffebaaedce6af 0x20 0x9; assert (r12 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9 % S.q); let r13 = S.qmul (qsquare_times r12 6) x_101 in qsquare_times_lemma r12 6; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9 0x40 0x5; assert (r13 == M.pow f 0x7fffffffffffffffffffffffffffffff5d576e7357a45 % S.q); let r14 = S.qmul (qsquare_times r13 10) x_111 in qsquare_times_lemma r13 10; assert_norm (pow2 10 = 0x400); lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffff5d576e7357a45 0x400 0x7; assert (r14 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e91407 % S.q); let r15 = S.qmul (qsquare_times r14 4) x_111 in qsquare_times_lemma r14 4; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e91407 0x10 0x7; assert (r15 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e914077 % S.q); let r16 = S.qmul (qsquare_times r15 9) x8 in qsquare_times_lemma r15 9; assert_norm (pow2 9 = 0x200); lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e914077 0x200 0xff; assert (r16 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff % S.q); let r17 = S.qmul (qsquare_times r16 5) x_1001 in qsquare_times_lemma r16 5; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff 0x20 0x9; assert (r17 == M.pow f 0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe9 % S.q); let r18 = S.qmul (qsquare_times r17 6) x_1011 in qsquare_times_lemma r17 6; lemma_pow_pow_mod_mul f 0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe9 0x40 0xb; assert (r18 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9140777fa4b % S.q); let r19 = S.qmul (qsquare_times r18 4) x_1101 in qsquare_times_lemma r18 4; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9140777fa4b 0x10 0xd; assert (r19 == M.pow f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9140777fa4bd % S.q); let r20 = S.qmul (qsquare_times r19 5) x_11 in qsquare_times_lemma r19 5; lemma_pow_pow_mod_mul f 0x1fffffffffffffffffffffffffffffffd755db9cd5e9140777fa4bd 0x20 0x3; assert (r20 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3 % S.q); let r21 = S.qmul (qsquare_times r20 6) x_1101 in qsquare_times_lemma r20 6; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3 0x40 0xd; assert (r21 == M.pow f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd % S.q); let r22 = S.qmul (qsquare_times r21 10) x_1101 in qsquare_times_lemma r21 10; lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd 0x400 0xd; assert (r22 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3340d % S.q); let r23 = S.qmul (qsquare_times r22 4) x_1001 in qsquare_times_lemma r22 4; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3340d 0x10 0x9; assert (r23 == M.pow f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3340d9 % S.q); let r24 = S.qmul (qsquare_times r23 6) x_1 in qsquare_times_lemma r23 6; lemma_pow_pow_mod_mul f 0x3fffffffffffffffffffffffffffffffaeabb739abd2280eeff497a3340d9 0x40 0x1; assert (r24 == M.pow f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641 % S.q); let r25 = S.qmul (qsquare_times r24 8) x6 in qsquare_times_lemma r24 8; assert_norm (pow2 8 = 0x100); lemma_pow_pow_mod_mul f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641 0x100 0x3f; assert (r25 == M.pow f 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413f % S.q)
{ "checked_file": "Hacl.Spec.K256.Qinv.fst.checked", "dependencies": [ "Spec.K256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.K256.Qinv.fst" }
[ "lemma" ]
[ "Spec.K256.PointOps.qelem", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Lib.NatMod.pow", "Spec.K256.PointOps.q", "Prims.unit", "Hacl.Spec.K256.Qinv.lemma_pow_pow_mod_mul", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.pow2", "Hacl.Spec.K256.Qinv.qsquare_times_lemma", "Spec.K256.PointOps.qmul", "Hacl.Spec.K256.Qinv.qsquare_times", "Hacl.Spec.K256.Qinv.lemma_pow_mod_mul", "Hacl.Spec.K256.Qinv.lemma_pow_mod_1" ]
[]
module Hacl.Spec.K256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.K256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.q let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.q) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.q a (pow2 b) (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val qinv_r0_r1 (x14: S.qelem) : S.qelem let qinv_r0_r1 x14 = let x28 = S.qmul (qsquare_times x14 14) x14 in let x56 = S.qmul (qsquare_times x28 28) x28 in let r0 = S.qmul (qsquare_times x56 56) x56 in let r1 = S.qmul (qsquare_times r0 14) x14 in r1 val qinv_r2_r8 (r1 x_101 x_111 x_1011: S.qelem) : S.qelem let qinv_r2_r8 r1 x_101 x_111 x_1011 = let r2 = S.qmul (qsquare_times r1 3) x_101 in let r3 = S.qmul (qsquare_times r2 4) x_111 in let r4 = S.qmul (qsquare_times r3 4) x_101 in let r5 = S.qmul (qsquare_times r4 5) x_1011 in let r6 = S.qmul (qsquare_times r5 4) x_1011 in let r7 = S.qmul (qsquare_times r6 4) x_111 in let r8 = S.qmul (qsquare_times r7 5) x_111 in r8 val qinv_r9_r15 (r8 x_101 x_111 x_1001 x_1101: S.qelem) : S.qelem let qinv_r9_r15 r8 x_101 x_111 x_1001 x_1101 = let r9 = S.qmul (qsquare_times r8 6) x_1101 in let r10 = S.qmul (qsquare_times r9 4) x_101 in let r11 = S.qmul (qsquare_times r10 3) x_111 in let r12 = S.qmul (qsquare_times r11 5) x_1001 in let r13 = S.qmul (qsquare_times r12 6) x_101 in let r14 = S.qmul (qsquare_times r13 10) x_111 in let r15 = S.qmul (qsquare_times r14 4) x_111 in r15 val qinv_r16_r23 (r15 x8 x_11 x_1001 x_1011 x_1101: S.qelem) : S.qelem let qinv_r16_r23 r15 x8 x_11 x_1001 x_1011 x_1101 = let r16 = S.qmul (qsquare_times r15 9) x8 in let r17 = S.qmul (qsquare_times r16 5) x_1001 in let r18 = S.qmul (qsquare_times r17 6) x_1011 in let r19 = S.qmul (qsquare_times r18 4) x_1101 in let r20 = S.qmul (qsquare_times r19 5) x_11 in let r21 = S.qmul (qsquare_times r20 6) x_1101 in let r22 = S.qmul (qsquare_times r21 10) x_1101 in let r23 = S.qmul (qsquare_times r22 4) x_1001 in r23 val qinv_r24_r25 (r23 x_1 x6: S.qelem) : S.qelem let qinv_r24_r25 r23 x_1 x6 = let r24 = S.qmul (qsquare_times r23 6) x_1 in let r25 = S.qmul (qsquare_times r24 8) x6 in r25 val qinv_r0_r25 (x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101: S.qelem) : S.qelem let qinv_r0_r25 x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101 = let x6 = S.qmul (qsquare_times x_1101 2) x_1011 in let x8 = S.qmul (qsquare_times x6 2) x_11 in let x14 = S.qmul (qsquare_times x8 6) x6 in let r1 = qinv_r0_r1 x14 in let r8 = qinv_r2_r8 r1 x_101 x_111 x_1011 in let r15 = qinv_r9_r15 r8 x_101 x_111 x_1001 x_1101 in let r23 = qinv_r16_r23 r15 x8 x_11 x_1001 x_1011 x_1101 in qinv_r24_r25 r23 x_1 x6 val qinv: f:S.qelem -> S.qelem let qinv f = let x_1 = f in let x_10 = qsquare_times f 1 in let x_11 = S.qmul x_10 x_1 in let x_101 = S.qmul x_10 x_11 in let x_111 = S.qmul x_10 x_101 in let x_1001 = S.qmul x_10 x_111 in let x_1011 = S.qmul x_10 x_1001 in let x_1101 = S.qmul x_10 x_1011 in qinv_r0_r25 x_1 x_11 x_101 x_111 x_1001 x_1011 x_1101 val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.q) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.q; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.q) val lemma_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.q) (M.pow f b % S.q) == M.pow f (a + b) % S.q) let lemma_pow_mod_mul f a b = calc (==) { S.qmul (M.pow f a % S.q) (M.pow f b % S.q); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.q) S.q; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.q } M.pow f a * M.pow f b % S.q; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.q; } val lemma_pow_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> c:nat -> Lemma (S.qmul (M.pow (M.pow f a % S.q) b % S.q) (M.pow f c % S.q) == M.pow f (a * b + c) % S.q) let lemma_pow_pow_mod_mul f a b c = calc (==) { S.qmul (M.pow (M.pow f a % S.q) b % S.q) (M.pow f c % S.q); (==) { M.lemma_pow_mod_base (M.pow f a) b S.q; Math.Lemmas.lemma_mod_mul_distr_l (M.pow (M.pow f a) b) (M.pow f c % S.q) S.q; Math.Lemmas.lemma_mod_mul_distr_r (M.pow (M.pow f a) b) (M.pow f c) S.q } M.pow (M.pow f a) b * M.pow f c % S.q; (==) { M.lemma_pow_mul f a b } M.pow f (a * b) * M.pow f c % S.q; (==) { M.lemma_pow_add f (a * b) c } M.pow f (a * b + c) % S.q; } // S.q - 2 = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413f
false
false
Hacl.Spec.K256.Qinv.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 qinv_lemma: f:S.qelem -> Lemma (qinv f == M.pow f (S.q - 2) % S.q)
[]
Hacl.Spec.K256.Qinv.qinv_lemma
{ "file_name": "code/k256/Hacl.Spec.K256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.K256.PointOps.qelem -> FStar.Pervasives.Lemma (ensures Hacl.Spec.K256.Qinv.qinv f == Lib.NatMod.pow f (Spec.K256.PointOps.q - 2) % Spec.K256.PointOps.q)
{ "end_col": 98, "end_line": 371, "start_col": 18, "start_line": 174 }
Prims.Tot
val bezout_prop (n l: nat) (b: bezout_t) : Tot prop
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l
val bezout_prop (n l: nat) (b: bezout_t) : Tot prop let bezout_prop (n l: nat) (b: bezout_t) : Tot prop =
false
null
false
bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "total" ]
[ "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout_t", "Steel.ST.GenArraySwap.Proof.bezout_prop'", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_l", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__u_n", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__u_l", "Prims.prop" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t)
false
true
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bezout_prop (n l: nat) (b: bezout_t) : Tot prop
[]
Steel.ST.GenArraySwap.Proof.bezout_prop
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.nat -> l: Prims.nat -> b: Steel.ST.GenArraySwap.Proof.bezout_t -> Prims.prop
{ "end_col": 46, "end_line": 98, "start_col": 2, "start_line": 98 }
Prims.Tot
val bezout_prop' (n l: nat) (d: pos) (q_n q_l: nat) (u_n u_l: int) : Tot prop
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l
val bezout_prop' (n l: nat) (d: pos) (q_n q_l: nat) (u_n u_l: int) : Tot prop let bezout_prop' (n l: nat) (d: pos) (q_n q_l: nat) (u_n u_l: int) : Tot prop =
false
null
false
n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "total" ]
[ "Prims.nat", "Prims.pos", "Prims.int", "Prims.l_and", "Prims.eq2", "FStar.Mul.op_Star", "Prims.op_Addition", "Prims.prop" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int)
false
true
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bezout_prop' (n l: nat) (d: pos) (q_n q_l: nat) (u_n u_l: int) : Tot prop
[]
Steel.ST.GenArraySwap.Proof.bezout_prop'
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.nat -> l: Prims.nat -> d: Prims.pos -> q_n: Prims.nat -> q_l: Prims.nat -> u_n: Prims.int -> u_l: Prims.int -> Prims.prop
{ "end_col": 24, "end_line": 91, "start_col": 2, "start_line": 89 }
FStar.Tactics.Effect.Tac
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed ()
let int_semiring () =
true
null
false
FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed ()
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[]
[ "Prims.unit", "FStar.Tactics.V1.Derived.qed", "FStar.Tactics.V1.Derived.trefl", "FStar.Tactics.CanonCommSemiring.int_semiring" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false"
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val int_semiring : _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
[]
Steel.ST.GenArraySwap.Proof.int_semiring
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit
{ "end_col": 22, "end_line": 68, "start_col": 2, "start_line": 66 }
Prims.Tot
val array_swap_post (#t: Type) (s0: Seq.seq t) (n l: nat) (s: Seq.seq t) : Tot prop
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let array_swap_post (#t: Type) (s0: Seq.seq t) (n: nat) (l: nat) (s: Seq.seq t) : Tot prop = n == Seq.length s0 /\ 0 <= l /\ l <= n /\ s `Seq.equal` (Seq.slice s0 l n `Seq.append` Seq.slice s0 0 l)
val array_swap_post (#t: Type) (s0: Seq.seq t) (n l: nat) (s: Seq.seq t) : Tot prop let array_swap_post (#t: Type) (s0: Seq.seq t) (n l: nat) (s: Seq.seq t) : Tot prop =
false
null
false
n == Seq.length s0 /\ 0 <= l /\ l <= n /\ s `Seq.equal` ((Seq.slice s0 l n) `Seq.append` (Seq.slice s0 0 l))
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Prims.nat", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.length", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.equal", "FStar.Seq.Base.append", "FStar.Seq.Base.slice", "Prims.prop" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n #restart-solver [@@"opaque_to_smt"] irreducible let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n )) = assert ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) by (int_semiring ()); assert (b.d == b.d * 1) by (int_semiring ()); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then begin lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); assert (kl * 1 == kl) by (int_semiring ()); kl end else begin assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); assert (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) by (int_semiring ()); assert (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) by (int_semiring ()); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); assert (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) by (int_semiring ()); assert (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) by (int_semiring ()); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); assert (kl * (1 + - (b.u_n * b.q_n)) == kl + - kl * b.u_n * b.q_n) by (int_semiring ()); assert (kl * b.u_n * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) by (int_semiring ()); kn * b.u_l + kl * b.u_n end let jump_iter_mod_q_inj_weak (n: pos) (l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires ( iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x )) (ensures ( b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n )) = jump_iter n l x k1; jump_iter n l x k2; let kn = mod_eq_elim n (x + k1 * l) (x + k2 * l) in assert ((k1 + - k2) * l == (k1 * l + - (k2 * l))) by (int_semiring ()); let kq = gauss n l b (k1 + - k2) kn in mod_eq_intro b.q_n k1 k2 kq let jump_iter_inj (n: nat) (l: nat) (b: bezout_t) (i1 i2: nat) (k1 k2: nat) : Lemma (requires ( n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2 )) (ensures ( i1 == i2 /\ k1 == k2 )) [SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b)] = jump_iter_mod_d n l b i1 k1; jump_iter_mod_d n l b i2 k2; small_mod i1 b.d; small_mod i2 b.d; jump_iter_mod_q_inj_weak n l b i1 k1 k2; small_mod k1 b.q_n; small_mod k2 b.q_n #restart-solver let jump_iter_elim (n: pos) (p: nat_up_to n -> prop) (l: nat) (b: bezout n l) : Lemma (requires ( forall (i: nat_up_to b.d) (k: nat_up_to b.q_n) . p (iter_fun (jump n l) k i) )) (ensures ( forall (x: nat_up_to n) . p x )) = let prf (x: nat_up_to n) : Lemma (p x) = let i : nat_up_to b.d = x % b.d in let k' = jump_coverage_strong n l b x in jump_coverage_strong_bound n l b x; assert (p (iter_fun (jump n l) k' i)) in Classical.forall_intro prf let jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma (jump n l idx == (if idx + l >= n then idx - (n - l) else idx + l)) = let idx' = (if idx + l >= n then idx - (n - l) else idx + l) in small_mod idx n; small_mod idx' n; lemma_mod_plus (idx + l) (-1) n let jump_iter_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (ensures ( iter_fun (jump n l) b.q_n x == x )) = cancel_mul_mod 1 b.q_n; jump_iter_mod_q n l b x b.q_n let rec iter_fun_add (#t: Type) (f: (t -> GTot t)) (n1 n2: nat) (x: t) : Lemma (ensures (iter_fun f n1 (iter_fun f n2 x) == iter_fun f (n1 + n2) x)) (decreases n2) = if n2 = 0 then () else iter_fun_add f n1 (n2 - 1) (f x) let iter_succ_l (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : Lemma (f (iter_fun f n x) == iter_fun f (n + 1) x) [SMTPat (f (iter_fun f n x))] = iter_fun_add f 1 n x let jump_jump_iter_pred_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (j: nat_up_to b.q_n) : Lemma (requires ( j == b.q_n - 1 )) (ensures ( jump n l (iter_fun (jump n l) j x) == x )) [SMTPat (jump n l (iter_fun (jump n l) j x)); SMTPat (bezout_prop n l b)] = jump_iter_q n l b x let array_swap_post (#t: Type) (s0: Seq.seq t) (n: nat) (l: nat) (s: Seq.seq t) : Tot prop
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val array_swap_post (#t: Type) (s0: Seq.seq t) (n l: nat) (s: Seq.seq t) : Tot prop
[]
Steel.ST.GenArraySwap.Proof.array_swap_post
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
s0: FStar.Seq.Base.seq t -> n: Prims.nat -> l: Prims.nat -> s: FStar.Seq.Base.seq t -> Prims.prop
{ "end_col": 66, "end_line": 605, "start_col": 4, "start_line": 602 }
Prims.GTot
val iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_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 iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x)
val iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) =
false
null
false
if n = 0 then x else iter_fun f (n - 1) (f x)
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "sometrivial", "" ]
[ "Prims.nat", "Prims.op_Equality", "Prims.int", "Prims.bool", "Steel.ST.GenArraySwap.Proof.iter_fun", "Prims.op_Subtraction" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n)
[ "recursion" ]
Steel.ST.GenArraySwap.Proof.iter_fun
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
f: (_: t -> Prims.GTot t) -> n: Prims.nat -> x: t -> Prims.GTot t
{ "end_col": 31, "end_line": 187, "start_col": 2, "start_line": 185 }
FStar.Pervasives.Lemma
val jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma (jump n l idx == (if idx + l >= n then idx - (n - l) else idx + l))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma (jump n l idx == (if idx + l >= n then idx - (n - l) else idx + l)) = let idx' = (if idx + l >= n then idx - (n - l) else idx + l) in small_mod idx n; small_mod idx' n; lemma_mod_plus (idx + l) (-1) n
val jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma (jump n l idx == (if idx + l >= n then idx - (n - l) else idx + l)) let jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma (jump n l idx == (if idx + l >= n then idx - (n - l) else idx + l)) =
false
null
true
let idx' = (if idx + l >= n then idx - (n - l) else idx + l) in small_mod idx n; small_mod idx' n; lemma_mod_plus (idx + l) (- 1) n
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Prims.squash", "Prims.b2t", "Prims.op_LessThan", "Steel.ST.GenArraySwap.Proof.nat_up_to", "FStar.Math.Lemmas.lemma_mod_plus", "Prims.op_Addition", "Prims.op_Minus", "Prims.unit", "FStar.Math.Lemmas.small_mod", "Prims.op_GreaterThanOrEqual", "Prims.op_Subtraction", "Prims.bool", "Prims.l_True", "Prims.eq2", "Prims.int", "Steel.ST.GenArraySwap.Proof.jump", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n #restart-solver [@@"opaque_to_smt"] irreducible let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n )) = assert ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) by (int_semiring ()); assert (b.d == b.d * 1) by (int_semiring ()); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then begin lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); assert (kl * 1 == kl) by (int_semiring ()); kl end else begin assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); assert (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) by (int_semiring ()); assert (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) by (int_semiring ()); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); assert (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) by (int_semiring ()); assert (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) by (int_semiring ()); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); assert (kl * (1 + - (b.u_n * b.q_n)) == kl + - kl * b.u_n * b.q_n) by (int_semiring ()); assert (kl * b.u_n * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) by (int_semiring ()); kn * b.u_l + kl * b.u_n end let jump_iter_mod_q_inj_weak (n: pos) (l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires ( iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x )) (ensures ( b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n )) = jump_iter n l x k1; jump_iter n l x k2; let kn = mod_eq_elim n (x + k1 * l) (x + k2 * l) in assert ((k1 + - k2) * l == (k1 * l + - (k2 * l))) by (int_semiring ()); let kq = gauss n l b (k1 + - k2) kn in mod_eq_intro b.q_n k1 k2 kq let jump_iter_inj (n: nat) (l: nat) (b: bezout_t) (i1 i2: nat) (k1 k2: nat) : Lemma (requires ( n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2 )) (ensures ( i1 == i2 /\ k1 == k2 )) [SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b)] = jump_iter_mod_d n l b i1 k1; jump_iter_mod_d n l b i2 k2; small_mod i1 b.d; small_mod i2 b.d; jump_iter_mod_q_inj_weak n l b i1 k1 k2; small_mod k1 b.q_n; small_mod k2 b.q_n #restart-solver let jump_iter_elim (n: pos) (p: nat_up_to n -> prop) (l: nat) (b: bezout n l) : Lemma (requires ( forall (i: nat_up_to b.d) (k: nat_up_to b.q_n) . p (iter_fun (jump n l) k i) )) (ensures ( forall (x: nat_up_to n) . p x )) = let prf (x: nat_up_to n) : Lemma (p x) = let i : nat_up_to b.d = x % b.d in let k' = jump_coverage_strong n l b x in jump_coverage_strong_bound n l b x; assert (p (iter_fun (jump n l) k' i)) in Classical.forall_intro prf let jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma (jump n l idx == (if idx + l >= n then idx - (n - l) else idx + l))
[]
Steel.ST.GenArraySwap.Proof.jump_if
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.nat -> sq: Prims.squash (l < n) -> idx: Steel.ST.GenArraySwap.Proof.nat_up_to n -> FStar.Pervasives.Lemma (ensures Steel.ST.GenArraySwap.Proof.jump n l idx == (match idx + l >= n with | true -> idx - (n - l) | _ -> idx + l))
{ "end_col": 33, "end_line": 542, "start_col": 1, "start_line": 539 }
FStar.Pervasives.Lemma
val bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)]
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d
val bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] =
false
null
true
lemma_pos_mul_pos_args b.q_n b.d
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "Steel.ST.GenArraySwap.Proof.lemma_pos_mul_pos_args", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.prop", "Steel.ST.GenArraySwap.Proof.bezout_prop", "Prims.Nil" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0)
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)]
[]
Steel.ST.GenArraySwap.Proof.bezout_pos_le
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.nat -> b: Steel.ST.GenArraySwap.Proof.bezout n l -> FStar.Pervasives.Lemma (ensures Mkbezout_t?.d b <= n /\ Mkbezout_t?.q_n b > 0) [SMTPat (Steel.ST.GenArraySwap.Proof.bezout_prop n l b)]
{ "end_col": 34, "end_line": 264, "start_col": 2, "start_line": 264 }
Prims.GTot
val jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n
val jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) =
false
null
false
(x + l) % n
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "sometrivial" ]
[ "Prims.pos", "Prims.nat", "Steel.ST.GenArraySwap.Proof.nat_up_to", "Prims.op_Modulus", "Prims.op_Addition" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n)
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n)
[]
Steel.ST.GenArraySwap.Proof.jump
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.nat -> x: Steel.ST.GenArraySwap.Proof.nat_up_to n -> Prims.GTot (Steel.ST.GenArraySwap.Proof.nat_up_to n)
{ "end_col": 13, "end_line": 196, "start_col": 2, "start_line": 196 }
Prims.Tot
val array_swap_outer_invariant (#t: Type0) (s0: Seq.seq t) (n l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i: nat) : Tot prop
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let array_swap_outer_invariant // hoisting necessary because "Let binding is effectful" (#t: Type0) (s0: Seq.seq t) (n: nat) (l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i: nat) : Tot prop = 0 < l /\ l < n /\ i <= bz.d /\ n == Seq.length s0 /\ n == Seq.length s /\ (forall (i': nat_up_to bz.d) . // this is always true, but I need it here for the pattern Seq.index s i' == Seq.index s (iter_fun #(nat_up_to (n)) (jump (n) (l)) 0 i') ) /\ (forall (i': nat_up_to bz.d) . (forall (j: nat_up_to bz.q_n) . let idx = iter_fun #(nat_up_to (n)) (jump (n) (l)) j i' in Seq.index s idx == Seq.index s0 (if i' < i then jump (n) (l) idx else idx) ))
val array_swap_outer_invariant (#t: Type0) (s0: Seq.seq t) (n l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i: nat) : Tot prop let array_swap_outer_invariant (#t: Type0) (s0: Seq.seq t) (n l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i: nat) : Tot prop =
false
null
false
0 < l /\ l < n /\ i <= bz.d /\ n == Seq.length s0 /\ n == Seq.length s /\ (forall (i': nat_up_to bz.d). Seq.index s i' == Seq.index s (iter_fun #(nat_up_to (n)) (jump (n) (l)) 0 i')) /\ (forall (i': nat_up_to bz.d). (forall (j: nat_up_to bz.q_n). let idx = iter_fun #(nat_up_to (n)) (jump (n) (l)) j i' in Seq.index s idx == Seq.index s0 (if i' < i then jump (n) (l) idx else idx)))
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.op_LessThanOrEqual", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Prims.eq2", "FStar.Seq.Base.length", "Prims.l_Forall", "Steel.ST.GenArraySwap.Proof.nat_up_to", "FStar.Seq.Base.index", "Steel.ST.GenArraySwap.Proof.iter_fun", "Steel.ST.GenArraySwap.Proof.jump", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Prims.bool", "Prims.prop" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n #restart-solver [@@"opaque_to_smt"] irreducible let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n )) = assert ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) by (int_semiring ()); assert (b.d == b.d * 1) by (int_semiring ()); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then begin lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); assert (kl * 1 == kl) by (int_semiring ()); kl end else begin assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); assert (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) by (int_semiring ()); assert (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) by (int_semiring ()); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); assert (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) by (int_semiring ()); assert (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) by (int_semiring ()); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); assert (kl * (1 + - (b.u_n * b.q_n)) == kl + - kl * b.u_n * b.q_n) by (int_semiring ()); assert (kl * b.u_n * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) by (int_semiring ()); kn * b.u_l + kl * b.u_n end let jump_iter_mod_q_inj_weak (n: pos) (l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires ( iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x )) (ensures ( b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n )) = jump_iter n l x k1; jump_iter n l x k2; let kn = mod_eq_elim n (x + k1 * l) (x + k2 * l) in assert ((k1 + - k2) * l == (k1 * l + - (k2 * l))) by (int_semiring ()); let kq = gauss n l b (k1 + - k2) kn in mod_eq_intro b.q_n k1 k2 kq let jump_iter_inj (n: nat) (l: nat) (b: bezout_t) (i1 i2: nat) (k1 k2: nat) : Lemma (requires ( n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2 )) (ensures ( i1 == i2 /\ k1 == k2 )) [SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b)] = jump_iter_mod_d n l b i1 k1; jump_iter_mod_d n l b i2 k2; small_mod i1 b.d; small_mod i2 b.d; jump_iter_mod_q_inj_weak n l b i1 k1 k2; small_mod k1 b.q_n; small_mod k2 b.q_n #restart-solver let jump_iter_elim (n: pos) (p: nat_up_to n -> prop) (l: nat) (b: bezout n l) : Lemma (requires ( forall (i: nat_up_to b.d) (k: nat_up_to b.q_n) . p (iter_fun (jump n l) k i) )) (ensures ( forall (x: nat_up_to n) . p x )) = let prf (x: nat_up_to n) : Lemma (p x) = let i : nat_up_to b.d = x % b.d in let k' = jump_coverage_strong n l b x in jump_coverage_strong_bound n l b x; assert (p (iter_fun (jump n l) k' i)) in Classical.forall_intro prf let jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma (jump n l idx == (if idx + l >= n then idx - (n - l) else idx + l)) = let idx' = (if idx + l >= n then idx - (n - l) else idx + l) in small_mod idx n; small_mod idx' n; lemma_mod_plus (idx + l) (-1) n let jump_iter_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (ensures ( iter_fun (jump n l) b.q_n x == x )) = cancel_mul_mod 1 b.q_n; jump_iter_mod_q n l b x b.q_n let rec iter_fun_add (#t: Type) (f: (t -> GTot t)) (n1 n2: nat) (x: t) : Lemma (ensures (iter_fun f n1 (iter_fun f n2 x) == iter_fun f (n1 + n2) x)) (decreases n2) = if n2 = 0 then () else iter_fun_add f n1 (n2 - 1) (f x) let iter_succ_l (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : Lemma (f (iter_fun f n x) == iter_fun f (n + 1) x) [SMTPat (f (iter_fun f n x))] = iter_fun_add f 1 n x let jump_jump_iter_pred_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (j: nat_up_to b.q_n) : Lemma (requires ( j == b.q_n - 1 )) (ensures ( jump n l (iter_fun (jump n l) j x) == x )) [SMTPat (jump n l (iter_fun (jump n l) j x)); SMTPat (bezout_prop n l b)] = jump_iter_q n l b x let array_swap_post (#t: Type) (s0: Seq.seq t) (n: nat) (l: nat) (s: Seq.seq t) : Tot prop = n == Seq.length s0 /\ 0 <= l /\ l <= n /\ s `Seq.equal` (Seq.slice s0 l n `Seq.append` Seq.slice s0 0 l) let array_as_ring_buffer_swap (#t: Type) (n: nat) (l: nat) (bz: bezout n l) (s0: Seq.seq t) (s: Seq.seq t) : Lemma (requires ( n == Seq.length s0 /\ n == Seq.length s /\ 0 < l /\ l < n /\ (forall (i': nat_up_to bz.d) . (forall (j: nat_up_to bz.q_n) . (i' < bz.d) ==> ( let idx = iter_fun #(nat_up_to n) (jump n l) j i' in Seq.index s idx == Seq.index s0 (jump n l idx) ))) )) (ensures ( array_swap_post s0 n l s )) [SMTPat (array_swap_post s0 n l s); SMTPat (bezout_prop n l bz)] = Classical.forall_intro (jump_if n l ()); let p (idx: nat_up_to n) : Tot prop = Seq.index s idx == Seq.index s0 (jump n l idx) in jump_iter_elim n p l bz let array_swap_outer_invariant // hoisting necessary because "Let binding is effectful" (#t: Type0) (s0: Seq.seq t) (n: nat) (l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i: nat)
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val array_swap_outer_invariant (#t: Type0) (s0: Seq.seq t) (n l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i: nat) : Tot prop
[]
Steel.ST.GenArraySwap.Proof.array_swap_outer_invariant
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
s0: FStar.Seq.Base.seq t -> n: Prims.nat -> l: Prims.nat -> bz: Steel.ST.GenArraySwap.Proof.bezout n l -> s: FStar.Seq.Base.seq t -> i: Prims.nat -> Prims.prop
{ "end_col": 4, "end_line": 655, "start_col": 2, "start_line": 643 }
Prims.Ghost
val minimal_exists' (p: (nat -> GTot bool)) (n i: nat) : Ghost nat (requires (p n == true /\ i <= n /\ (forall (j: nat). j < i ==> p j == false))) (ensures (fun k -> p k == true /\ (forall (j: nat). j < k ==> p j == false))) (decreases (n - i))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_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 minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1)
val minimal_exists' (p: (nat -> GTot bool)) (n i: nat) : Ghost nat (requires (p n == true /\ i <= n /\ (forall (j: nat). j < i ==> p j == false))) (ensures (fun k -> p k == true /\ (forall (j: nat). j < k ==> p j == false))) (decreases (n - i)) let rec minimal_exists' (p: (nat -> GTot bool)) (n i: nat) : Ghost nat (requires (p n == true /\ i <= n /\ (forall (j: nat). j < i ==> p j == false))) (ensures (fun k -> p k == true /\ (forall (j: nat). j < k ==> p j == false))) (decreases (n - i)) =
false
null
false
if p i then i else minimal_exists' p n (i + 1)
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "" ]
[ "Prims.nat", "Prims.bool", "Steel.ST.GenArraySwap.Proof.minimal_exists'", "Prims.op_Addition", "Prims.l_and", "Prims.eq2", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.l_Forall", "Prims.l_imp", "Prims.op_LessThan" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) ))
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val minimal_exists' (p: (nat -> GTot bool)) (n i: nat) : Ghost nat (requires (p n == true /\ i <= n /\ (forall (j: nat). j < i ==> p j == false))) (ensures (fun k -> p k == true /\ (forall (j: nat). j < k ==> p j == false))) (decreases (n - i))
[ "recursion" ]
Steel.ST.GenArraySwap.Proof.minimal_exists'
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: (_: Prims.nat -> Prims.GTot Prims.bool) -> n: Prims.nat -> i: Prims.nat -> Prims.Ghost Prims.nat
{ "end_col": 34, "end_line": 318, "start_col": 2, "start_line": 316 }
Prims.Tot
val array_swap_inner_invariant (#t: Type0) (s0: Seq.seq t) (n l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i j idx: nat) : Tot prop
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let array_swap_inner_invariant (#t: Type0) (s0: Seq.seq t) (n: nat) (l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i: nat) (j: nat) (idx: nat) : Tot prop = 0 < l /\ l < n /\ n == Seq.length s0 /\ i < bz.d /\ j < bz.q_n /\ idx == iter_fun #(nat_up_to (n)) (jump (n) (l)) (j) (i) /\ n == Seq.length s /\ (forall (i': nat_up_to bz.d) . (forall (j': nat_up_to bz.q_n) . let idx = iter_fun #(nat_up_to (n)) (jump (n) (l)) j' i' in Seq.index s idx == Seq.index s0 (if i' < i || (i' = i && j' < j) then jump (n) (l) idx else idx) ))
val array_swap_inner_invariant (#t: Type0) (s0: Seq.seq t) (n l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i j idx: nat) : Tot prop let array_swap_inner_invariant (#t: Type0) (s0: Seq.seq t) (n l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i j idx: nat) : Tot prop =
false
null
false
0 < l /\ l < n /\ n == Seq.length s0 /\ i < bz.d /\ j < bz.q_n /\ idx == iter_fun #(nat_up_to (n)) (jump (n) (l)) (j) (i) /\ n == Seq.length s /\ (forall (i': nat_up_to bz.d). (forall (j': nat_up_to bz.q_n). let idx = iter_fun #(nat_up_to (n)) (jump (n) (l)) j' i' in Seq.index s idx == Seq.index s0 (if i' < i || (i' = i && j' < j) then jump (n) (l) idx else idx)))
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Prims.eq2", "FStar.Seq.Base.length", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Steel.ST.GenArraySwap.Proof.iter_fun", "Steel.ST.GenArraySwap.Proof.nat_up_to", "Steel.ST.GenArraySwap.Proof.jump", "Prims.l_Forall", "FStar.Seq.Base.index", "Prims.op_BarBar", "Prims.op_AmpAmp", "Prims.op_Equality", "Prims.bool", "Prims.prop" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n #restart-solver [@@"opaque_to_smt"] irreducible let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n )) = assert ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) by (int_semiring ()); assert (b.d == b.d * 1) by (int_semiring ()); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then begin lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); assert (kl * 1 == kl) by (int_semiring ()); kl end else begin assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); assert (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) by (int_semiring ()); assert (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) by (int_semiring ()); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); assert (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) by (int_semiring ()); assert (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) by (int_semiring ()); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); assert (kl * (1 + - (b.u_n * b.q_n)) == kl + - kl * b.u_n * b.q_n) by (int_semiring ()); assert (kl * b.u_n * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) by (int_semiring ()); kn * b.u_l + kl * b.u_n end let jump_iter_mod_q_inj_weak (n: pos) (l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires ( iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x )) (ensures ( b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n )) = jump_iter n l x k1; jump_iter n l x k2; let kn = mod_eq_elim n (x + k1 * l) (x + k2 * l) in assert ((k1 + - k2) * l == (k1 * l + - (k2 * l))) by (int_semiring ()); let kq = gauss n l b (k1 + - k2) kn in mod_eq_intro b.q_n k1 k2 kq let jump_iter_inj (n: nat) (l: nat) (b: bezout_t) (i1 i2: nat) (k1 k2: nat) : Lemma (requires ( n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2 )) (ensures ( i1 == i2 /\ k1 == k2 )) [SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b)] = jump_iter_mod_d n l b i1 k1; jump_iter_mod_d n l b i2 k2; small_mod i1 b.d; small_mod i2 b.d; jump_iter_mod_q_inj_weak n l b i1 k1 k2; small_mod k1 b.q_n; small_mod k2 b.q_n #restart-solver let jump_iter_elim (n: pos) (p: nat_up_to n -> prop) (l: nat) (b: bezout n l) : Lemma (requires ( forall (i: nat_up_to b.d) (k: nat_up_to b.q_n) . p (iter_fun (jump n l) k i) )) (ensures ( forall (x: nat_up_to n) . p x )) = let prf (x: nat_up_to n) : Lemma (p x) = let i : nat_up_to b.d = x % b.d in let k' = jump_coverage_strong n l b x in jump_coverage_strong_bound n l b x; assert (p (iter_fun (jump n l) k' i)) in Classical.forall_intro prf let jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma (jump n l idx == (if idx + l >= n then idx - (n - l) else idx + l)) = let idx' = (if idx + l >= n then idx - (n - l) else idx + l) in small_mod idx n; small_mod idx' n; lemma_mod_plus (idx + l) (-1) n let jump_iter_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (ensures ( iter_fun (jump n l) b.q_n x == x )) = cancel_mul_mod 1 b.q_n; jump_iter_mod_q n l b x b.q_n let rec iter_fun_add (#t: Type) (f: (t -> GTot t)) (n1 n2: nat) (x: t) : Lemma (ensures (iter_fun f n1 (iter_fun f n2 x) == iter_fun f (n1 + n2) x)) (decreases n2) = if n2 = 0 then () else iter_fun_add f n1 (n2 - 1) (f x) let iter_succ_l (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : Lemma (f (iter_fun f n x) == iter_fun f (n + 1) x) [SMTPat (f (iter_fun f n x))] = iter_fun_add f 1 n x let jump_jump_iter_pred_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (j: nat_up_to b.q_n) : Lemma (requires ( j == b.q_n - 1 )) (ensures ( jump n l (iter_fun (jump n l) j x) == x )) [SMTPat (jump n l (iter_fun (jump n l) j x)); SMTPat (bezout_prop n l b)] = jump_iter_q n l b x let array_swap_post (#t: Type) (s0: Seq.seq t) (n: nat) (l: nat) (s: Seq.seq t) : Tot prop = n == Seq.length s0 /\ 0 <= l /\ l <= n /\ s `Seq.equal` (Seq.slice s0 l n `Seq.append` Seq.slice s0 0 l) let array_as_ring_buffer_swap (#t: Type) (n: nat) (l: nat) (bz: bezout n l) (s0: Seq.seq t) (s: Seq.seq t) : Lemma (requires ( n == Seq.length s0 /\ n == Seq.length s /\ 0 < l /\ l < n /\ (forall (i': nat_up_to bz.d) . (forall (j: nat_up_to bz.q_n) . (i' < bz.d) ==> ( let idx = iter_fun #(nat_up_to n) (jump n l) j i' in Seq.index s idx == Seq.index s0 (jump n l idx) ))) )) (ensures ( array_swap_post s0 n l s )) [SMTPat (array_swap_post s0 n l s); SMTPat (bezout_prop n l bz)] = Classical.forall_intro (jump_if n l ()); let p (idx: nat_up_to n) : Tot prop = Seq.index s idx == Seq.index s0 (jump n l idx) in jump_iter_elim n p l bz let array_swap_outer_invariant // hoisting necessary because "Let binding is effectful" (#t: Type0) (s0: Seq.seq t) (n: nat) (l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i: nat) : Tot prop = 0 < l /\ l < n /\ i <= bz.d /\ n == Seq.length s0 /\ n == Seq.length s /\ (forall (i': nat_up_to bz.d) . // this is always true, but I need it here for the pattern Seq.index s i' == Seq.index s (iter_fun #(nat_up_to (n)) (jump (n) (l)) 0 i') ) /\ (forall (i': nat_up_to bz.d) . (forall (j: nat_up_to bz.q_n) . let idx = iter_fun #(nat_up_to (n)) (jump (n) (l)) j i' in Seq.index s idx == Seq.index s0 (if i' < i then jump (n) (l) idx else idx) )) let array_swap_inner_invariant (#t: Type0) (s0: Seq.seq t) (n: nat) (l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i: nat) (j: nat) (idx: nat)
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val array_swap_inner_invariant (#t: Type0) (s0: Seq.seq t) (n l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i j idx: nat) : Tot prop
[]
Steel.ST.GenArraySwap.Proof.array_swap_inner_invariant
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
s0: FStar.Seq.Base.seq t -> n: Prims.nat -> l: Prims.nat -> bz: Steel.ST.GenArraySwap.Proof.bezout n l -> s: FStar.Seq.Base.seq t -> i: Prims.nat -> j: Prims.nat -> idx: Prims.nat -> Prims.prop
{ "end_col": 4, "end_line": 672, "start_col": 2, "start_line": 661 }
Prims.Ghost
val minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires (p n == true)) (ensures (fun k -> p k == true /\ (forall (j: nat). j < k ==> p j == false)))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0
val minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires (p n == true)) (ensures (fun k -> p k == true /\ (forall (j: nat). j < k ==> p j == false))) let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires (p n == true)) (ensures (fun k -> p k == true /\ (forall (j: nat). j < k ==> p j == false))) =
false
null
false
minimal_exists' p n 0
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[]
[ "Prims.nat", "Prims.bool", "Steel.ST.GenArraySwap.Proof.minimal_exists'", "Prims.eq2", "Prims.l_and", "Prims.l_Forall", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false)
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires (p n == true)) (ensures (fun k -> p k == true /\ (forall (j: nat). j < k ==> p j == false)))
[]
Steel.ST.GenArraySwap.Proof.minimal_exists
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
p: (_: Prims.nat -> Prims.GTot Prims.bool) -> n: Prims.nat -> Prims.Ghost Prims.nat
{ "end_col": 23, "end_line": 333, "start_col": 2, "start_line": 333 }
FStar.Pervasives.Lemma
val mod_eq_intro (n: pos) (x1 x2 k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n
val mod_eq_intro (n: pos) (x1 x2 k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) let mod_eq_intro (n: pos) (x1 x2 k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) =
false
null
true
lemma_mod_plus x2 k n
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.int", "FStar.Math.Lemmas.lemma_mod_plus", "Prims.unit", "Prims.eq2", "Prims.op_Subtraction", "FStar.Mul.op_Star", "Prims.squash", "Prims.op_Modulus", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n))
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mod_eq_intro (n: pos) (x1 x2 k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n))
[]
Steel.ST.GenArraySwap.Proof.mod_eq_intro
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> x1: Prims.int -> x2: Prims.int -> k: Prims.int -> FStar.Pervasives.Lemma (requires x1 - x2 == k * n) (ensures x1 % n == x2 % n)
{ "end_col": 23, "end_line": 412, "start_col": 2, "start_line": 412 }
FStar.Pervasives.Lemma
val bezout_q_eq (n l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n]
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d
val bezout_q_eq (n l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] let bezout_q_eq (n l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] =
false
null
true
cancel_mul_div bz.q_n bz.d
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "FStar.Math.Lemmas.cancel_mul_div", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.int", "Prims.op_Division", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.prop", "Steel.ST.GenArraySwap.Proof.bezout_prop", "Prims.Nil" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d)
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val bezout_q_eq (n l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n]
[]
Steel.ST.GenArraySwap.Proof.bezout_q_eq
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.nat -> l: Prims.nat -> bz: Steel.ST.GenArraySwap.Proof.bezout n l -> FStar.Pervasives.Lemma (ensures Mkbezout_t?.q_n bz == n / Mkbezout_t?.d bz) [SMTPat (Steel.ST.GenArraySwap.Proof.bezout_prop n l bz); SMTPat (Mkbezout_t?.q_n bz)]
{ "end_col": 28, "end_line": 176, "start_col": 2, "start_line": 176 }
FStar.Pervasives.Lemma
val iter_succ_l (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : Lemma (f (iter_fun f n x) == iter_fun f (n + 1) x) [SMTPat (f (iter_fun f n x))]
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let iter_succ_l (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : Lemma (f (iter_fun f n x) == iter_fun f (n + 1) x) [SMTPat (f (iter_fun f n x))] = iter_fun_add f 1 n x
val iter_succ_l (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : Lemma (f (iter_fun f n x) == iter_fun f (n + 1) x) [SMTPat (f (iter_fun f n x))] let iter_succ_l (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : Lemma (f (iter_fun f n x) == iter_fun f (n + 1) x) [SMTPat (f (iter_fun f n x))] =
false
null
true
iter_fun_add f 1 n x
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "Prims.nat", "Steel.ST.GenArraySwap.Proof.iter_fun_add", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Steel.ST.GenArraySwap.Proof.iter_fun", "Prims.op_Addition", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n #restart-solver [@@"opaque_to_smt"] irreducible let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n )) = assert ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) by (int_semiring ()); assert (b.d == b.d * 1) by (int_semiring ()); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then begin lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); assert (kl * 1 == kl) by (int_semiring ()); kl end else begin assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); assert (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) by (int_semiring ()); assert (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) by (int_semiring ()); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); assert (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) by (int_semiring ()); assert (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) by (int_semiring ()); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); assert (kl * (1 + - (b.u_n * b.q_n)) == kl + - kl * b.u_n * b.q_n) by (int_semiring ()); assert (kl * b.u_n * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) by (int_semiring ()); kn * b.u_l + kl * b.u_n end let jump_iter_mod_q_inj_weak (n: pos) (l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires ( iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x )) (ensures ( b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n )) = jump_iter n l x k1; jump_iter n l x k2; let kn = mod_eq_elim n (x + k1 * l) (x + k2 * l) in assert ((k1 + - k2) * l == (k1 * l + - (k2 * l))) by (int_semiring ()); let kq = gauss n l b (k1 + - k2) kn in mod_eq_intro b.q_n k1 k2 kq let jump_iter_inj (n: nat) (l: nat) (b: bezout_t) (i1 i2: nat) (k1 k2: nat) : Lemma (requires ( n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2 )) (ensures ( i1 == i2 /\ k1 == k2 )) [SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b)] = jump_iter_mod_d n l b i1 k1; jump_iter_mod_d n l b i2 k2; small_mod i1 b.d; small_mod i2 b.d; jump_iter_mod_q_inj_weak n l b i1 k1 k2; small_mod k1 b.q_n; small_mod k2 b.q_n #restart-solver let jump_iter_elim (n: pos) (p: nat_up_to n -> prop) (l: nat) (b: bezout n l) : Lemma (requires ( forall (i: nat_up_to b.d) (k: nat_up_to b.q_n) . p (iter_fun (jump n l) k i) )) (ensures ( forall (x: nat_up_to n) . p x )) = let prf (x: nat_up_to n) : Lemma (p x) = let i : nat_up_to b.d = x % b.d in let k' = jump_coverage_strong n l b x in jump_coverage_strong_bound n l b x; assert (p (iter_fun (jump n l) k' i)) in Classical.forall_intro prf let jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma (jump n l idx == (if idx + l >= n then idx - (n - l) else idx + l)) = let idx' = (if idx + l >= n then idx - (n - l) else idx + l) in small_mod idx n; small_mod idx' n; lemma_mod_plus (idx + l) (-1) n let jump_iter_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (ensures ( iter_fun (jump n l) b.q_n x == x )) = cancel_mul_mod 1 b.q_n; jump_iter_mod_q n l b x b.q_n let rec iter_fun_add (#t: Type) (f: (t -> GTot t)) (n1 n2: nat) (x: t) : Lemma (ensures (iter_fun f n1 (iter_fun f n2 x) == iter_fun f (n1 + n2) x)) (decreases n2) = if n2 = 0 then () else iter_fun_add f n1 (n2 - 1) (f x) let iter_succ_l (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : Lemma (f (iter_fun f n x) == iter_fun f (n + 1) x)
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val iter_succ_l (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : Lemma (f (iter_fun f n x) == iter_fun f (n + 1) x) [SMTPat (f (iter_fun f n x))]
[]
Steel.ST.GenArraySwap.Proof.iter_succ_l
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
f: (_: t -> Prims.GTot t) -> n: Prims.nat -> x: t -> FStar.Pervasives.Lemma (ensures f (Steel.ST.GenArraySwap.Proof.iter_fun f n x) == Steel.ST.GenArraySwap.Proof.iter_fun f (n + 1) x) [SMTPat (f (Steel.ST.GenArraySwap.Proof.iter_fun f n x))]
{ "end_col": 22, "end_line": 576, "start_col": 2, "start_line": 576 }
FStar.Pervasives.Lemma
val sz_rem_spec (n l: SZ.t) : Lemma (requires (SZ.v l > 0)) (ensures (SZ.v (SZ.rem n l) == SZ.v n % SZ.v l)) [SMTPat (SZ.rem n l)]
[ { "abbrev": true, "full_module": "FStar.SizeT", "short_module": "SZ" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sz_rem_spec (n: SZ.t) (l: SZ.t) : Lemma (requires (SZ.v l > 0)) (ensures (SZ.v (SZ.rem n l) == SZ.v n % SZ.v l)) [SMTPat (SZ.rem n l)] = euclidean_division_definition (SZ.v n) (SZ.v l)
val sz_rem_spec (n l: SZ.t) : Lemma (requires (SZ.v l > 0)) (ensures (SZ.v (SZ.rem n l) == SZ.v n % SZ.v l)) [SMTPat (SZ.rem n l)] let sz_rem_spec (n l: SZ.t) : Lemma (requires (SZ.v l > 0)) (ensures (SZ.v (SZ.rem n l) == SZ.v n % SZ.v l)) [SMTPat (SZ.rem n l)] =
false
null
true
euclidean_division_definition (SZ.v n) (SZ.v l)
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "FStar.SizeT.t", "FStar.Math.Lemmas.euclidean_division_definition", "FStar.SizeT.v", "Prims.unit", "Prims.b2t", "Prims.op_GreaterThan", "Prims.squash", "Prims.eq2", "Prims.int", "FStar.SizeT.rem", "Prims.op_Modulus", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n #restart-solver [@@"opaque_to_smt"] irreducible let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n )) = assert ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) by (int_semiring ()); assert (b.d == b.d * 1) by (int_semiring ()); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then begin lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); assert (kl * 1 == kl) by (int_semiring ()); kl end else begin assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); assert (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) by (int_semiring ()); assert (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) by (int_semiring ()); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); assert (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) by (int_semiring ()); assert (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) by (int_semiring ()); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); assert (kl * (1 + - (b.u_n * b.q_n)) == kl + - kl * b.u_n * b.q_n) by (int_semiring ()); assert (kl * b.u_n * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) by (int_semiring ()); kn * b.u_l + kl * b.u_n end let jump_iter_mod_q_inj_weak (n: pos) (l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires ( iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x )) (ensures ( b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n )) = jump_iter n l x k1; jump_iter n l x k2; let kn = mod_eq_elim n (x + k1 * l) (x + k2 * l) in assert ((k1 + - k2) * l == (k1 * l + - (k2 * l))) by (int_semiring ()); let kq = gauss n l b (k1 + - k2) kn in mod_eq_intro b.q_n k1 k2 kq let jump_iter_inj (n: nat) (l: nat) (b: bezout_t) (i1 i2: nat) (k1 k2: nat) : Lemma (requires ( n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2 )) (ensures ( i1 == i2 /\ k1 == k2 )) [SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b)] = jump_iter_mod_d n l b i1 k1; jump_iter_mod_d n l b i2 k2; small_mod i1 b.d; small_mod i2 b.d; jump_iter_mod_q_inj_weak n l b i1 k1 k2; small_mod k1 b.q_n; small_mod k2 b.q_n #restart-solver let jump_iter_elim (n: pos) (p: nat_up_to n -> prop) (l: nat) (b: bezout n l) : Lemma (requires ( forall (i: nat_up_to b.d) (k: nat_up_to b.q_n) . p (iter_fun (jump n l) k i) )) (ensures ( forall (x: nat_up_to n) . p x )) = let prf (x: nat_up_to n) : Lemma (p x) = let i : nat_up_to b.d = x % b.d in let k' = jump_coverage_strong n l b x in jump_coverage_strong_bound n l b x; assert (p (iter_fun (jump n l) k' i)) in Classical.forall_intro prf let jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma (jump n l idx == (if idx + l >= n then idx - (n - l) else idx + l)) = let idx' = (if idx + l >= n then idx - (n - l) else idx + l) in small_mod idx n; small_mod idx' n; lemma_mod_plus (idx + l) (-1) n let jump_iter_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (ensures ( iter_fun (jump n l) b.q_n x == x )) = cancel_mul_mod 1 b.q_n; jump_iter_mod_q n l b x b.q_n let rec iter_fun_add (#t: Type) (f: (t -> GTot t)) (n1 n2: nat) (x: t) : Lemma (ensures (iter_fun f n1 (iter_fun f n2 x) == iter_fun f (n1 + n2) x)) (decreases n2) = if n2 = 0 then () else iter_fun_add f n1 (n2 - 1) (f x) let iter_succ_l (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : Lemma (f (iter_fun f n x) == iter_fun f (n + 1) x) [SMTPat (f (iter_fun f n x))] = iter_fun_add f 1 n x let jump_jump_iter_pred_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (j: nat_up_to b.q_n) : Lemma (requires ( j == b.q_n - 1 )) (ensures ( jump n l (iter_fun (jump n l) j x) == x )) [SMTPat (jump n l (iter_fun (jump n l) j x)); SMTPat (bezout_prop n l b)] = jump_iter_q n l b x let array_swap_post (#t: Type) (s0: Seq.seq t) (n: nat) (l: nat) (s: Seq.seq t) : Tot prop = n == Seq.length s0 /\ 0 <= l /\ l <= n /\ s `Seq.equal` (Seq.slice s0 l n `Seq.append` Seq.slice s0 0 l) let array_as_ring_buffer_swap (#t: Type) (n: nat) (l: nat) (bz: bezout n l) (s0: Seq.seq t) (s: Seq.seq t) : Lemma (requires ( n == Seq.length s0 /\ n == Seq.length s /\ 0 < l /\ l < n /\ (forall (i': nat_up_to bz.d) . (forall (j: nat_up_to bz.q_n) . (i' < bz.d) ==> ( let idx = iter_fun #(nat_up_to n) (jump n l) j i' in Seq.index s idx == Seq.index s0 (jump n l idx) ))) )) (ensures ( array_swap_post s0 n l s )) [SMTPat (array_swap_post s0 n l s); SMTPat (bezout_prop n l bz)] = Classical.forall_intro (jump_if n l ()); let p (idx: nat_up_to n) : Tot prop = Seq.index s idx == Seq.index s0 (jump n l idx) in jump_iter_elim n p l bz let array_swap_outer_invariant // hoisting necessary because "Let binding is effectful" (#t: Type0) (s0: Seq.seq t) (n: nat) (l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i: nat) : Tot prop = 0 < l /\ l < n /\ i <= bz.d /\ n == Seq.length s0 /\ n == Seq.length s /\ (forall (i': nat_up_to bz.d) . // this is always true, but I need it here for the pattern Seq.index s i' == Seq.index s (iter_fun #(nat_up_to (n)) (jump (n) (l)) 0 i') ) /\ (forall (i': nat_up_to bz.d) . (forall (j: nat_up_to bz.q_n) . let idx = iter_fun #(nat_up_to (n)) (jump (n) (l)) j i' in Seq.index s idx == Seq.index s0 (if i' < i then jump (n) (l) idx else idx) )) let array_swap_inner_invariant (#t: Type0) (s0: Seq.seq t) (n: nat) (l: nat) (bz: bezout (n) (l)) (s: Seq.seq t) (i: nat) (j: nat) (idx: nat) : Tot prop = 0 < l /\ l < n /\ n == Seq.length s0 /\ i < bz.d /\ j < bz.q_n /\ idx == iter_fun #(nat_up_to (n)) (jump (n) (l)) (j) (i) /\ n == Seq.length s /\ (forall (i': nat_up_to bz.d) . (forall (j': nat_up_to bz.q_n) . let idx = iter_fun #(nat_up_to (n)) (jump (n) (l)) j' i' in Seq.index s idx == Seq.index s0 (if i' < i || (i' = i && j' < j) then jump (n) (l) idx else idx) )) let array_swap_inner_invariant_end (#t: Type) (n: nat) (l: nat) (bz: bezout (n) (l)) (s0: Seq.seq t) (s: Seq.seq t) (i: nat) (j: nat) (idx: nat) : Lemma (requires ( array_swap_inner_invariant s0 n l bz s i j idx /\ (~ (j < bz.q_n - 1)) )) (ensures ( let s' = Seq.upd s idx (Seq.index s0 i) in array_swap_outer_invariant s0 n l bz s' (i + 1) )) // [SMTPat (array_swap_inner_invariant s0 n l bz s i j idx)] = () module SZ = FStar.SizeT let sz_rem_spec (n: SZ.t) (l: SZ.t) : Lemma (requires (SZ.v l > 0)) (ensures (SZ.v (SZ.rem n l) == SZ.v n % SZ.v l))
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sz_rem_spec (n l: SZ.t) : Lemma (requires (SZ.v l > 0)) (ensures (SZ.v (SZ.rem n l) == SZ.v n % SZ.v l)) [SMTPat (SZ.rem n l)]
[]
Steel.ST.GenArraySwap.Proof.sz_rem_spec
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: FStar.SizeT.t -> l: FStar.SizeT.t -> FStar.Pervasives.Lemma (requires FStar.SizeT.v l > 0) (ensures FStar.SizeT.v (FStar.SizeT.rem n l) == FStar.SizeT.v n % FStar.SizeT.v l) [SMTPat (FStar.SizeT.rem n l)]
{ "end_col": 49, "end_line": 705, "start_col": 2, "start_line": 705 }
FStar.Pervasives.Lemma
val jump_iter_inj (n l: nat) (b: bezout_t) (i1 i2 k1 k2: nat) : Lemma (requires (n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2)) (ensures (i1 == i2 /\ k1 == k2)) [ SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b) ]
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let jump_iter_inj (n: nat) (l: nat) (b: bezout_t) (i1 i2: nat) (k1 k2: nat) : Lemma (requires ( n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2 )) (ensures ( i1 == i2 /\ k1 == k2 )) [SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b)] = jump_iter_mod_d n l b i1 k1; jump_iter_mod_d n l b i2 k2; small_mod i1 b.d; small_mod i2 b.d; jump_iter_mod_q_inj_weak n l b i1 k1 k2; small_mod k1 b.q_n; small_mod k2 b.q_n
val jump_iter_inj (n l: nat) (b: bezout_t) (i1 i2 k1 k2: nat) : Lemma (requires (n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2)) (ensures (i1 == i2 /\ k1 == k2)) [ SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b) ] let jump_iter_inj (n l: nat) (b: bezout_t) (i1 i2 k1 k2: nat) : Lemma (requires (n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2)) (ensures (i1 == i2 /\ k1 == k2)) [ SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b) ] =
false
null
true
jump_iter_mod_d n l b i1 k1; jump_iter_mod_d n l b i2 k2; small_mod i1 b.d; small_mod i2 b.d; jump_iter_mod_q_inj_weak n l b i1 k1 k2; small_mod k1 b.q_n; small_mod k2 b.q_n
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout_t", "FStar.Math.Lemmas.small_mod", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Prims.unit", "Steel.ST.GenArraySwap.Proof.jump_iter_mod_q_inj_weak", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Steel.ST.GenArraySwap.Proof.jump_iter_mod_d", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Steel.ST.GenArraySwap.Proof.bezout_prop", "Prims.op_LessThan", "Prims.eq2", "Steel.ST.GenArraySwap.Proof.nat_up_to", "Steel.ST.GenArraySwap.Proof.iter_fun", "Steel.ST.GenArraySwap.Proof.jump", "Prims.squash", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.prop", "Prims.Nil" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n #restart-solver [@@"opaque_to_smt"] irreducible let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n )) = assert ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) by (int_semiring ()); assert (b.d == b.d * 1) by (int_semiring ()); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then begin lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); assert (kl * 1 == kl) by (int_semiring ()); kl end else begin assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); assert (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) by (int_semiring ()); assert (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) by (int_semiring ()); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); assert (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) by (int_semiring ()); assert (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) by (int_semiring ()); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); assert (kl * (1 + - (b.u_n * b.q_n)) == kl + - kl * b.u_n * b.q_n) by (int_semiring ()); assert (kl * b.u_n * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) by (int_semiring ()); kn * b.u_l + kl * b.u_n end let jump_iter_mod_q_inj_weak (n: pos) (l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires ( iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x )) (ensures ( b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n )) = jump_iter n l x k1; jump_iter n l x k2; let kn = mod_eq_elim n (x + k1 * l) (x + k2 * l) in assert ((k1 + - k2) * l == (k1 * l + - (k2 * l))) by (int_semiring ()); let kq = gauss n l b (k1 + - k2) kn in mod_eq_intro b.q_n k1 k2 kq let jump_iter_inj (n: nat) (l: nat) (b: bezout_t) (i1 i2: nat) (k1 k2: nat) : Lemma (requires ( n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2 )) (ensures ( i1 == i2 /\ k1 == k2 ))
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_iter_inj (n l: nat) (b: bezout_t) (i1 i2 k1 k2: nat) : Lemma (requires (n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2)) (ensures (i1 == i2 /\ k1 == k2)) [ SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b) ]
[]
Steel.ST.GenArraySwap.Proof.jump_iter_inj
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.nat -> l: Prims.nat -> b: Steel.ST.GenArraySwap.Proof.bezout_t -> i1: Prims.nat -> i2: Prims.nat -> k1: Prims.nat -> k2: Prims.nat -> FStar.Pervasives.Lemma (requires n > 0 /\ l > 0 /\ Steel.ST.GenArraySwap.Proof.bezout_prop n l b /\ i1 < Mkbezout_t?.d b /\ i2 < Mkbezout_t?.d b /\ k1 < Mkbezout_t?.q_n b /\ k2 < Mkbezout_t?.q_n b /\ Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) k1 i1 == Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) k2 i2) (ensures i1 == i2 /\ k1 == k2) [ SMTPat (Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) k1 i1); SMTPat (Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) k2 i2); SMTPat (Steel.ST.GenArraySwap.Proof.bezout_prop n l b) ]
{ "end_col": 20, "end_line": 505, "start_col": 2, "start_line": 499 }
FStar.Pervasives.Lemma
val jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n) [SMTPat (jump_coverage_strong n l b x)]
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k
val jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n) [SMTPat (jump_coverage_strong n l b x)] let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n) [SMTPat (jump_coverage_strong n l b x)] =
false
null
true
let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "Steel.ST.GenArraySwap.Proof.nat_up_to", "Steel.ST.GenArraySwap.Proof.jump_iter_mod_q", "Prims.op_Modulus", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Steel.ST.GenArraySwap.Proof.jump_coverage_strong", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Prims.op_LessThan", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n )
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n) [SMTPat (jump_coverage_strong n l b x)]
[]
Steel.ST.GenArraySwap.Proof.jump_coverage_strong_bound
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.nat -> b: Steel.ST.GenArraySwap.Proof.bezout n l -> x: Steel.ST.GenArraySwap.Proof.nat_up_to n -> FStar.Pervasives.Lemma (ensures Mkbezout_t?.q_n b > 0 /\ Steel.ST.GenArraySwap.Proof.jump_coverage_strong n l b x < Mkbezout_t?.q_n b) [SMTPat (Steel.ST.GenArraySwap.Proof.jump_coverage_strong n l b x)]
{ "end_col": 35, "end_line": 384, "start_col": 1, "start_line": 383 }
FStar.Pervasives.Lemma
val jump_iter_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (ensures (iter_fun (jump n l) b.q_n x == x))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let jump_iter_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (ensures ( iter_fun (jump n l) b.q_n x == x )) = cancel_mul_mod 1 b.q_n; jump_iter_mod_q n l b x b.q_n
val jump_iter_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (ensures (iter_fun (jump n l) b.q_n x == x)) let jump_iter_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (ensures (iter_fun (jump n l) b.q_n x == x)) =
false
null
true
cancel_mul_mod 1 b.q_n; jump_iter_mod_q n l b x b.q_n
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "Steel.ST.GenArraySwap.Proof.nat_up_to", "Steel.ST.GenArraySwap.Proof.jump_iter_mod_q", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Prims.unit", "FStar.Math.Lemmas.cancel_mul_mod", "Prims.l_True", "Prims.squash", "Prims.eq2", "Steel.ST.GenArraySwap.Proof.iter_fun", "Steel.ST.GenArraySwap.Proof.jump", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n #restart-solver [@@"opaque_to_smt"] irreducible let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n )) = assert ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) by (int_semiring ()); assert (b.d == b.d * 1) by (int_semiring ()); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then begin lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); assert (kl * 1 == kl) by (int_semiring ()); kl end else begin assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); assert (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) by (int_semiring ()); assert (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) by (int_semiring ()); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); assert (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) by (int_semiring ()); assert (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) by (int_semiring ()); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); assert (kl * (1 + - (b.u_n * b.q_n)) == kl + - kl * b.u_n * b.q_n) by (int_semiring ()); assert (kl * b.u_n * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) by (int_semiring ()); kn * b.u_l + kl * b.u_n end let jump_iter_mod_q_inj_weak (n: pos) (l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires ( iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x )) (ensures ( b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n )) = jump_iter n l x k1; jump_iter n l x k2; let kn = mod_eq_elim n (x + k1 * l) (x + k2 * l) in assert ((k1 + - k2) * l == (k1 * l + - (k2 * l))) by (int_semiring ()); let kq = gauss n l b (k1 + - k2) kn in mod_eq_intro b.q_n k1 k2 kq let jump_iter_inj (n: nat) (l: nat) (b: bezout_t) (i1 i2: nat) (k1 k2: nat) : Lemma (requires ( n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2 )) (ensures ( i1 == i2 /\ k1 == k2 )) [SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b)] = jump_iter_mod_d n l b i1 k1; jump_iter_mod_d n l b i2 k2; small_mod i1 b.d; small_mod i2 b.d; jump_iter_mod_q_inj_weak n l b i1 k1 k2; small_mod k1 b.q_n; small_mod k2 b.q_n #restart-solver let jump_iter_elim (n: pos) (p: nat_up_to n -> prop) (l: nat) (b: bezout n l) : Lemma (requires ( forall (i: nat_up_to b.d) (k: nat_up_to b.q_n) . p (iter_fun (jump n l) k i) )) (ensures ( forall (x: nat_up_to n) . p x )) = let prf (x: nat_up_to n) : Lemma (p x) = let i : nat_up_to b.d = x % b.d in let k' = jump_coverage_strong n l b x in jump_coverage_strong_bound n l b x; assert (p (iter_fun (jump n l) k' i)) in Classical.forall_intro prf let jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma (jump n l idx == (if idx + l >= n then idx - (n - l) else idx + l)) = let idx' = (if idx + l >= n then idx - (n - l) else idx + l) in small_mod idx n; small_mod idx' n; lemma_mod_plus (idx + l) (-1) n let jump_iter_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (ensures ( iter_fun (jump n l) b.q_n x == x
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_iter_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (ensures (iter_fun (jump n l) b.q_n x == x))
[]
Steel.ST.GenArraySwap.Proof.jump_iter_q
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.nat -> b: Steel.ST.GenArraySwap.Proof.bezout n l -> x: Steel.ST.GenArraySwap.Proof.nat_up_to n -> FStar.Pervasives.Lemma (ensures Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) (Mkbezout_t?.q_n b) x == x)
{ "end_col": 31, "end_line": 554, "start_col": 2, "start_line": 553 }
FStar.Pervasives.Lemma
val jump_jump_iter_pred_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (j: nat_up_to b.q_n) : Lemma (requires (j == b.q_n - 1)) (ensures (jump n l (iter_fun (jump n l) j x) == x)) [SMTPat (jump n l (iter_fun (jump n l) j x)); SMTPat (bezout_prop n l b)]
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let jump_jump_iter_pred_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (j: nat_up_to b.q_n) : Lemma (requires ( j == b.q_n - 1 )) (ensures ( jump n l (iter_fun (jump n l) j x) == x )) [SMTPat (jump n l (iter_fun (jump n l) j x)); SMTPat (bezout_prop n l b)] = jump_iter_q n l b x
val jump_jump_iter_pred_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (j: nat_up_to b.q_n) : Lemma (requires (j == b.q_n - 1)) (ensures (jump n l (iter_fun (jump n l) j x) == x)) [SMTPat (jump n l (iter_fun (jump n l) j x)); SMTPat (bezout_prop n l b)] let jump_jump_iter_pred_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (j: nat_up_to b.q_n) : Lemma (requires (j == b.q_n - 1)) (ensures (jump n l (iter_fun (jump n l) j x) == x)) [SMTPat (jump n l (iter_fun (jump n l) j x)); SMTPat (bezout_prop n l b)] =
false
null
true
jump_iter_q n l b x
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "Steel.ST.GenArraySwap.Proof.nat_up_to", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Steel.ST.GenArraySwap.Proof.jump_iter_q", "Prims.unit", "Prims.eq2", "Prims.int", "Prims.op_Subtraction", "Prims.squash", "Steel.ST.GenArraySwap.Proof.jump", "Steel.ST.GenArraySwap.Proof.iter_fun", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.prop", "Steel.ST.GenArraySwap.Proof.bezout_prop", "Prims.Nil" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n #restart-solver [@@"opaque_to_smt"] irreducible let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n )) = assert ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) by (int_semiring ()); assert (b.d == b.d * 1) by (int_semiring ()); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then begin lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); assert (kl * 1 == kl) by (int_semiring ()); kl end else begin assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); assert (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) by (int_semiring ()); assert (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) by (int_semiring ()); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); assert (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) by (int_semiring ()); assert (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) by (int_semiring ()); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); assert (kl * (1 + - (b.u_n * b.q_n)) == kl + - kl * b.u_n * b.q_n) by (int_semiring ()); assert (kl * b.u_n * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) by (int_semiring ()); kn * b.u_l + kl * b.u_n end let jump_iter_mod_q_inj_weak (n: pos) (l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires ( iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x )) (ensures ( b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n )) = jump_iter n l x k1; jump_iter n l x k2; let kn = mod_eq_elim n (x + k1 * l) (x + k2 * l) in assert ((k1 + - k2) * l == (k1 * l + - (k2 * l))) by (int_semiring ()); let kq = gauss n l b (k1 + - k2) kn in mod_eq_intro b.q_n k1 k2 kq let jump_iter_inj (n: nat) (l: nat) (b: bezout_t) (i1 i2: nat) (k1 k2: nat) : Lemma (requires ( n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2 )) (ensures ( i1 == i2 /\ k1 == k2 )) [SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b)] = jump_iter_mod_d n l b i1 k1; jump_iter_mod_d n l b i2 k2; small_mod i1 b.d; small_mod i2 b.d; jump_iter_mod_q_inj_weak n l b i1 k1 k2; small_mod k1 b.q_n; small_mod k2 b.q_n #restart-solver let jump_iter_elim (n: pos) (p: nat_up_to n -> prop) (l: nat) (b: bezout n l) : Lemma (requires ( forall (i: nat_up_to b.d) (k: nat_up_to b.q_n) . p (iter_fun (jump n l) k i) )) (ensures ( forall (x: nat_up_to n) . p x )) = let prf (x: nat_up_to n) : Lemma (p x) = let i : nat_up_to b.d = x % b.d in let k' = jump_coverage_strong n l b x in jump_coverage_strong_bound n l b x; assert (p (iter_fun (jump n l) k' i)) in Classical.forall_intro prf let jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma (jump n l idx == (if idx + l >= n then idx - (n - l) else idx + l)) = let idx' = (if idx + l >= n then idx - (n - l) else idx + l) in small_mod idx n; small_mod idx' n; lemma_mod_plus (idx + l) (-1) n let jump_iter_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (ensures ( iter_fun (jump n l) b.q_n x == x )) = cancel_mul_mod 1 b.q_n; jump_iter_mod_q n l b x b.q_n let rec iter_fun_add (#t: Type) (f: (t -> GTot t)) (n1 n2: nat) (x: t) : Lemma (ensures (iter_fun f n1 (iter_fun f n2 x) == iter_fun f (n1 + n2) x)) (decreases n2) = if n2 = 0 then () else iter_fun_add f n1 (n2 - 1) (f x) let iter_succ_l (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : Lemma (f (iter_fun f n x) == iter_fun f (n + 1) x) [SMTPat (f (iter_fun f n x))] = iter_fun_add f 1 n x let jump_jump_iter_pred_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (j: nat_up_to b.q_n) : Lemma (requires ( j == b.q_n - 1 )) (ensures ( jump n l (iter_fun (jump n l) j x) == x ))
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_jump_iter_pred_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (j: nat_up_to b.q_n) : Lemma (requires (j == b.q_n - 1)) (ensures (jump n l (iter_fun (jump n l) j x) == x)) [SMTPat (jump n l (iter_fun (jump n l) j x)); SMTPat (bezout_prop n l b)]
[]
Steel.ST.GenArraySwap.Proof.jump_jump_iter_pred_q
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.nat -> b: Steel.ST.GenArraySwap.Proof.bezout n l -> x: Steel.ST.GenArraySwap.Proof.nat_up_to n -> j: Steel.ST.GenArraySwap.Proof.nat_up_to (Mkbezout_t?.q_n b) -> FStar.Pervasives.Lemma (requires j == Mkbezout_t?.q_n b - 1) (ensures Steel.ST.GenArraySwap.Proof.jump n l (Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) j x) == x) [ SMTPat (Steel.ST.GenArraySwap.Proof.jump n l (Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) j x)); SMTPat (Steel.ST.GenArraySwap.Proof.bezout_prop n l b) ]
{ "end_col": 21, "end_line": 592, "start_col": 2, "start_line": 592 }
Prims.Ghost
val jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat). k' < k ==> (~(x == iter_fun (jump n l) k' (x % b.d))))))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k'
val jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat). k' < k ==> (~(x == iter_fun (jump n l) k' (x % b.d)))))) let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat). k' < k ==> (~(x == iter_fun (jump n l) k' (x % b.d)))))) =
false
null
false
let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k'
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[]
[ "Prims.pos", "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "Steel.ST.GenArraySwap.Proof.nat_up_to", "Steel.ST.GenArraySwap.Proof.minimal_exists", "Prims.op_Equality", "Steel.ST.GenArraySwap.Proof.iter_fun", "Steel.ST.GenArraySwap.Proof.jump", "Prims.op_Modulus", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Prims.bool", "Steel.ST.GenArraySwap.Proof.jump_coverage", "Prims.l_True", "Prims.l_and", "Prims.eq2", "Prims.l_Forall", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Prims.l_not" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d))))
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat). k' < k ==> (~(x == iter_fun (jump n l) k' (x % b.d))))))
[]
Steel.ST.GenArraySwap.Proof.jump_coverage_strong
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.nat -> b: Steel.ST.GenArraySwap.Proof.bezout n l -> x: Steel.ST.GenArraySwap.Proof.nat_up_to n -> Prims.Ghost Prims.nat
{ "end_col": 66, "end_line": 349, "start_col": 1, "start_line": 348 }
FStar.Pervasives.Lemma
val iter_fun_add (#t: Type) (f: (t -> GTot t)) (n1 n2: nat) (x: t) : Lemma (ensures (iter_fun f n1 (iter_fun f n2 x) == iter_fun f (n1 + n2) x)) (decreases n2)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_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 iter_fun_add (#t: Type) (f: (t -> GTot t)) (n1 n2: nat) (x: t) : Lemma (ensures (iter_fun f n1 (iter_fun f n2 x) == iter_fun f (n1 + n2) x)) (decreases n2) = if n2 = 0 then () else iter_fun_add f n1 (n2 - 1) (f x)
val iter_fun_add (#t: Type) (f: (t -> GTot t)) (n1 n2: nat) (x: t) : Lemma (ensures (iter_fun f n1 (iter_fun f n2 x) == iter_fun f (n1 + n2) x)) (decreases n2) let rec iter_fun_add (#t: Type) (f: (t -> GTot t)) (n1 n2: nat) (x: t) : Lemma (ensures (iter_fun f n1 (iter_fun f n2 x) == iter_fun f (n1 + n2) x)) (decreases n2) =
false
null
true
if n2 = 0 then () else iter_fun_add f n1 (n2 - 1) (f x)
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma", "" ]
[ "Prims.nat", "Prims.op_Equality", "Prims.int", "Prims.bool", "Steel.ST.GenArraySwap.Proof.iter_fun_add", "Prims.op_Subtraction", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Steel.ST.GenArraySwap.Proof.iter_fun", "Prims.op_Addition", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n #restart-solver [@@"opaque_to_smt"] irreducible let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n )) = assert ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) by (int_semiring ()); assert (b.d == b.d * 1) by (int_semiring ()); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then begin lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); assert (kl * 1 == kl) by (int_semiring ()); kl end else begin assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); assert (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) by (int_semiring ()); assert (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) by (int_semiring ()); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); assert (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) by (int_semiring ()); assert (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) by (int_semiring ()); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); assert (kl * (1 + - (b.u_n * b.q_n)) == kl + - kl * b.u_n * b.q_n) by (int_semiring ()); assert (kl * b.u_n * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) by (int_semiring ()); kn * b.u_l + kl * b.u_n end let jump_iter_mod_q_inj_weak (n: pos) (l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires ( iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x )) (ensures ( b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n )) = jump_iter n l x k1; jump_iter n l x k2; let kn = mod_eq_elim n (x + k1 * l) (x + k2 * l) in assert ((k1 + - k2) * l == (k1 * l + - (k2 * l))) by (int_semiring ()); let kq = gauss n l b (k1 + - k2) kn in mod_eq_intro b.q_n k1 k2 kq let jump_iter_inj (n: nat) (l: nat) (b: bezout_t) (i1 i2: nat) (k1 k2: nat) : Lemma (requires ( n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2 )) (ensures ( i1 == i2 /\ k1 == k2 )) [SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b)] = jump_iter_mod_d n l b i1 k1; jump_iter_mod_d n l b i2 k2; small_mod i1 b.d; small_mod i2 b.d; jump_iter_mod_q_inj_weak n l b i1 k1 k2; small_mod k1 b.q_n; small_mod k2 b.q_n #restart-solver let jump_iter_elim (n: pos) (p: nat_up_to n -> prop) (l: nat) (b: bezout n l) : Lemma (requires ( forall (i: nat_up_to b.d) (k: nat_up_to b.q_n) . p (iter_fun (jump n l) k i) )) (ensures ( forall (x: nat_up_to n) . p x )) = let prf (x: nat_up_to n) : Lemma (p x) = let i : nat_up_to b.d = x % b.d in let k' = jump_coverage_strong n l b x in jump_coverage_strong_bound n l b x; assert (p (iter_fun (jump n l) k' i)) in Classical.forall_intro prf let jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma (jump n l idx == (if idx + l >= n then idx - (n - l) else idx + l)) = let idx' = (if idx + l >= n then idx - (n - l) else idx + l) in small_mod idx n; small_mod idx' n; lemma_mod_plus (idx + l) (-1) n let jump_iter_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (ensures ( iter_fun (jump n l) b.q_n x == x )) = cancel_mul_mod 1 b.q_n; jump_iter_mod_q n l b x b.q_n let rec iter_fun_add (#t: Type) (f: (t -> GTot t)) (n1 n2: nat) (x: t) : Lemma (ensures (iter_fun f n1 (iter_fun f n2 x) == iter_fun f (n1 + n2) x))
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val iter_fun_add (#t: Type) (f: (t -> GTot t)) (n1 n2: nat) (x: t) : Lemma (ensures (iter_fun f n1 (iter_fun f n2 x) == iter_fun f (n1 + n2) x)) (decreases n2)
[ "recursion" ]
Steel.ST.GenArraySwap.Proof.iter_fun_add
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
f: (_: t -> Prims.GTot t) -> n1: Prims.nat -> n2: Prims.nat -> x: t -> FStar.Pervasives.Lemma (ensures Steel.ST.GenArraySwap.Proof.iter_fun f n1 (Steel.ST.GenArraySwap.Proof.iter_fun f n2 x) == Steel.ST.GenArraySwap.Proof.iter_fun f (n1 + n2) x) (decreases n2)
{ "end_col": 39, "end_line": 566, "start_col": 2, "start_line": 564 }
FStar.Pervasives.Lemma
val jump_iter_elim (n: pos) (p: (nat_up_to n -> prop)) (l: nat) (b: bezout n l) : Lemma (requires (forall (i: nat_up_to b.d) (k: nat_up_to b.q_n). p (iter_fun (jump n l) k i))) (ensures (forall (x: nat_up_to n). p x))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let jump_iter_elim (n: pos) (p: nat_up_to n -> prop) (l: nat) (b: bezout n l) : Lemma (requires ( forall (i: nat_up_to b.d) (k: nat_up_to b.q_n) . p (iter_fun (jump n l) k i) )) (ensures ( forall (x: nat_up_to n) . p x )) = let prf (x: nat_up_to n) : Lemma (p x) = let i : nat_up_to b.d = x % b.d in let k' = jump_coverage_strong n l b x in jump_coverage_strong_bound n l b x; assert (p (iter_fun (jump n l) k' i)) in Classical.forall_intro prf
val jump_iter_elim (n: pos) (p: (nat_up_to n -> prop)) (l: nat) (b: bezout n l) : Lemma (requires (forall (i: nat_up_to b.d) (k: nat_up_to b.q_n). p (iter_fun (jump n l) k i))) (ensures (forall (x: nat_up_to n). p x)) let jump_iter_elim (n: pos) (p: (nat_up_to n -> prop)) (l: nat) (b: bezout n l) : Lemma (requires (forall (i: nat_up_to b.d) (k: nat_up_to b.q_n). p (iter_fun (jump n l) k i))) (ensures (forall (x: nat_up_to n). p x)) =
false
null
true
let prf (x: nat_up_to n) : Lemma (p x) = let i:nat_up_to b.d = x % b.d in let k' = jump_coverage_strong n l b x in jump_coverage_strong_bound n l b x; assert (p (iter_fun (jump n l) k' i)) in Classical.forall_intro prf
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "Prims.pos", "Steel.ST.GenArraySwap.Proof.nat_up_to", "Prims.prop", "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "FStar.Classical.forall_intro", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Prims._assert", "Steel.ST.GenArraySwap.Proof.iter_fun", "Steel.ST.GenArraySwap.Proof.jump", "Steel.ST.GenArraySwap.Proof.jump_coverage_strong_bound", "Steel.ST.GenArraySwap.Proof.jump_coverage_strong", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Prims.op_Modulus", "Prims.l_Forall", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n #restart-solver [@@"opaque_to_smt"] irreducible let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n )) = assert ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) by (int_semiring ()); assert (b.d == b.d * 1) by (int_semiring ()); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then begin lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); assert (kl * 1 == kl) by (int_semiring ()); kl end else begin assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); assert (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) by (int_semiring ()); assert (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) by (int_semiring ()); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); assert (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) by (int_semiring ()); assert (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) by (int_semiring ()); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); assert (kl * (1 + - (b.u_n * b.q_n)) == kl + - kl * b.u_n * b.q_n) by (int_semiring ()); assert (kl * b.u_n * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) by (int_semiring ()); kn * b.u_l + kl * b.u_n end let jump_iter_mod_q_inj_weak (n: pos) (l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires ( iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x )) (ensures ( b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n )) = jump_iter n l x k1; jump_iter n l x k2; let kn = mod_eq_elim n (x + k1 * l) (x + k2 * l) in assert ((k1 + - k2) * l == (k1 * l + - (k2 * l))) by (int_semiring ()); let kq = gauss n l b (k1 + - k2) kn in mod_eq_intro b.q_n k1 k2 kq let jump_iter_inj (n: nat) (l: nat) (b: bezout_t) (i1 i2: nat) (k1 k2: nat) : Lemma (requires ( n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2 )) (ensures ( i1 == i2 /\ k1 == k2 )) [SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b)] = jump_iter_mod_d n l b i1 k1; jump_iter_mod_d n l b i2 k2; small_mod i1 b.d; small_mod i2 b.d; jump_iter_mod_q_inj_weak n l b i1 k1 k2; small_mod k1 b.q_n; small_mod k2 b.q_n #restart-solver let jump_iter_elim (n: pos) (p: nat_up_to n -> prop) (l: nat) (b: bezout n l) : Lemma (requires ( forall (i: nat_up_to b.d) (k: nat_up_to b.q_n) . p (iter_fun (jump n l) k i) )) (ensures ( forall (x: nat_up_to n) . p x
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_iter_elim (n: pos) (p: (nat_up_to n -> prop)) (l: nat) (b: bezout n l) : Lemma (requires (forall (i: nat_up_to b.d) (k: nat_up_to b.q_n). p (iter_fun (jump n l) k i))) (ensures (forall (x: nat_up_to n). p x))
[]
Steel.ST.GenArraySwap.Proof.jump_iter_elim
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> p: (_: Steel.ST.GenArraySwap.Proof.nat_up_to n -> Prims.prop) -> l: Prims.nat -> b: Steel.ST.GenArraySwap.Proof.bezout n l -> FStar.Pervasives.Lemma (requires forall (i: Steel.ST.GenArraySwap.Proof.nat_up_to (Mkbezout_t?.d b)) (k: Steel.ST.GenArraySwap.Proof.nat_up_to (Mkbezout_t?.q_n b)). p (Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) k i)) (ensures forall (x: Steel.ST.GenArraySwap.Proof.nat_up_to n). p x)
{ "end_col": 28, "end_line": 530, "start_col": 1, "start_line": 520 }
FStar.Pervasives.Lemma
val jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_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 jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end
val jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) =
false
null
true
if k = 0 then () else (jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1))
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma", "" ]
[ "Prims.pos", "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "Steel.ST.GenArraySwap.Proof.nat_up_to", "Prims.op_Equality", "Prims.int", "Prims.bool", "Steel.ST.GenArraySwap.Proof.jump_iter_mod_d", "Steel.ST.GenArraySwap.Proof.jump", "Prims.op_Subtraction", "Prims.unit", "Steel.ST.GenArraySwap.Proof.jump_mod_d", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.op_Modulus", "Steel.ST.GenArraySwap.Proof.iter_fun", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d))
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k)
[ "recursion" ]
Steel.ST.GenArraySwap.Proof.jump_iter_mod_d
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.nat -> b: Steel.ST.GenArraySwap.Proof.bezout n l -> x: Steel.ST.GenArraySwap.Proof.nat_up_to n -> k: Prims.nat -> FStar.Pervasives.Lemma (ensures Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) k x % Mkbezout_t?.d b == x % Mkbezout_t?.d b) (decreases k)
{ "end_col": 5, "end_line": 234, "start_col": 2, "start_line": 229 }
FStar.Pervasives.Lemma
val jump_iter_mod_q_inj_weak (n l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires (iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x)) (ensures (b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let jump_iter_mod_q_inj_weak (n: pos) (l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires ( iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x )) (ensures ( b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n )) = jump_iter n l x k1; jump_iter n l x k2; let kn = mod_eq_elim n (x + k1 * l) (x + k2 * l) in assert ((k1 + - k2) * l == (k1 * l + - (k2 * l))) by (int_semiring ()); let kq = gauss n l b (k1 + - k2) kn in mod_eq_intro b.q_n k1 k2 kq
val jump_iter_mod_q_inj_weak (n l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires (iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x)) (ensures (b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n)) let jump_iter_mod_q_inj_weak (n l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires (iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x)) (ensures (b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n)) =
false
null
true
jump_iter n l x k1; jump_iter n l x k2; let kn = mod_eq_elim n (x + k1 * l) (x + k2 * l) in FStar.Tactics.Effect.assert_by_tactic ((k1 + - k2) * l == (k1 * l + - (k2 * l))) (fun _ -> (); (int_semiring ())); let kq = gauss n l b (k1 + - k2) kn in mod_eq_intro b.q_n k1 k2 kq
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "Prims.pos", "Steel.ST.GenArraySwap.Proof.bezout", "Steel.ST.GenArraySwap.Proof.nat_up_to", "Prims.nat", "Steel.ST.GenArraySwap.Proof.mod_eq_intro", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Prims.int", "Steel.ST.GenArraySwap.Proof.gauss", "Prims.op_Addition", "Prims.op_Minus", "Prims.unit", "FStar.Tactics.Effect.assert_by_tactic", "Prims.eq2", "FStar.Mul.op_Star", "Steel.ST.GenArraySwap.Proof.int_semiring", "Steel.ST.GenArraySwap.Proof.mod_eq_elim", "Steel.ST.GenArraySwap.Proof.jump_iter", "Steel.ST.GenArraySwap.Proof.iter_fun", "Steel.ST.GenArraySwap.Proof.jump", "Prims.squash", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_Modulus", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n #restart-solver [@@"opaque_to_smt"] irreducible let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n )) = assert ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) by (int_semiring ()); assert (b.d == b.d * 1) by (int_semiring ()); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then begin lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); assert (kl * 1 == kl) by (int_semiring ()); kl end else begin assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); assert (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) by (int_semiring ()); assert (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) by (int_semiring ()); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); assert (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) by (int_semiring ()); assert (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) by (int_semiring ()); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); assert (kl * (1 + - (b.u_n * b.q_n)) == kl + - kl * b.u_n * b.q_n) by (int_semiring ()); assert (kl * b.u_n * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) by (int_semiring ()); kn * b.u_l + kl * b.u_n end let jump_iter_mod_q_inj_weak (n: pos) (l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires ( iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x )) (ensures ( b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_iter_mod_q_inj_weak (n l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires (iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x)) (ensures (b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n))
[]
Steel.ST.GenArraySwap.Proof.jump_iter_mod_q_inj_weak
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.pos -> b: Steel.ST.GenArraySwap.Proof.bezout n l -> x: Steel.ST.GenArraySwap.Proof.nat_up_to n -> k1: Prims.nat -> k2: Prims.nat -> FStar.Pervasives.Lemma (requires Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) k1 x == Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) k2 x) (ensures Mkbezout_t?.q_n b > 0 /\ k1 % Mkbezout_t?.q_n b == k2 % Mkbezout_t?.q_n b)
{ "end_col": 29, "end_line": 475, "start_col": 2, "start_line": 470 }
FStar.Pervasives.Lemma
val jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_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 jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end
val jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) =
false
null
true
if k = 0 then (FStar.Tactics.Effect.assert_by_tactic (eq2 #int (x + 0 * l) x) (fun _ -> (); (int_semiring ())); small_mod x n) else let k' = k - 1 in FStar.Tactics.Effect.assert_by_tactic (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) (fun _ -> (); (int_semiring ())); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma", "" ]
[ "Prims.pos", "Prims.nat", "Steel.ST.GenArraySwap.Proof.nat_up_to", "Prims.op_Equality", "Prims.int", "FStar.Math.Lemmas.small_mod", "Prims.unit", "FStar.Tactics.Effect.assert_by_tactic", "Prims.eq2", "Prims.op_Addition", "FStar.Mul.op_Star", "Steel.ST.GenArraySwap.Proof.int_semiring", "Prims.bool", "FStar.Math.Lemmas.lemma_mod_add_distr", "Steel.ST.GenArraySwap.Proof.jump_iter", "Prims.op_Modulus", "Prims.op_Subtraction", "Prims.l_True", "Prims.squash", "Steel.ST.GenArraySwap.Proof.iter_fun", "Steel.ST.GenArraySwap.Proof.jump", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n))
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k)
[ "recursion" ]
Steel.ST.GenArraySwap.Proof.jump_iter
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.nat -> x: Steel.ST.GenArraySwap.Proof.nat_up_to n -> k: Prims.nat -> FStar.Pervasives.Lemma (ensures Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) k x == (x + k * l) % n) (decreases k)
{ "end_col": 5, "end_line": 255, "start_col": 2, "start_line": 246 }
FStar.Pervasives.Lemma
val array_as_ring_buffer_swap (#t: Type) (n l: nat) (bz: bezout n l) (s0 s: Seq.seq t) : Lemma (requires (n == Seq.length s0 /\ n == Seq.length s /\ 0 < l /\ l < n /\ (forall (i': nat_up_to bz.d). (forall (j: nat_up_to bz.q_n). (i' < bz.d) ==> (let idx = iter_fun #(nat_up_to n) (jump n l) j i' in Seq.index s idx == Seq.index s0 (jump n l idx)))))) (ensures (array_swap_post s0 n l s)) [SMTPat (array_swap_post s0 n l s); SMTPat (bezout_prop n l bz)]
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let array_as_ring_buffer_swap (#t: Type) (n: nat) (l: nat) (bz: bezout n l) (s0: Seq.seq t) (s: Seq.seq t) : Lemma (requires ( n == Seq.length s0 /\ n == Seq.length s /\ 0 < l /\ l < n /\ (forall (i': nat_up_to bz.d) . (forall (j: nat_up_to bz.q_n) . (i' < bz.d) ==> ( let idx = iter_fun #(nat_up_to n) (jump n l) j i' in Seq.index s idx == Seq.index s0 (jump n l idx) ))) )) (ensures ( array_swap_post s0 n l s )) [SMTPat (array_swap_post s0 n l s); SMTPat (bezout_prop n l bz)] = Classical.forall_intro (jump_if n l ()); let p (idx: nat_up_to n) : Tot prop = Seq.index s idx == Seq.index s0 (jump n l idx) in jump_iter_elim n p l bz
val array_as_ring_buffer_swap (#t: Type) (n l: nat) (bz: bezout n l) (s0 s: Seq.seq t) : Lemma (requires (n == Seq.length s0 /\ n == Seq.length s /\ 0 < l /\ l < n /\ (forall (i': nat_up_to bz.d). (forall (j: nat_up_to bz.q_n). (i' < bz.d) ==> (let idx = iter_fun #(nat_up_to n) (jump n l) j i' in Seq.index s idx == Seq.index s0 (jump n l idx)))))) (ensures (array_swap_post s0 n l s)) [SMTPat (array_swap_post s0 n l s); SMTPat (bezout_prop n l bz)] let array_as_ring_buffer_swap (#t: Type) (n l: nat) (bz: bezout n l) (s0 s: Seq.seq t) : Lemma (requires (n == Seq.length s0 /\ n == Seq.length s /\ 0 < l /\ l < n /\ (forall (i': nat_up_to bz.d). (forall (j: nat_up_to bz.q_n). (i' < bz.d) ==> (let idx = iter_fun #(nat_up_to n) (jump n l) j i' in Seq.index s idx == Seq.index s0 (jump n l idx)))))) (ensures (array_swap_post s0 n l s)) [SMTPat (array_swap_post s0 n l s); SMTPat (bezout_prop n l bz)] =
false
null
true
Classical.forall_intro (jump_if n l ()); let p (idx: nat_up_to n) : Tot prop = Seq.index s idx == Seq.index s0 (jump n l idx) in jump_iter_elim n p l bz
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "FStar.Seq.Base.seq", "Steel.ST.GenArraySwap.Proof.jump_iter_elim", "Steel.ST.GenArraySwap.Proof.nat_up_to", "Prims.prop", "Prims.eq2", "FStar.Seq.Base.index", "Steel.ST.GenArraySwap.Proof.jump", "Prims.unit", "FStar.Classical.forall_intro", "Prims.int", "Prims.op_GreaterThanOrEqual", "Prims.op_Addition", "Prims.op_Subtraction", "Prims.bool", "Steel.ST.GenArraySwap.Proof.jump_if", "Prims.l_and", "FStar.Seq.Base.length", "Prims.b2t", "Prims.op_LessThan", "Prims.l_Forall", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Prims.l_imp", "Steel.ST.GenArraySwap.Proof.iter_fun", "Prims.squash", "Steel.ST.GenArraySwap.Proof.array_swap_post", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Steel.ST.GenArraySwap.Proof.bezout_prop", "Prims.Nil" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n #restart-solver [@@"opaque_to_smt"] irreducible let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n )) = assert ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) by (int_semiring ()); assert (b.d == b.d * 1) by (int_semiring ()); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then begin lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); assert (kl * 1 == kl) by (int_semiring ()); kl end else begin assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); assert (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) by (int_semiring ()); assert (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) by (int_semiring ()); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); assert (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) by (int_semiring ()); assert (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) by (int_semiring ()); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); assert (kl * (1 + - (b.u_n * b.q_n)) == kl + - kl * b.u_n * b.q_n) by (int_semiring ()); assert (kl * b.u_n * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) by (int_semiring ()); kn * b.u_l + kl * b.u_n end let jump_iter_mod_q_inj_weak (n: pos) (l: pos) (b: bezout n l) (x: nat_up_to n) (k1 k2: nat) : Lemma (requires ( iter_fun (jump n l) k1 x == iter_fun (jump n l) k2 x )) (ensures ( b.q_n > 0 /\ k1 % b.q_n == k2 % b.q_n )) = jump_iter n l x k1; jump_iter n l x k2; let kn = mod_eq_elim n (x + k1 * l) (x + k2 * l) in assert ((k1 + - k2) * l == (k1 * l + - (k2 * l))) by (int_semiring ()); let kq = gauss n l b (k1 + - k2) kn in mod_eq_intro b.q_n k1 k2 kq let jump_iter_inj (n: nat) (l: nat) (b: bezout_t) (i1 i2: nat) (k1 k2: nat) : Lemma (requires ( n > 0 /\ l > 0 /\ bezout_prop n l b /\ i1 < b.d /\ i2 < b.d /\ k1 < b.q_n /\ k2 < b.q_n /\ iter_fun (jump n l) k1 i1 == iter_fun (jump n l) k2 i2 )) (ensures ( i1 == i2 /\ k1 == k2 )) [SMTPat (iter_fun (jump n l) k1 i1); SMTPat (iter_fun (jump n l) k2 i2); SMTPat (bezout_prop n l b)] = jump_iter_mod_d n l b i1 k1; jump_iter_mod_d n l b i2 k2; small_mod i1 b.d; small_mod i2 b.d; jump_iter_mod_q_inj_weak n l b i1 k1 k2; small_mod k1 b.q_n; small_mod k2 b.q_n #restart-solver let jump_iter_elim (n: pos) (p: nat_up_to n -> prop) (l: nat) (b: bezout n l) : Lemma (requires ( forall (i: nat_up_to b.d) (k: nat_up_to b.q_n) . p (iter_fun (jump n l) k i) )) (ensures ( forall (x: nat_up_to n) . p x )) = let prf (x: nat_up_to n) : Lemma (p x) = let i : nat_up_to b.d = x % b.d in let k' = jump_coverage_strong n l b x in jump_coverage_strong_bound n l b x; assert (p (iter_fun (jump n l) k' i)) in Classical.forall_intro prf let jump_if (n: pos) (l: nat) (sq: squash (l < n)) (idx: nat_up_to n) : Lemma (jump n l idx == (if idx + l >= n then idx - (n - l) else idx + l)) = let idx' = (if idx + l >= n then idx - (n - l) else idx + l) in small_mod idx n; small_mod idx' n; lemma_mod_plus (idx + l) (-1) n let jump_iter_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (ensures ( iter_fun (jump n l) b.q_n x == x )) = cancel_mul_mod 1 b.q_n; jump_iter_mod_q n l b x b.q_n let rec iter_fun_add (#t: Type) (f: (t -> GTot t)) (n1 n2: nat) (x: t) : Lemma (ensures (iter_fun f n1 (iter_fun f n2 x) == iter_fun f (n1 + n2) x)) (decreases n2) = if n2 = 0 then () else iter_fun_add f n1 (n2 - 1) (f x) let iter_succ_l (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : Lemma (f (iter_fun f n x) == iter_fun f (n + 1) x) [SMTPat (f (iter_fun f n x))] = iter_fun_add f 1 n x let jump_jump_iter_pred_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (j: nat_up_to b.q_n) : Lemma (requires ( j == b.q_n - 1 )) (ensures ( jump n l (iter_fun (jump n l) j x) == x )) [SMTPat (jump n l (iter_fun (jump n l) j x)); SMTPat (bezout_prop n l b)] = jump_iter_q n l b x let array_swap_post (#t: Type) (s0: Seq.seq t) (n: nat) (l: nat) (s: Seq.seq t) : Tot prop = n == Seq.length s0 /\ 0 <= l /\ l <= n /\ s `Seq.equal` (Seq.slice s0 l n `Seq.append` Seq.slice s0 0 l) let array_as_ring_buffer_swap (#t: Type) (n: nat) (l: nat) (bz: bezout n l) (s0: Seq.seq t) (s: Seq.seq t) : Lemma (requires ( n == Seq.length s0 /\ n == Seq.length s /\ 0 < l /\ l < n /\ (forall (i': nat_up_to bz.d) . (forall (j: nat_up_to bz.q_n) . (i' < bz.d) ==> ( let idx = iter_fun #(nat_up_to n) (jump n l) j i' in Seq.index s idx == Seq.index s0 (jump n l idx) ))) )) (ensures ( array_swap_post s0 n l s ))
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val array_as_ring_buffer_swap (#t: Type) (n l: nat) (bz: bezout n l) (s0 s: Seq.seq t) : Lemma (requires (n == Seq.length s0 /\ n == Seq.length s /\ 0 < l /\ l < n /\ (forall (i': nat_up_to bz.d). (forall (j: nat_up_to bz.q_n). (i' < bz.d) ==> (let idx = iter_fun #(nat_up_to n) (jump n l) j i' in Seq.index s idx == Seq.index s0 (jump n l idx)))))) (ensures (array_swap_post s0 n l s)) [SMTPat (array_swap_post s0 n l s); SMTPat (bezout_prop n l bz)]
[]
Steel.ST.GenArraySwap.Proof.array_as_ring_buffer_swap
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.nat -> l: Prims.nat -> bz: Steel.ST.GenArraySwap.Proof.bezout n l -> s0: FStar.Seq.Base.seq t -> s: FStar.Seq.Base.seq t -> FStar.Pervasives.Lemma (requires n == FStar.Seq.Base.length s0 /\ n == FStar.Seq.Base.length s /\ 0 < l /\ l < n /\ (forall (i': Steel.ST.GenArraySwap.Proof.nat_up_to (Mkbezout_t?.d bz)) (j: Steel.ST.GenArraySwap.Proof.nat_up_to (Mkbezout_t?.q_n bz)). i' < Mkbezout_t?.d bz ==> (let idx = Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) j i' in FStar.Seq.Base.index s idx == FStar.Seq.Base.index s0 (Steel.ST.GenArraySwap.Proof.jump n l idx)))) (ensures Steel.ST.GenArraySwap.Proof.array_swap_post s0 n l s) [ SMTPat (Steel.ST.GenArraySwap.Proof.array_swap_post s0 n l s); SMTPat (Steel.ST.GenArraySwap.Proof.bezout_prop n l bz) ]
{ "end_col": 25, "end_line": 637, "start_col": 2, "start_line": 631 }
Prims.Ghost
val mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k
val mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) =
false
null
false
euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in FStar.Tactics.Effect.assert_by_tactic (q1 * n + r + - (q2 * n + r) == k * n) (fun _ -> (); (int_semiring ())); k
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[]
[ "Prims.pos", "Prims.int", "Prims.unit", "FStar.Tactics.Effect.assert_by_tactic", "Prims.eq2", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.op_Minus", "Steel.ST.GenArraySwap.Proof.int_semiring", "Prims.op_Modulus", "Prims.op_Division", "FStar.Math.Lemmas.euclidean_division_definition", "Prims.op_Subtraction" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n))
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n))
[]
Steel.ST.GenArraySwap.Proof.mod_eq_elim
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> x1: Prims.int -> x2: Prims.int -> Prims.Ghost Prims.int
{ "end_col": 3, "end_line": 403, "start_col": 2, "start_line": 396 }
FStar.Pervasives.Lemma
val jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d
val jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) =
false
null
true
let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in FStar.Tactics.Effect.assert_by_tactic (eq2 #int x'_alt (x + qx * b.d)) (fun _ -> (); (int_semiring ())); lemma_mod_plus x qx b.d
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "Steel.ST.GenArraySwap.Proof.nat_up_to", "FStar.Math.Lemmas.lemma_mod_plus", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Prims.unit", "FStar.Tactics.Effect.assert_by_tactic", "Prims.eq2", "Prims.int", "Prims.op_Addition", "FStar.Mul.op_Star", "Steel.ST.GenArraySwap.Proof.int_semiring", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_l", "Prims.op_Minus", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Prims._assert", "FStar.Math.Lemmas.euclidean_division_definition", "Prims.op_Division", "Steel.ST.GenArraySwap.Proof.jump", "Prims.l_True", "Prims.squash", "Prims.op_Modulus", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d)
[]
Steel.ST.GenArraySwap.Proof.jump_mod_d
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.nat -> b: Steel.ST.GenArraySwap.Proof.bezout n l -> x: Steel.ST.GenArraySwap.Proof.nat_up_to n -> FStar.Pervasives.Lemma (ensures Steel.ST.GenArraySwap.Proof.jump n l x % Mkbezout_t?.d b == x % Mkbezout_t?.d b)
{ "end_col": 25, "end_line": 218, "start_col": 1, "start_line": 206 }
FStar.Pervasives.Lemma
val jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n
val jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x)) let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x)) =
false
null
true
assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; FStar.Tactics.Effect.assert_by_tactic (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) (fun _ -> (); (int_semiring ())); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "lemma" ]
[ "Prims.pos", "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "Steel.ST.GenArraySwap.Proof.nat_up_to", "FStar.Math.Lemmas.lemma_mod_plus", "Prims.op_Addition", "FStar.Mul.op_Star", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_l", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.int", "FStar.Tactics.Effect.assert_by_tactic", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Steel.ST.GenArraySwap.Proof.int_semiring", "Steel.ST.GenArraySwap.Proof.jump_iter", "FStar.Math.Lemmas.euclidean_division_definition", "Prims.op_Division", "Prims.op_Modulus", "Prims.b2t", "Prims.op_GreaterThan", "Prims.l_True", "Prims.squash", "Prims.l_and", "Steel.ST.GenArraySwap.Proof.iter_fun", "Steel.ST.GenArraySwap.Proof.jump", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x))
[]
Steel.ST.GenArraySwap.Proof.jump_iter_mod_q
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.nat -> b: Steel.ST.GenArraySwap.Proof.bezout n l -> x: Steel.ST.GenArraySwap.Proof.nat_up_to n -> k: Prims.nat -> FStar.Pervasives.Lemma (ensures Mkbezout_t?.q_n b > 0 /\ Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) (k % Mkbezout_t?.q_n b) x == Steel.ST.GenArraySwap.Proof.iter_fun (Steel.ST.GenArraySwap.Proof.jump n l) k x)
{ "end_col": 44, "end_line": 371, "start_col": 2, "start_line": 363 }
Prims.Ghost
val gauss (n l: pos) (b: bezout n l) (kl kn: int) : Ghost int (requires (kl * l == kn * n)) (ensures (fun k -> kl == k * b.q_n))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n )) = assert ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) by (int_semiring ()); assert (b.d == b.d * 1) by (int_semiring ()); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then begin lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); assert (kl * 1 == kl) by (int_semiring ()); kl end else begin assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); assert (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) by (int_semiring ()); assert (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) by (int_semiring ()); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); assert (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) by (int_semiring ()); assert (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) by (int_semiring ()); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); assert (kl * (1 + - (b.u_n * b.q_n)) == kl + - kl * b.u_n * b.q_n) by (int_semiring ()); assert (kl * b.u_n * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) by (int_semiring ()); kn * b.u_l + kl * b.u_n end
val gauss (n l: pos) (b: bezout n l) (kl kn: int) : Ghost int (requires (kl * l == kn * n)) (ensures (fun k -> kl == k * b.q_n)) let gauss (n l: pos) (b: bezout n l) (kl kn: int) : Ghost int (requires (kl * l == kn * n)) (ensures (fun k -> kl == k * b.q_n)) =
false
null
false
FStar.Tactics.Effect.assert_by_tactic ((b.d * b.q_n) * b.u_n + (b.d * b.q_l) * b.u_l == b.d * (b.u_n * b.q_n + b.u_l * b.q_l)) (fun _ -> (); (int_semiring ())); FStar.Tactics.Effect.assert_by_tactic (b.d == b.d * 1) (fun _ -> (); (int_semiring ())); assert (b.d * (b.u_n * b.q_n + b.u_l * b.q_l) == b.d * 1); lemma_mult_reg_l b.d (b.u_n * b.q_n + b.u_l * b.q_l) 1; assert (b.u_n * b.q_n + b.u_l * b.q_l == 1); if b.u_l = 0 then (lemma_bezout_one_zero b.u_n b.q_n b.u_l b.q_l; assert (b.q_n == 1); FStar.Tactics.Effect.assert_by_tactic (kl * 1 == kl) (fun _ -> (); (int_semiring ())); kl) else (assert (kl * (b.d * b.q_l) == kn * (b.d * b.q_n)); FStar.Tactics.Effect.assert_by_tactic (kl * (b.d * b.q_l) == b.d * (kl * b.q_l)) (fun _ -> (); (int_semiring ())); FStar.Tactics.Effect.assert_by_tactic (kn * (b.d * b.q_n) == b.d * (kn * b.q_n)) (fun _ -> (); (int_semiring ())); assert (b.d * (kl * b.q_l) == b.d * (kn * b.q_n)); lemma_mult_reg_l b.d (kl * b.q_l) (kn * b.q_n); assert (kl * b.q_l == kn * b.q_n); assert (b.u_l * (kl * b.q_l) == b.u_l * (kn * b.q_n)); FStar.Tactics.Effect.assert_by_tactic (b.u_l * (kl * b.q_l) == kl * (b.u_l * b.q_l)) (fun _ -> (); (int_semiring ())); FStar.Tactics.Effect.assert_by_tactic (b.u_l * (kn * b.q_n) == (kn * b.u_l) * b.q_n) (fun _ -> (); (int_semiring ())); assert (kl * (b.u_l * b.q_l) == (kn * b.u_l) * b.q_n); FStar.Tactics.Effect.assert_by_tactic (kl * (1 + - (b.u_n * b.q_n)) == kl + - (kl * b.u_n) * b.q_n) (fun _ -> (); (int_semiring ())); FStar.Tactics.Effect.assert_by_tactic ((kl * b.u_n) * b.q_n + (kn * b.u_l) * b.q_n == (kn * b.u_l + kl * b.u_n) * b.q_n) (fun _ -> (); (int_semiring ())); kn * b.u_l + kl * b.u_n)
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[]
[ "Prims.pos", "Steel.ST.GenArraySwap.Proof.bezout", "Prims.int", "Prims.op_Equality", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__u_l", "Prims.unit", "FStar.Tactics.Effect.assert_by_tactic", "Prims.eq2", "FStar.Mul.op_Star", "Steel.ST.GenArraySwap.Proof.int_semiring", "Prims._assert", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Steel.ST.GenArraySwap.Proof.lemma_bezout_one_zero", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__u_n", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_l", "Prims.bool", "Prims.op_Addition", "Prims.op_Minus", "Steel.ST.GenArraySwap.Proof.lemma_mult_reg_l", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k [@@"opaque_to_smt"] irreducible let rec minimal_exists' (p: (nat -> GTot bool)) (n: nat) (i: nat) : Ghost nat (requires ( p n == true /\ i <= n /\ (forall (j: nat) . j < i ==> p j == false) )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) (decreases (n - i)) = if p i then i else minimal_exists' p n (i + 1) [@@"opaque_to_smt"] irreducible let minimal_exists (p: (nat -> GTot bool)) (n: nat) : Ghost nat (requires ( p n == true )) (ensures (fun k -> p k == true /\ (forall (j: nat) . j < k ==> p j == false) )) = minimal_exists' p n 0 [@@"opaque_to_smt"] irreducible let jump_coverage_strong (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) /\ (forall (k': nat) . k' < k ==> (~ (x == iter_fun (jump n l) k' (x % b.d)))) )) = let k' = jump_coverage n l b x in minimal_exists (fun k -> x = iter_fun (jump n l) k (x % b.d)) k' #restart-solver let jump_iter_mod_q (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures ( b.q_n > 0 /\ iter_fun (jump n l) (k % b.q_n) x == iter_fun (jump n l) k x )) = assert (b.q_n > 0); let k' = k % b.q_n in let qk = k / b.q_n in euclidean_division_definition k b.q_n; jump_iter n l x k'; jump_iter n l x k; assert (eq2 #int (x + (qk * b.q_n + k') * (b.d * b.q_l)) (x + k' * (b.d * b.q_l) + (qk * b.q_l) * (b.d * b.q_n))) by (int_semiring ()); assert (x + k * l == x + k' * l + (qk * b.q_l) * n); lemma_mod_plus (x + k' * l) (qk * b.q_l) n let jump_coverage_strong_bound (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (b.q_n > 0 /\ jump_coverage_strong n l b x < b.q_n ) [SMTPat (jump_coverage_strong n l b x)] = let k = jump_coverage_strong n l b x in jump_iter_mod_q n l b (x % b.d) k #restart-solver [@@"opaque_to_smt"] irreducible let mod_eq_elim (n: pos) (x1 x2: int) : Ghost int (requires (x1 % n == x2 % n)) (ensures (fun k -> x1 - x2 == k * n)) = euclidean_division_definition x1 n; euclidean_division_definition x2 n; let q1 = x1 / n in let q2 = x2 / n in let k = q1 + - q2 in let r = x1 % n in assert (q1 * n + r + - (q2 * n + r) == k * n) by (int_semiring ()); k let mod_eq_intro (n: pos) (x1 x2: int) (k: int) : Lemma (requires (x1 - x2 == k * n)) (ensures (x1 % n == x2 % n)) = lemma_mod_plus x2 k n #restart-solver [@@"opaque_to_smt"] irreducible let gauss (n: pos) (l: pos) // necessary here (b: bezout n l) (kl kn: int) : Ghost int (requires ( kl * l == kn * n )) (ensures (fun k -> kl == k * b.q_n
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val gauss (n l: pos) (b: bezout n l) (kl kn: int) : Ghost int (requires (kl * l == kn * n)) (ensures (fun k -> kl == k * b.q_n))
[]
Steel.ST.GenArraySwap.Proof.gauss
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.pos -> b: Steel.ST.GenArraySwap.Proof.bezout n l -> kl: Prims.int -> kn: Prims.int -> Prims.Ghost Prims.int
{ "end_col": 5, "end_line": 454, "start_col": 2, "start_line": 429 }
Prims.Ghost
val jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d)))
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d) )) = let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in assert (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) by (int_semiring ()); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; assert (i + (qk * n + k) * l == i + k * l + (qk * l) * n) by (int_semiring ()); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k
val jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d))) let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d))) =
false
null
false
let i = x % b.d in let qx = x / b.d in euclidean_division_definition x b.d; let k1 = qx * b.u_l in let m = qx * b.u_n in FStar.Tactics.Effect.assert_by_tactic (eq2 #int (qx * (n * b.u_n + l * b.u_l) + i) (i + k1 * l + m * n)) (fun _ -> (); (int_semiring ())); assert (x == i + k1 * l + m * n); small_mod x n; lemma_mod_plus (i + k1 * l) m n; assert (x == (i + k1 * l) % n); let k = k1 % n in let qk = k1 / n in euclidean_division_definition k1 n; FStar.Tactics.Effect.assert_by_tactic (i + (qk * n + k) * l == i + k * l + (qk * l) * n) (fun _ -> (); (int_semiring ())); lemma_mod_plus (i + k * l) (qk * l) n; assert (eq2 #int x ((i + k * l) % n)); jump_iter n l i k; k
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[]
[ "Prims.pos", "Prims.nat", "Steel.ST.GenArraySwap.Proof.bezout", "Steel.ST.GenArraySwap.Proof.nat_up_to", "Prims.unit", "Steel.ST.GenArraySwap.Proof.jump_iter", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Prims.op_Addition", "FStar.Mul.op_Star", "FStar.Math.Lemmas.lemma_mod_plus", "FStar.Tactics.Effect.assert_by_tactic", "Steel.ST.GenArraySwap.Proof.int_semiring", "FStar.Math.Lemmas.euclidean_division_definition", "Prims.op_Division", "FStar.Math.Lemmas.small_mod", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__u_n", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__u_l", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Prims.l_True", "Steel.ST.GenArraySwap.Proof.iter_fun", "Steel.ST.GenArraySwap.Proof.jump" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end let bezout_q_eq (n: nat) (l: nat) (bz: bezout n l) : Lemma (bz.q_n == n / bz.d) [SMTPat (bezout_prop n l bz); SMTPat bz.q_n] = cancel_mul_div bz.q_n bz.d let rec iter_fun (#t: Type) (f: (t -> GTot t)) (n: nat) (x: t) : GTot t (decreases n) = if n = 0 then x else iter_fun f (n - 1) (f x) let nat_up_to (n: nat) : Tot Type = (i: nat { i < n }) let jump (n: pos) (l: nat) (x: nat_up_to n) : GTot (nat_up_to n) = (x + l) % n #restart-solver let jump_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Lemma (jump n l x % b.d == x % b.d) = let x' = jump n l x in let x'q = (x + l) / n in euclidean_division_definition (x + l) n; let l_alt = b.d * b.q_l in assert (l_alt == l); let n_alt = b.d * b.q_n in assert (n_alt == n); let x'_alt = x + l_alt + - x'q * n_alt in assert (x'_alt == x'); let qx = b.q_l + - x'q * b.q_n in assert (eq2 #int x'_alt (x + qx * b.d)) by (int_semiring ()); lemma_mod_plus x qx b.d let rec jump_iter_mod_d (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x % b.d == x % b.d)) (decreases k) = if k = 0 then () else begin jump_mod_d n l b x; jump_iter_mod_d n l b (jump n l x) (k - 1) end (* Coverage *) let rec jump_iter (n: pos) (l: nat) (x: nat_up_to n) (k: nat) : Lemma (ensures (iter_fun #(nat_up_to n) (jump n l) k x == (x + k * l) % n)) (decreases k) = if k = 0 then begin assert (eq2 #int (x + 0 * l) x) by (int_semiring ()); small_mod x n end else begin let k' = k - 1 in assert (eq2 #int (x + (k' + 1) * l) ((x + l) + k' * l)) by (int_semiring ()); jump_iter n l ((x + l) % n) k'; lemma_mod_add_distr (k' * l) (x + l) n end let bezout_pos_le (n: pos) (l: nat) (b: bezout n l) : Lemma (b.d <= n /\ b.q_n > 0) [SMTPat (bezout_prop n l b)] = lemma_pos_mul_pos_args b.q_n b.d #restart-solver [@@"opaque_to_smt"] irreducible let jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d)
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val jump_coverage (n: pos) (l: nat) (b: bezout n l) (x: nat_up_to n) : Ghost nat (requires True) (ensures (fun k -> x == iter_fun (jump n l) k (x % b.d)))
[]
Steel.ST.GenArraySwap.Proof.jump_coverage
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.nat -> b: Steel.ST.GenArraySwap.Proof.bezout n l -> x: Steel.ST.GenArraySwap.Proof.nat_up_to n -> Prims.Ghost Prims.nat
{ "end_col": 3, "end_line": 297, "start_col": 1, "start_line": 279 }
Prims.Pure
val mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l)
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST.GenArraySwap", "short_module": null }, { "abbrev": false, "full_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 mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) = if l = 0 then begin let d : pos = n in let q_n : nat = 1 in let q_l : nat = 0 in let u_n : int = 1 in let u_l : int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l; } in assert (eq2 #int n (d * q_n)) by (int_semiring ()); assert (eq2 #int 0 (d * q_l)) by (int_semiring ()); assert (eq2 #int d (n * 1 + 0 * res.u_l)) by (int_semiring ()); res end else begin let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in assert (eq2 #int n_alt1 (d * q_n)) by (int_semiring ()); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in assert (eq2 #int (n * upre_lpre + l * u_l) d_alt) by (int_semiring ()); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l; } in res end
val mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l) =
false
null
false
if l = 0 then let d:pos = n in let q_n:nat = 1 in let q_l:nat = 0 in let u_n:int = 1 in let u_l:int = 0 in let res = { d = d; q_n = q_n; q_l = q_l; u_n = u_n; u_l = u_l } in FStar.Tactics.Effect.assert_by_tactic (eq2 #int n (d * q_n)) (fun _ -> (); (int_semiring ())); FStar.Tactics.Effect.assert_by_tactic (eq2 #int 0 (d * q_l)) (fun _ -> (); (int_semiring ())); FStar.Tactics.Effect.assert_by_tactic (eq2 #int d (n * 1 + 0 * res.u_l)) (fun _ -> (); (int_semiring ())); res else let lpre = n % l in let ql = n / l in euclidean_division_definition n l; let bpre = mk_bezout l lpre in let d = bpre.d in let q_l = bpre.q_n in let qpre_lpre = bpre.q_l in let upre_l = bpre.u_n in let upre_lpre = bpre.u_l in let n_alt0 = l * ql + lpre in assert (n == n_alt0); let l_alt = d * q_l in let lpre_alt1 = d * qpre_lpre in let n_alt1 = l_alt * ql + lpre_alt1 in assert (n_alt1 == n); let q_n = q_l * ql + qpre_lpre in FStar.Tactics.Effect.assert_by_tactic (eq2 #int n_alt1 (d * q_n)) (fun _ -> (); (int_semiring ())); let lpre_alt2 = n + - l * ql in assert (lpre_alt2 == lpre); let d_alt = l * upre_l + lpre_alt2 * upre_lpre in assert (d_alt == d); let u_l = upre_l + - ql * upre_lpre in FStar.Tactics.Effect.assert_by_tactic (eq2 #int (n * upre_lpre + l * u_l) d_alt) (fun _ -> (); (int_semiring ())); let res = { d = d; q_n = q_n; q_l = q_l; u_n = upre_lpre; u_l = u_l } in res
{ "checked_file": "Steel.ST.GenArraySwap.Proof.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Tactics.Effect.fsti.checked", "FStar.Tactics.CanonCommSemiring.fst.checked", "FStar.Tactics.fst.checked", "FStar.SizeT.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": false, "source_file": "Steel.ST.GenArraySwap.Proof.fst" }
[ "" ]
[ "Prims.pos", "Prims.nat", "Prims.op_Equality", "Prims.int", "Prims.unit", "FStar.Tactics.Effect.assert_by_tactic", "Prims.eq2", "Prims.op_Addition", "FStar.Mul.op_Star", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__u_l", "Steel.ST.GenArraySwap.Proof.int_semiring", "Steel.ST.GenArraySwap.Proof.bezout_t", "Steel.ST.GenArraySwap.Proof.Mkbezout_t", "Prims.bool", "Prims.op_Minus", "Prims._assert", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__u_n", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_l", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__q_n", "Steel.ST.GenArraySwap.Proof.__proj__Mkbezout_t__item__d", "Steel.ST.GenArraySwap.Proof.bezout", "Steel.ST.GenArraySwap.Proof.mk_bezout", "FStar.Math.Lemmas.euclidean_division_definition", "Prims.op_Division", "Prims.op_Modulus", "Prims.b2t", "Prims.op_LessThan", "Prims.l_True" ]
[]
module Steel.ST.GenArraySwap.Proof open FStar.Math.Lemmas open FStar.Mul let lemma_mod_lt (a:int) (b:pos) : Lemma (let r = a % b in 0 <= r /\ r < b) [SMTPat (a % b)] = () let lemma_mul_nat_nat_is_nat (a b: nat) : Lemma (a * b >= 0) [SMTPat (a * b)] = () let lemma_pos_mul_pos_args (a: nat) (b: nat) : Lemma (requires (a * b > 0)) (ensures (a > 0 /\ b > 0 /\ a <= a * b /\ b <= a * b /\ a * b == b * a)) = () let lemma_div_nat (a: nat) (b: pos) : Lemma (a / b >= 0) [SMTPat (a / b)] = () let lemma_mult_reg_l (k: int) (x1 x2: int) : Lemma (requires ( k * x1 == k * x2 /\ k <> 0 )) (ensures ( x1 == x2 )) = () let lemma_bezout_one_zero (x1: int) (x2: nat) (y1 y2: int) : Lemma (requires ( x1 * x2 + y1 * y2 == 1 /\ y1 == 0 )) (ensures ( x1 == 1 /\ x2 == 1 )) = () #set-options "--z3cliopt smt.arith.nl=false" let int_semiring () = FStar.Tactics.CanonCommSemiring.int_semiring (); FStar.Tactics.trefl (); FStar.Tactics.qed () [@@erasable] noeq type bezout_t = { d: pos; q_n: nat; q_l: nat; u_n: int; u_l: int; } let bezout_prop' (n: nat) (l: nat) (d: pos) (q_n: nat) (q_l: nat) (u_n: int) (u_l: int) : Tot prop = n == d * q_n /\ l == d * q_l /\ d == n * u_n + l * u_l let bezout_prop (n: nat) (l: nat) (b: bezout_t) : Tot prop = bezout_prop' n l b.d b.q_n b.q_l b.u_n b.u_l let bezout (n: nat) (l: nat) : Tot Type = (b: bezout_t { bezout_prop n l b }) #restart-solver let rec mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True))
false
false
Steel.ST.GenArraySwap.Proof.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": [ "smt.arith.nl=false" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mk_bezout (n: pos) (l: nat) : Pure (bezout n l) (requires (l < n)) (ensures (fun _ -> True)) (decreases l)
[ "recursion" ]
Steel.ST.GenArraySwap.Proof.mk_bezout
{ "file_name": "lib/steel/Steel.ST.GenArraySwap.Proof.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
n: Prims.pos -> l: Prims.nat -> Prims.Pure (Steel.ST.GenArraySwap.Proof.bezout n l)
{ "end_col": 5, "end_line": 167, "start_col": 2, "start_line": 114 }
Prims.Tot
[ { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Fields", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Curve25519.Generic", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let p = Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled)
let p =
false
null
false
let open Vale.X64.CPU_Features_s in adx_enabled /\ bmi2_enabled
{ "checked_file": "Hacl.Curve25519_64.fsti.checked", "dependencies": [ "Vale.X64.CPU_Features_s.fst.checked", "prims.fst.checked", "Hacl.Impl.Curve25519.Generic.fsti.checked", "Hacl.Impl.Curve25519.Fields.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Curve25519_64.fsti" }
[ "total" ]
[ "Prims.l_and", "Prims.b2t", "Vale.X64.CPU_Features_s.adx_enabled", "Vale.X64.CPU_Features_s.bmi2_enabled" ]
[]
module Hacl.Curve25519_64 open Hacl.Impl.Curve25519.Generic open Hacl.Impl.Curve25519.Fields
false
true
Hacl.Curve25519_64.fsti
{ "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 p : Prims.logical
[]
Hacl.Curve25519_64.p
{ "file_name": "code/curve25519/Hacl.Curve25519_64.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.logical
{ "end_col": 60, "end_line": 7, "start_col": 33, "start_line": 7 }
FStar.HyperStack.ST.Stack
val verify: public_key:lbuffer uint8 32ul -> msg_len:size_t -> msg:lbuffer uint8 msg_len -> signature:lbuffer uint8 64ul -> Stack bool (requires fun h -> live h public_key /\ live h msg /\ live h signature) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ b == Spec.Ed25519.verify (as_seq h0 public_key) (as_seq h0 msg) (as_seq h0 signature))
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let verify public_key msg_len msg signature = Hacl.Impl.Ed25519.Verify.verify public_key msg_len msg signature
val verify: public_key:lbuffer uint8 32ul -> msg_len:size_t -> msg:lbuffer uint8 msg_len -> signature:lbuffer uint8 64ul -> Stack bool (requires fun h -> live h public_key /\ live h msg /\ live h signature) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ b == Spec.Ed25519.verify (as_seq h0 public_key) (as_seq h0 msg) (as_seq h0 signature)) let verify public_key msg_len msg signature =
true
null
false
Hacl.Impl.Ed25519.Verify.verify public_key msg_len msg signature
{ "checked_file": "Hacl.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Impl.Ed25519.Verify.fst.checked", "Hacl.Impl.Ed25519.Sign.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": true, "source_file": "Hacl.Ed25519.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Hacl.Impl.Ed25519.Verify.verify", "Prims.bool" ]
[]
module Hacl.Ed25519 module ST = FStar.HyperStack.ST open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer module S = Spec.Ed25519 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val secret_expand: expanded:lbuffer uint8 64ul -> secret:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h expanded /\ live h secret /\ disjoint expanded secret) (ensures fun h0 _ h1 -> modifies (loc expanded) h0 h1 /\ (let a, prefix = S.secret_expand (as_seq h0 secret) in as_seq h1 (gsub expanded 0ul 32ul) == a /\ as_seq h1 (gsub expanded 32ul 32ul) == prefix)) [@CInline] let secret_expand expanded secret = assert_norm (pow2 32 <= pow2 125 - 1); Hacl.Streaming.SHA2.hash_512 secret 32ul expanded; let h_low = sub expanded 0ul 32ul in let h_low0 = h_low.( 0ul) in let h_low31 = h_low.(31ul) in h_low.( 0ul) <- h_low0 &. u8 0xf8; h_low.(31ul) <- (h_low31 &. u8 127) |. u8 64 let secret_to_public public_key private_key = push_frame (); let expanded_secret = create 64ul (u8 0) in secret_expand expanded_secret private_key; let a = sub expanded_secret 0ul 32ul in Hacl.Impl.Ed25519.Sign.point_mul_g_compress public_key a; pop_frame () let expand_keys expanded_keys private_key = let public_key = sub expanded_keys 0ul 32ul in let s_prefix = sub expanded_keys 32ul 64ul in let s = sub expanded_keys 32ul 32ul in secret_expand s_prefix private_key; Hacl.Impl.Ed25519.Sign.point_mul_g_compress public_key s let sign_expanded signature expanded_keys msg_len msg = Hacl.Impl.Ed25519.Sign.sign_expanded signature expanded_keys msg_len msg let sign signature private_key msg_len msg = push_frame (); let expanded_keys = create 96ul (u8 0) in expand_keys expanded_keys private_key; sign_expanded signature expanded_keys msg_len msg; pop_frame ()
false
false
Hacl.Ed25519.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 verify: public_key:lbuffer uint8 32ul -> msg_len:size_t -> msg:lbuffer uint8 msg_len -> signature:lbuffer uint8 64ul -> Stack bool (requires fun h -> live h public_key /\ live h msg /\ live h signature) (ensures fun h0 b h1 -> modifies0 h0 h1 /\ b == Spec.Ed25519.verify (as_seq h0 public_key) (as_seq h0 msg) (as_seq h0 signature))
[]
Hacl.Ed25519.verify
{ "file_name": "code/ed25519/Hacl.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
public_key: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> msg_len: Lib.IntTypes.size_t -> msg: Lib.Buffer.lbuffer Lib.IntTypes.uint8 msg_len -> signature: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> FStar.HyperStack.ST.Stack Prims.bool
{ "end_col": 66, "end_line": 62, "start_col": 2, "start_line": 62 }
FStar.HyperStack.ST.Stack
val sign_expanded: signature:lbuffer uint8 64ul -> expanded_keys:lbuffer uint8 96ul -> msg_len:size_t -> msg:lbuffer uint8 msg_len -> Stack unit (requires fun h -> live h signature /\ live h msg /\ live h expanded_keys /\ disjoint signature msg /\ disjoint signature expanded_keys) (ensures fun h0 _ h1 -> modifies (loc signature) h0 h1 /\ as_seq h1 signature == Spec.Ed25519.sign_expanded (as_seq h0 (gsub expanded_keys 0ul 32ul)) (as_seq h0 (gsub expanded_keys 32ul 32ul)) (as_seq h0 (gsub expanded_keys 64ul 32ul)) (as_seq h0 msg))
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sign_expanded signature expanded_keys msg_len msg = Hacl.Impl.Ed25519.Sign.sign_expanded signature expanded_keys msg_len msg
val sign_expanded: signature:lbuffer uint8 64ul -> expanded_keys:lbuffer uint8 96ul -> msg_len:size_t -> msg:lbuffer uint8 msg_len -> Stack unit (requires fun h -> live h signature /\ live h msg /\ live h expanded_keys /\ disjoint signature msg /\ disjoint signature expanded_keys) (ensures fun h0 _ h1 -> modifies (loc signature) h0 h1 /\ as_seq h1 signature == Spec.Ed25519.sign_expanded (as_seq h0 (gsub expanded_keys 0ul 32ul)) (as_seq h0 (gsub expanded_keys 32ul 32ul)) (as_seq h0 (gsub expanded_keys 64ul 32ul)) (as_seq h0 msg)) let sign_expanded signature expanded_keys msg_len msg =
true
null
false
Hacl.Impl.Ed25519.Sign.sign_expanded signature expanded_keys msg_len msg
{ "checked_file": "Hacl.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Impl.Ed25519.Verify.fst.checked", "Hacl.Impl.Ed25519.Sign.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": true, "source_file": "Hacl.Ed25519.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Hacl.Impl.Ed25519.Sign.sign_expanded", "Prims.unit" ]
[]
module Hacl.Ed25519 module ST = FStar.HyperStack.ST open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer module S = Spec.Ed25519 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val secret_expand: expanded:lbuffer uint8 64ul -> secret:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h expanded /\ live h secret /\ disjoint expanded secret) (ensures fun h0 _ h1 -> modifies (loc expanded) h0 h1 /\ (let a, prefix = S.secret_expand (as_seq h0 secret) in as_seq h1 (gsub expanded 0ul 32ul) == a /\ as_seq h1 (gsub expanded 32ul 32ul) == prefix)) [@CInline] let secret_expand expanded secret = assert_norm (pow2 32 <= pow2 125 - 1); Hacl.Streaming.SHA2.hash_512 secret 32ul expanded; let h_low = sub expanded 0ul 32ul in let h_low0 = h_low.( 0ul) in let h_low31 = h_low.(31ul) in h_low.( 0ul) <- h_low0 &. u8 0xf8; h_low.(31ul) <- (h_low31 &. u8 127) |. u8 64 let secret_to_public public_key private_key = push_frame (); let expanded_secret = create 64ul (u8 0) in secret_expand expanded_secret private_key; let a = sub expanded_secret 0ul 32ul in Hacl.Impl.Ed25519.Sign.point_mul_g_compress public_key a; pop_frame () let expand_keys expanded_keys private_key = let public_key = sub expanded_keys 0ul 32ul in let s_prefix = sub expanded_keys 32ul 64ul in let s = sub expanded_keys 32ul 32ul in secret_expand s_prefix private_key; Hacl.Impl.Ed25519.Sign.point_mul_g_compress public_key s
false
false
Hacl.Ed25519.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_expanded: signature:lbuffer uint8 64ul -> expanded_keys:lbuffer uint8 96ul -> msg_len:size_t -> msg:lbuffer uint8 msg_len -> Stack unit (requires fun h -> live h signature /\ live h msg /\ live h expanded_keys /\ disjoint signature msg /\ disjoint signature expanded_keys) (ensures fun h0 _ h1 -> modifies (loc signature) h0 h1 /\ as_seq h1 signature == Spec.Ed25519.sign_expanded (as_seq h0 (gsub expanded_keys 0ul 32ul)) (as_seq h0 (gsub expanded_keys 32ul 32ul)) (as_seq h0 (gsub expanded_keys 64ul 32ul)) (as_seq h0 msg))
[]
Hacl.Ed25519.sign_expanded
{ "file_name": "code/ed25519/Hacl.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
signature: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> expanded_keys: Lib.Buffer.lbuffer Lib.IntTypes.uint8 96ul -> msg_len: Lib.IntTypes.size_t -> msg: Lib.Buffer.lbuffer Lib.IntTypes.uint8 msg_len -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 74, "end_line": 50, "start_col": 2, "start_line": 50 }
FStar.HyperStack.ST.Stack
val secret_to_public: public_key:lbuffer uint8 32ul -> private_key:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h public_key /\ live h private_key /\ disjoint public_key private_key) (ensures fun h0 _ h1 -> modifies (loc public_key) h0 h1 /\ as_seq h1 public_key == Spec.Ed25519.secret_to_public (as_seq h0 private_key))
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let secret_to_public public_key private_key = push_frame (); let expanded_secret = create 64ul (u8 0) in secret_expand expanded_secret private_key; let a = sub expanded_secret 0ul 32ul in Hacl.Impl.Ed25519.Sign.point_mul_g_compress public_key a; pop_frame ()
val secret_to_public: public_key:lbuffer uint8 32ul -> private_key:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h public_key /\ live h private_key /\ disjoint public_key private_key) (ensures fun h0 _ h1 -> modifies (loc public_key) h0 h1 /\ as_seq h1 public_key == Spec.Ed25519.secret_to_public (as_seq h0 private_key)) let secret_to_public public_key private_key =
true
null
false
push_frame (); let expanded_secret = create 64ul (u8 0) in secret_expand expanded_secret private_key; let a = sub expanded_secret 0ul 32ul in Hacl.Impl.Ed25519.Sign.point_mul_g_compress public_key a; pop_frame ()
{ "checked_file": "Hacl.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Impl.Ed25519.Verify.fst.checked", "Hacl.Impl.Ed25519.Sign.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": true, "source_file": "Hacl.Ed25519.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Ed25519.Sign.point_mul_g_compress", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "Hacl.Ed25519.secret_expand", "Lib.Buffer.create", "Lib.IntTypes.u8", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Ed25519 module ST = FStar.HyperStack.ST open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer module S = Spec.Ed25519 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val secret_expand: expanded:lbuffer uint8 64ul -> secret:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h expanded /\ live h secret /\ disjoint expanded secret) (ensures fun h0 _ h1 -> modifies (loc expanded) h0 h1 /\ (let a, prefix = S.secret_expand (as_seq h0 secret) in as_seq h1 (gsub expanded 0ul 32ul) == a /\ as_seq h1 (gsub expanded 32ul 32ul) == prefix)) [@CInline] let secret_expand expanded secret = assert_norm (pow2 32 <= pow2 125 - 1); Hacl.Streaming.SHA2.hash_512 secret 32ul expanded; let h_low = sub expanded 0ul 32ul in let h_low0 = h_low.( 0ul) in let h_low31 = h_low.(31ul) in h_low.( 0ul) <- h_low0 &. u8 0xf8; h_low.(31ul) <- (h_low31 &. u8 127) |. u8 64
false
false
Hacl.Ed25519.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 secret_to_public: public_key:lbuffer uint8 32ul -> private_key:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h public_key /\ live h private_key /\ disjoint public_key private_key) (ensures fun h0 _ h1 -> modifies (loc public_key) h0 h1 /\ as_seq h1 public_key == Spec.Ed25519.secret_to_public (as_seq h0 private_key))
[]
Hacl.Ed25519.secret_to_public
{ "file_name": "code/ed25519/Hacl.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
public_key: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> private_key: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 38, "start_col": 2, "start_line": 33 }
FStar.HyperStack.ST.Stack
val secret_expand: expanded:lbuffer uint8 64ul -> secret:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h expanded /\ live h secret /\ disjoint expanded secret) (ensures fun h0 _ h1 -> modifies (loc expanded) h0 h1 /\ (let a, prefix = S.secret_expand (as_seq h0 secret) in as_seq h1 (gsub expanded 0ul 32ul) == a /\ as_seq h1 (gsub expanded 32ul 32ul) == prefix))
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let secret_expand expanded secret = assert_norm (pow2 32 <= pow2 125 - 1); Hacl.Streaming.SHA2.hash_512 secret 32ul expanded; let h_low = sub expanded 0ul 32ul in let h_low0 = h_low.( 0ul) in let h_low31 = h_low.(31ul) in h_low.( 0ul) <- h_low0 &. u8 0xf8; h_low.(31ul) <- (h_low31 &. u8 127) |. u8 64
val secret_expand: expanded:lbuffer uint8 64ul -> secret:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h expanded /\ live h secret /\ disjoint expanded secret) (ensures fun h0 _ h1 -> modifies (loc expanded) h0 h1 /\ (let a, prefix = S.secret_expand (as_seq h0 secret) in as_seq h1 (gsub expanded 0ul 32ul) == a /\ as_seq h1 (gsub expanded 32ul 32ul) == prefix)) let secret_expand expanded secret =
true
null
false
assert_norm (pow2 32 <= pow2 125 - 1); Hacl.Streaming.SHA2.hash_512 secret 32ul expanded; let h_low = sub expanded 0ul 32ul in let h_low0 = h_low.(0ul) in let h_low31 = h_low.(31ul) in h_low.(0ul) <- h_low0 &. u8 0xf8; h_low.(31ul) <- (h_low31 &. u8 127) |. u8 64
{ "checked_file": "Hacl.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Impl.Ed25519.Verify.fst.checked", "Hacl.Impl.Ed25519.Sign.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": true, "source_file": "Hacl.Ed25519.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.Buffer.op_Array_Assignment", "Lib.IntTypes.op_Bar_Dot", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.u8", "Prims.unit", "Lib.IntTypes.int_t", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Lib.Buffer.lbuffer_t", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "Hacl.Streaming.SHA2.hash_512", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.pow2", "Prims.op_Subtraction" ]
[]
module Hacl.Ed25519 module ST = FStar.HyperStack.ST open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer module S = Spec.Ed25519 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val secret_expand: expanded:lbuffer uint8 64ul -> secret:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h expanded /\ live h secret /\ disjoint expanded secret) (ensures fun h0 _ h1 -> modifies (loc expanded) h0 h1 /\ (let a, prefix = S.secret_expand (as_seq h0 secret) in as_seq h1 (gsub expanded 0ul 32ul) == a /\ as_seq h1 (gsub expanded 32ul 32ul) == prefix)) [@CInline]
false
false
Hacl.Ed25519.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 secret_expand: expanded:lbuffer uint8 64ul -> secret:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h expanded /\ live h secret /\ disjoint expanded secret) (ensures fun h0 _ h1 -> modifies (loc expanded) h0 h1 /\ (let a, prefix = S.secret_expand (as_seq h0 secret) in as_seq h1 (gsub expanded 0ul 32ul) == a /\ as_seq h1 (gsub expanded 32ul 32ul) == prefix))
[]
Hacl.Ed25519.secret_expand
{ "file_name": "code/ed25519/Hacl.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
expanded: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> secret: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 46, "end_line": 29, "start_col": 2, "start_line": 23 }
FStar.HyperStack.ST.Stack
val expand_keys: expanded_keys:lbuffer uint8 96ul -> private_key:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h expanded_keys /\ live h private_key /\ disjoint expanded_keys private_key) (ensures fun h0 _ h1 -> modifies (loc expanded_keys) h0 h1 /\ (let public_key, s, prefix = Spec.Ed25519.expand_keys (as_seq h0 private_key) in as_seq h1 (gsub expanded_keys 0ul 32ul) == public_key /\ as_seq h1 (gsub expanded_keys 32ul 32ul) == s /\ as_seq h1 (gsub expanded_keys 64ul 32ul) == prefix))
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let expand_keys expanded_keys private_key = let public_key = sub expanded_keys 0ul 32ul in let s_prefix = sub expanded_keys 32ul 64ul in let s = sub expanded_keys 32ul 32ul in secret_expand s_prefix private_key; Hacl.Impl.Ed25519.Sign.point_mul_g_compress public_key s
val expand_keys: expanded_keys:lbuffer uint8 96ul -> private_key:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h expanded_keys /\ live h private_key /\ disjoint expanded_keys private_key) (ensures fun h0 _ h1 -> modifies (loc expanded_keys) h0 h1 /\ (let public_key, s, prefix = Spec.Ed25519.expand_keys (as_seq h0 private_key) in as_seq h1 (gsub expanded_keys 0ul 32ul) == public_key /\ as_seq h1 (gsub expanded_keys 32ul 32ul) == s /\ as_seq h1 (gsub expanded_keys 64ul 32ul) == prefix)) let expand_keys expanded_keys private_key =
true
null
false
let public_key = sub expanded_keys 0ul 32ul in let s_prefix = sub expanded_keys 32ul 64ul in let s = sub expanded_keys 32ul 32ul in secret_expand s_prefix private_key; Hacl.Impl.Ed25519.Sign.point_mul_g_compress public_key s
{ "checked_file": "Hacl.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Impl.Ed25519.Verify.fst.checked", "Hacl.Impl.Ed25519.Sign.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": true, "source_file": "Hacl.Ed25519.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Ed25519.Sign.point_mul_g_compress", "Prims.unit", "Hacl.Ed25519.secret_expand", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub" ]
[]
module Hacl.Ed25519 module ST = FStar.HyperStack.ST open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer module S = Spec.Ed25519 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val secret_expand: expanded:lbuffer uint8 64ul -> secret:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h expanded /\ live h secret /\ disjoint expanded secret) (ensures fun h0 _ h1 -> modifies (loc expanded) h0 h1 /\ (let a, prefix = S.secret_expand (as_seq h0 secret) in as_seq h1 (gsub expanded 0ul 32ul) == a /\ as_seq h1 (gsub expanded 32ul 32ul) == prefix)) [@CInline] let secret_expand expanded secret = assert_norm (pow2 32 <= pow2 125 - 1); Hacl.Streaming.SHA2.hash_512 secret 32ul expanded; let h_low = sub expanded 0ul 32ul in let h_low0 = h_low.( 0ul) in let h_low31 = h_low.(31ul) in h_low.( 0ul) <- h_low0 &. u8 0xf8; h_low.(31ul) <- (h_low31 &. u8 127) |. u8 64 let secret_to_public public_key private_key = push_frame (); let expanded_secret = create 64ul (u8 0) in secret_expand expanded_secret private_key; let a = sub expanded_secret 0ul 32ul in Hacl.Impl.Ed25519.Sign.point_mul_g_compress public_key a; pop_frame ()
false
false
Hacl.Ed25519.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 expand_keys: expanded_keys:lbuffer uint8 96ul -> private_key:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h expanded_keys /\ live h private_key /\ disjoint expanded_keys private_key) (ensures fun h0 _ h1 -> modifies (loc expanded_keys) h0 h1 /\ (let public_key, s, prefix = Spec.Ed25519.expand_keys (as_seq h0 private_key) in as_seq h1 (gsub expanded_keys 0ul 32ul) == public_key /\ as_seq h1 (gsub expanded_keys 32ul 32ul) == s /\ as_seq h1 (gsub expanded_keys 64ul 32ul) == prefix))
[]
Hacl.Ed25519.expand_keys
{ "file_name": "code/ed25519/Hacl.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
expanded_keys: Lib.Buffer.lbuffer Lib.IntTypes.uint8 96ul -> private_key: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 58, "end_line": 46, "start_col": 43, "start_line": 41 }
FStar.HyperStack.ST.Stack
val sign: signature:lbuffer uint8 64ul -> private_key:lbuffer uint8 32ul -> msg_len:size_t -> msg:lbuffer uint8 msg_len -> Stack unit (requires fun h -> live h signature /\ live h msg /\ live h private_key /\ disjoint signature msg /\ disjoint signature private_key) (ensures fun h0 _ h1 -> modifies (loc signature) h0 h1 /\ as_seq h1 signature == Spec.Ed25519.sign (as_seq h0 private_key) (as_seq h0 msg))
[ { "abbrev": true, "full_module": "Spec.Ed25519", "short_module": "S" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sign signature private_key msg_len msg = push_frame (); let expanded_keys = create 96ul (u8 0) in expand_keys expanded_keys private_key; sign_expanded signature expanded_keys msg_len msg; pop_frame ()
val sign: signature:lbuffer uint8 64ul -> private_key:lbuffer uint8 32ul -> msg_len:size_t -> msg:lbuffer uint8 msg_len -> Stack unit (requires fun h -> live h signature /\ live h msg /\ live h private_key /\ disjoint signature msg /\ disjoint signature private_key) (ensures fun h0 _ h1 -> modifies (loc signature) h0 h1 /\ as_seq h1 signature == Spec.Ed25519.sign (as_seq h0 private_key) (as_seq h0 msg)) let sign signature private_key msg_len msg =
true
null
false
push_frame (); let expanded_keys = create 96ul (u8 0) in expand_keys expanded_keys private_key; sign_expanded signature expanded_keys msg_len msg; pop_frame ()
{ "checked_file": "Hacl.Ed25519.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Streaming.SHA2.fst.checked", "Hacl.Impl.Ed25519.Verify.fst.checked", "Hacl.Impl.Ed25519.Sign.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": true, "source_file": "Hacl.Ed25519.fst" }
[]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Ed25519.sign_expanded", "Hacl.Ed25519.expand_keys", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.u8", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Ed25519 module ST = FStar.HyperStack.ST open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer module S = Spec.Ed25519 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" val secret_expand: expanded:lbuffer uint8 64ul -> secret:lbuffer uint8 32ul -> Stack unit (requires fun h -> live h expanded /\ live h secret /\ disjoint expanded secret) (ensures fun h0 _ h1 -> modifies (loc expanded) h0 h1 /\ (let a, prefix = S.secret_expand (as_seq h0 secret) in as_seq h1 (gsub expanded 0ul 32ul) == a /\ as_seq h1 (gsub expanded 32ul 32ul) == prefix)) [@CInline] let secret_expand expanded secret = assert_norm (pow2 32 <= pow2 125 - 1); Hacl.Streaming.SHA2.hash_512 secret 32ul expanded; let h_low = sub expanded 0ul 32ul in let h_low0 = h_low.( 0ul) in let h_low31 = h_low.(31ul) in h_low.( 0ul) <- h_low0 &. u8 0xf8; h_low.(31ul) <- (h_low31 &. u8 127) |. u8 64 let secret_to_public public_key private_key = push_frame (); let expanded_secret = create 64ul (u8 0) in secret_expand expanded_secret private_key; let a = sub expanded_secret 0ul 32ul in Hacl.Impl.Ed25519.Sign.point_mul_g_compress public_key a; pop_frame () let expand_keys expanded_keys private_key = let public_key = sub expanded_keys 0ul 32ul in let s_prefix = sub expanded_keys 32ul 64ul in let s = sub expanded_keys 32ul 32ul in secret_expand s_prefix private_key; Hacl.Impl.Ed25519.Sign.point_mul_g_compress public_key s let sign_expanded signature expanded_keys msg_len msg = Hacl.Impl.Ed25519.Sign.sign_expanded signature expanded_keys msg_len msg
false
false
Hacl.Ed25519.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: signature:lbuffer uint8 64ul -> private_key:lbuffer uint8 32ul -> msg_len:size_t -> msg:lbuffer uint8 msg_len -> Stack unit (requires fun h -> live h signature /\ live h msg /\ live h private_key /\ disjoint signature msg /\ disjoint signature private_key) (ensures fun h0 _ h1 -> modifies (loc signature) h0 h1 /\ as_seq h1 signature == Spec.Ed25519.sign (as_seq h0 private_key) (as_seq h0 msg))
[]
Hacl.Ed25519.sign
{ "file_name": "code/ed25519/Hacl.Ed25519.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
signature: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> private_key: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> msg_len: Lib.IntTypes.size_t -> msg: Lib.Buffer.lbuffer Lib.IntTypes.uint8 msg_len -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 58, "start_col": 2, "start_line": 54 }
Prims.Tot
val sel: #key:eqtype -> #value:Type -> t key value -> key -> Tot value
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sel #key #value m k = m.mappings k
val sel: #key:eqtype -> #value:Type -> t key value -> key -> Tot value let sel #key #value m k =
false
null
false
m.mappings k
{ "checked_file": "FStar.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.Map.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.Map.t", "FStar.Map.__proj__Mkt__item__mappings" ]
[]
(* 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. *) (** * Implementation of partial maps with extensional equality *) module FStar.Map open FStar.Set open FStar.FunctionalExtensionality module S = FStar.Set module F = FStar.FunctionalExtensionality (* The main "trick" in the representation of the type `t` * is to use a domain-restricted function type `key ^-> value` * from the FStar.FunctionalExtensionality library. * These restricted function types enjoy extensional equality, * which is necessary if Map.t is to also enjoy extensional equality. *) noeq type t (key:eqtype) (value:Type) = { mappings: key ^-> value; domain: set key }
false
false
FStar.Map.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 sel: #key:eqtype -> #value:Type -> t key value -> key -> Tot value
[]
FStar.Map.sel
{ "file_name": "ulib/FStar.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Map.t key value -> k: key -> value
{ "end_col": 38, "end_line": 38, "start_col": 26, "start_line": 38 }
Prims.Tot
val map_literal (#k:eqtype) (#v:Type) (f: k -> Tot v) : t k v
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let map_literal #k #v f = { mappings = F.on k f; domain = complement empty; }
val map_literal (#k:eqtype) (#v:Type) (f: k -> Tot v) : t k v let map_literal #k #v f =
false
null
false
{ mappings = F.on k f; domain = complement empty }
{ "checked_file": "FStar.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.Map.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.Map.Mkt", "FStar.FunctionalExtensionality.on", "FStar.Set.complement", "FStar.Set.empty", "FStar.Map.t" ]
[]
(* 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. *) (** * Implementation of partial maps with extensional equality *) module FStar.Map open FStar.Set open FStar.FunctionalExtensionality module S = FStar.Set module F = FStar.FunctionalExtensionality (* The main "trick" in the representation of the type `t` * is to use a domain-restricted function type `key ^-> value` * from the FStar.FunctionalExtensionality library. * These restricted function types enjoy extensional equality, * which is necessary if Map.t is to also enjoy extensional equality. *) noeq type t (key:eqtype) (value:Type) = { mappings: key ^-> value; domain: set key } let sel #key #value m k = m.mappings k (* Since mappings are restricted functions, assignments to that field must use `F.on` to restrict the domain of the functional maps *) let upd #key #value m k v = { mappings = F.on key (fun x -> if x = k then v else m.mappings x); domain = S.union m.domain (singleton k) } (* idem *) let const #key #value v = { mappings = F.on key (fun _ -> v); domain = complement empty } let domain #key #value m = m.domain let contains #key #value m k = mem k m.domain (* Again, use F.on to build a domain-restricted function *) let concat #key #value m1 m2 = { mappings = F.on key (fun x -> if mem x m2.domain then m2.mappings x else m1.mappings x); domain = union m1.domain m2.domain } let map_val #_ #_ f #key m = { mappings = F.on key (fun x -> f (m.mappings x)); domain = m.domain } let restrict #key #value s m = { mappings = m.mappings; domain = intersect s m.domain }
false
false
FStar.Map.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 map_literal (#k:eqtype) (#v:Type) (f: k -> Tot v) : t k v
[]
FStar.Map.map_literal
{ "file_name": "ulib/FStar.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: k -> v) -> FStar.Map.t k v
{ "end_col": 28, "end_line": 76, "start_col": 2, "start_line": 75 }
Prims.Tot
val contains: #key:eqtype -> #value:Type -> t key value -> key -> Tot bool
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let contains #key #value m k = mem k m.domain
val contains: #key:eqtype -> #value:Type -> t key value -> key -> Tot bool let contains #key #value m k =
false
null
false
mem k m.domain
{ "checked_file": "FStar.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.Map.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.Map.t", "FStar.Set.mem", "FStar.Map.__proj__Mkt__item__domain", "Prims.bool" ]
[]
(* 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. *) (** * Implementation of partial maps with extensional equality *) module FStar.Map open FStar.Set open FStar.FunctionalExtensionality module S = FStar.Set module F = FStar.FunctionalExtensionality (* The main "trick" in the representation of the type `t` * is to use a domain-restricted function type `key ^-> value` * from the FStar.FunctionalExtensionality library. * These restricted function types enjoy extensional equality, * which is necessary if Map.t is to also enjoy extensional equality. *) noeq type t (key:eqtype) (value:Type) = { mappings: key ^-> value; domain: set key } let sel #key #value m k = m.mappings k (* Since mappings are restricted functions, assignments to that field must use `F.on` to restrict the domain of the functional maps *) let upd #key #value m k v = { mappings = F.on key (fun x -> if x = k then v else m.mappings x); domain = S.union m.domain (singleton k) } (* idem *) let const #key #value v = { mappings = F.on key (fun _ -> v); domain = complement empty } let domain #key #value m = m.domain
false
false
FStar.Map.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 contains: #key:eqtype -> #value:Type -> t key value -> key -> Tot bool
[]
FStar.Map.contains
{ "file_name": "ulib/FStar.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Map.t key value -> k: key -> Prims.bool
{ "end_col": 45, "end_line": 56, "start_col": 31, "start_line": 56 }
Prims.Tot
val concat: #key:eqtype -> #value:Type -> t key value -> t key value -> Tot (t key value)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let concat #key #value m1 m2 = { mappings = F.on key (fun x -> if mem x m2.domain then m2.mappings x else m1.mappings x); domain = union m1.domain m2.domain }
val concat: #key:eqtype -> #value:Type -> t key value -> t key value -> Tot (t key value) let concat #key #value m1 m2 =
false
null
false
{ mappings = F.on key (fun x -> if mem x m2.domain then m2.mappings x else m1.mappings x); domain = union m1.domain m2.domain }
{ "checked_file": "FStar.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.Map.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.Map.t", "FStar.Map.Mkt", "FStar.FunctionalExtensionality.on", "FStar.Set.mem", "FStar.Map.__proj__Mkt__item__domain", "FStar.Map.__proj__Mkt__item__mappings", "Prims.bool", "FStar.Set.union" ]
[]
(* 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. *) (** * Implementation of partial maps with extensional equality *) module FStar.Map open FStar.Set open FStar.FunctionalExtensionality module S = FStar.Set module F = FStar.FunctionalExtensionality (* The main "trick" in the representation of the type `t` * is to use a domain-restricted function type `key ^-> value` * from the FStar.FunctionalExtensionality library. * These restricted function types enjoy extensional equality, * which is necessary if Map.t is to also enjoy extensional equality. *) noeq type t (key:eqtype) (value:Type) = { mappings: key ^-> value; domain: set key } let sel #key #value m k = m.mappings k (* Since mappings are restricted functions, assignments to that field must use `F.on` to restrict the domain of the functional maps *) let upd #key #value m k v = { mappings = F.on key (fun x -> if x = k then v else m.mappings x); domain = S.union m.domain (singleton k) } (* idem *) let const #key #value v = { mappings = F.on key (fun _ -> v); domain = complement empty } let domain #key #value m = m.domain let contains #key #value m k = mem k m.domain (* Again, use F.on to build a domain-restricted function *)
false
false
FStar.Map.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 concat: #key:eqtype -> #value:Type -> t key value -> t key value -> Tot (t key value)
[]
FStar.Map.concat
{ "file_name": "ulib/FStar.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m1: FStar.Map.t key value -> m2: FStar.Map.t key value -> FStar.Map.t key value
{ "end_col": 38, "end_line": 61, "start_col": 2, "start_line": 60 }
Prims.Tot
val const: #key:eqtype -> #value:Type -> value -> Tot (t key value)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let const #key #value v = { mappings = F.on key (fun _ -> v); domain = complement empty }
val const: #key:eqtype -> #value:Type -> value -> Tot (t key value) let const #key #value v =
false
null
false
{ mappings = F.on key (fun _ -> v); domain = complement empty }
{ "checked_file": "FStar.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.Map.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.Map.Mkt", "FStar.FunctionalExtensionality.on", "FStar.Set.complement", "FStar.Set.empty", "FStar.Map.t" ]
[]
(* 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. *) (** * Implementation of partial maps with extensional equality *) module FStar.Map open FStar.Set open FStar.FunctionalExtensionality module S = FStar.Set module F = FStar.FunctionalExtensionality (* The main "trick" in the representation of the type `t` * is to use a domain-restricted function type `key ^-> value` * from the FStar.FunctionalExtensionality library. * These restricted function types enjoy extensional equality, * which is necessary if Map.t is to also enjoy extensional equality. *) noeq type t (key:eqtype) (value:Type) = { mappings: key ^-> value; domain: set key } let sel #key #value m k = m.mappings k (* Since mappings are restricted functions, assignments to that field must use `F.on` to restrict the domain of the functional maps *) let upd #key #value m k v = { mappings = F.on key (fun x -> if x = k then v else m.mappings x); domain = S.union m.domain (singleton k) } (* idem *)
false
false
FStar.Map.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 const: #key:eqtype -> #value:Type -> value -> Tot (t key value)
[]
FStar.Map.const
{ "file_name": "ulib/FStar.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
v: value -> FStar.Map.t key value
{ "end_col": 29, "end_line": 51, "start_col": 2, "start_line": 50 }
Prims.Tot
val map_val: #val1:Type -> #val2:Type -> f:(val1 -> val2) -> #key:eqtype -> t key val1 -> Tot (t key val2)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let map_val #_ #_ f #key m = { mappings = F.on key (fun x -> f (m.mappings x)); domain = m.domain }
val map_val: #val1:Type -> #val2:Type -> f:(val1 -> val2) -> #key:eqtype -> t key val1 -> Tot (t key val2) let map_val #_ #_ f #key m =
false
null
false
{ mappings = F.on key (fun x -> f (m.mappings x)); domain = m.domain }
{ "checked_file": "FStar.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.Map.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.Map.t", "FStar.Map.Mkt", "FStar.FunctionalExtensionality.on", "FStar.Map.__proj__Mkt__item__mappings", "FStar.Map.__proj__Mkt__item__domain" ]
[]
(* 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. *) (** * Implementation of partial maps with extensional equality *) module FStar.Map open FStar.Set open FStar.FunctionalExtensionality module S = FStar.Set module F = FStar.FunctionalExtensionality (* The main "trick" in the representation of the type `t` * is to use a domain-restricted function type `key ^-> value` * from the FStar.FunctionalExtensionality library. * These restricted function types enjoy extensional equality, * which is necessary if Map.t is to also enjoy extensional equality. *) noeq type t (key:eqtype) (value:Type) = { mappings: key ^-> value; domain: set key } let sel #key #value m k = m.mappings k (* Since mappings are restricted functions, assignments to that field must use `F.on` to restrict the domain of the functional maps *) let upd #key #value m k v = { mappings = F.on key (fun x -> if x = k then v else m.mappings x); domain = S.union m.domain (singleton k) } (* idem *) let const #key #value v = { mappings = F.on key (fun _ -> v); domain = complement empty } let domain #key #value m = m.domain let contains #key #value m k = mem k m.domain (* Again, use F.on to build a domain-restricted function *) let concat #key #value m1 m2 = { mappings = F.on key (fun x -> if mem x m2.domain then m2.mappings x else m1.mappings x); domain = union m1.domain m2.domain }
false
false
FStar.Map.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 map_val: #val1:Type -> #val2:Type -> f:(val1 -> val2) -> #key:eqtype -> t key val1 -> Tot (t key val2)
[]
FStar.Map.map_val
{ "file_name": "ulib/FStar.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
f: (_: val1 -> val2) -> m: FStar.Map.t key val1 -> FStar.Map.t key val2
{ "end_col": 21, "end_line": 66, "start_col": 2, "start_line": 65 }
Prims.Tot
val restrict: #key:eqtype -> #value:Type -> S.set key -> t key value -> Tot (t key value)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let restrict #key #value s m = { mappings = m.mappings; domain = intersect s m.domain }
val restrict: #key:eqtype -> #value:Type -> S.set key -> t key value -> Tot (t key value) let restrict #key #value s m =
false
null
false
{ mappings = m.mappings; domain = intersect s m.domain }
{ "checked_file": "FStar.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.Map.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.Set.set", "FStar.Map.t", "FStar.Map.Mkt", "FStar.Map.__proj__Mkt__item__mappings", "FStar.Set.intersect", "FStar.Map.__proj__Mkt__item__domain" ]
[]
(* 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. *) (** * Implementation of partial maps with extensional equality *) module FStar.Map open FStar.Set open FStar.FunctionalExtensionality module S = FStar.Set module F = FStar.FunctionalExtensionality (* The main "trick" in the representation of the type `t` * is to use a domain-restricted function type `key ^-> value` * from the FStar.FunctionalExtensionality library. * These restricted function types enjoy extensional equality, * which is necessary if Map.t is to also enjoy extensional equality. *) noeq type t (key:eqtype) (value:Type) = { mappings: key ^-> value; domain: set key } let sel #key #value m k = m.mappings k (* Since mappings are restricted functions, assignments to that field must use `F.on` to restrict the domain of the functional maps *) let upd #key #value m k v = { mappings = F.on key (fun x -> if x = k then v else m.mappings x); domain = S.union m.domain (singleton k) } (* idem *) let const #key #value v = { mappings = F.on key (fun _ -> v); domain = complement empty } let domain #key #value m = m.domain let contains #key #value m k = mem k m.domain (* Again, use F.on to build a domain-restricted function *) let concat #key #value m1 m2 = { mappings = F.on key (fun x -> if mem x m2.domain then m2.mappings x else m1.mappings x); domain = union m1.domain m2.domain } let map_val #_ #_ f #key m = { mappings = F.on key (fun x -> f (m.mappings x)); domain = m.domain }
false
false
FStar.Map.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 restrict: #key:eqtype -> #value:Type -> S.set key -> t key value -> Tot (t key value)
[]
FStar.Map.restrict
{ "file_name": "ulib/FStar.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: FStar.Set.set key -> m: FStar.Map.t key value -> FStar.Map.t key value
{ "end_col": 33, "end_line": 71, "start_col": 2, "start_line": 70 }
Prims.Tot
val domain: #key:eqtype -> #value:Type -> t key value -> Tot (S.set key)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let domain #key #value m = m.domain
val domain: #key:eqtype -> #value:Type -> t key value -> Tot (S.set key) let domain #key #value m =
false
null
false
m.domain
{ "checked_file": "FStar.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.Map.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.Map.t", "FStar.Map.__proj__Mkt__item__domain", "FStar.Set.set" ]
[]
(* 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. *) (** * Implementation of partial maps with extensional equality *) module FStar.Map open FStar.Set open FStar.FunctionalExtensionality module S = FStar.Set module F = FStar.FunctionalExtensionality (* The main "trick" in the representation of the type `t` * is to use a domain-restricted function type `key ^-> value` * from the FStar.FunctionalExtensionality library. * These restricted function types enjoy extensional equality, * which is necessary if Map.t is to also enjoy extensional equality. *) noeq type t (key:eqtype) (value:Type) = { mappings: key ^-> value; domain: set key } let sel #key #value m k = m.mappings k (* Since mappings are restricted functions, assignments to that field must use `F.on` to restrict the domain of the functional maps *) let upd #key #value m k v = { mappings = F.on key (fun x -> if x = k then v else m.mappings x); domain = S.union m.domain (singleton k) } (* idem *) let const #key #value v = { mappings = F.on key (fun _ -> v); domain = complement empty }
false
false
FStar.Map.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 domain: #key:eqtype -> #value:Type -> t key value -> Tot (S.set key)
[]
FStar.Map.domain
{ "file_name": "ulib/FStar.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Map.t key value -> FStar.Set.set key
{ "end_col": 35, "end_line": 54, "start_col": 27, "start_line": 54 }
Prims.Tot
val upd: #key:eqtype -> #value:Type -> t key value -> key -> value -> Tot (t key value)
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let upd #key #value m k v = { mappings = F.on key (fun x -> if x = k then v else m.mappings x); domain = S.union m.domain (singleton k) }
val upd: #key:eqtype -> #value:Type -> t key value -> key -> value -> Tot (t key value) let upd #key #value m k v =
false
null
false
{ mappings = F.on key (fun x -> if x = k then v else m.mappings x); domain = S.union m.domain (singleton k) }
{ "checked_file": "FStar.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.Map.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.Map.t", "FStar.Map.Mkt", "FStar.FunctionalExtensionality.on", "Prims.op_Equality", "Prims.bool", "FStar.Map.__proj__Mkt__item__mappings", "FStar.Set.union", "FStar.Map.__proj__Mkt__item__domain", "FStar.Set.singleton" ]
[]
(* 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. *) (** * Implementation of partial maps with extensional equality *) module FStar.Map open FStar.Set open FStar.FunctionalExtensionality module S = FStar.Set module F = FStar.FunctionalExtensionality (* The main "trick" in the representation of the type `t` * is to use a domain-restricted function type `key ^-> value` * from the FStar.FunctionalExtensionality library. * These restricted function types enjoy extensional equality, * which is necessary if Map.t is to also enjoy extensional equality. *) noeq type t (key:eqtype) (value:Type) = { mappings: key ^-> value; domain: set key } let sel #key #value m k = m.mappings k (* Since mappings are restricted functions, assignments to that field must use `F.on` to restrict the domain of the functional maps *)
false
false
FStar.Map.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 upd: #key:eqtype -> #value:Type -> t key value -> key -> value -> Tot (t key value)
[]
FStar.Map.upd
{ "file_name": "ulib/FStar.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Map.t key value -> k: key -> v: value -> FStar.Map.t key value
{ "end_col": 43, "end_line": 45, "start_col": 2, "start_line": 44 }
Prims.Tot
val equal (#key:eqtype) (#value:Type) (m1:t key value) (m2:t key value) : prop
[ { "abbrev": true, "full_module": "FStar.FunctionalExtensionality", "short_module": "F" }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar.FunctionalExtensionality", "short_module": null }, { "abbrev": false, "full_module": "FStar.Set", "short_module": null }, { "abbrev": true, "full_module": "FStar.Set", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let equal (#key:eqtype) (#value:Type) (m1:t key value) (m2:t key value) : Type0 = F.feq m1.mappings m2.mappings /\ S.equal m1.domain m2.domain
val equal (#key:eqtype) (#value:Type) (m1:t key value) (m2:t key value) : prop let equal (#key: eqtype) (#value: Type) (m1 m2: t key value) : Type0 =
false
null
false
F.feq m1.mappings m2.mappings /\ S.equal m1.domain m2.domain
{ "checked_file": "FStar.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": true, "source_file": "FStar.Map.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.Map.t", "Prims.l_and", "FStar.FunctionalExtensionality.feq", "FStar.Map.__proj__Mkt__item__mappings", "FStar.Set.equal", "FStar.Map.__proj__Mkt__item__domain", "Prims.prop" ]
[]
(* 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. *) (** * Implementation of partial maps with extensional equality *) module FStar.Map open FStar.Set open FStar.FunctionalExtensionality module S = FStar.Set module F = FStar.FunctionalExtensionality (* The main "trick" in the representation of the type `t` * is to use a domain-restricted function type `key ^-> value` * from the FStar.FunctionalExtensionality library. * These restricted function types enjoy extensional equality, * which is necessary if Map.t is to also enjoy extensional equality. *) noeq type t (key:eqtype) (value:Type) = { mappings: key ^-> value; domain: set key } let sel #key #value m k = m.mappings k (* Since mappings are restricted functions, assignments to that field must use `F.on` to restrict the domain of the functional maps *) let upd #key #value m k v = { mappings = F.on key (fun x -> if x = k then v else m.mappings x); domain = S.union m.domain (singleton k) } (* idem *) let const #key #value v = { mappings = F.on key (fun _ -> v); domain = complement empty } let domain #key #value m = m.domain let contains #key #value m k = mem k m.domain (* Again, use F.on to build a domain-restricted function *) let concat #key #value m1 m2 = { mappings = F.on key (fun x -> if mem x m2.domain then m2.mappings x else m1.mappings x); domain = union m1.domain m2.domain } let map_val #_ #_ f #key m = { mappings = F.on key (fun x -> f (m.mappings x)); domain = m.domain } let restrict #key #value s m = { mappings = m.mappings; domain = intersect s m.domain } let map_literal #k #v f = { mappings = F.on k f; domain = complement empty; } let lemma_SelUpd1 #key #value m k v = () let lemma_SelUpd2 #key #value m k1 k2 v = () let lemma_SelConst #key #value v k = () let lemma_SelRestrict #key #value m ks k = () let lemma_SelConcat1 #key #value m1 m2 k = () let lemma_SelConcat2 #key #value m1 m2 k = () let lemma_SelMapVal #val1 #val2 f #key m k = () let lemma_InDomUpd1 #key #value m k1 k2 v = () let lemma_InDomUpd2 #key #value m k1 k2 v = () let lemma_InDomConstMap #key #value v k = () let lemma_InDomConcat #key #value m1 m2 k = () let lemma_InMapVal #val1 #val2 f #key m k = () let lemma_InDomRestrict #key #value m ks k = () let lemma_ContainsDom #key #value m k = () let lemma_UpdDomain #key #value m k v = () let lemma_map_literal #key #value f = ()
false
false
FStar.Map.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 equal (#key:eqtype) (#value:Type) (m1:t key value) (m2:t key value) : prop
[]
FStar.Map.equal
{ "file_name": "ulib/FStar.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m1: FStar.Map.t key value -> m2: FStar.Map.t key value -> Prims.prop
{ "end_col": 31, "end_line": 98, "start_col": 4, "start_line": 97 }
Prims.Tot
val max (x1 x2: nat) : Tot nat
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowParse.Low.BitSum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let max (x1 x2: nat) : Tot nat = if x1 > x2 then x1 else x2
val max (x1 x2: nat) : Tot nat let max (x1 x2: nat) : Tot nat =
false
null
false
if x1 > x2 then x1 else x2
{ "checked_file": "LowParse.Low.Writers.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Endianness.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Low.Writers.fst.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Low.Bytes.fst.checked", "LowParse.Low.BitSum.fst.checked", "LowParse.Endianness.BitFields.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Writers.Instances.fst" }
[ "total" ]
[ "Prims.nat", "Prims.op_GreaterThan", "Prims.bool" ]
[]
module LowParse.Low.Writers.Instances include LowParse.Low.Writers include LowParse.Low.Combinators include LowParse.Low.Bytes include LowParse.Low.BitSum module HS = FStar.HyperStack module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST inline_for_extraction noextract let swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 { (k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong }) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq s1 (swvalue w1); serialized_length_eq (serialize_weaken k2 s1) (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_weaken k2 p1 h sout pout_from; res ) inline_for_extraction noextract let swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = SWriter (Ghost.hide (swvalue w1, swvalue w2)) (fun pout_from -> serialized_length_eq (s1 `serialize_nondep_then` s2) (swvalue w1, swvalue w2); serialize_nondep_then_eq s1 s2 (swvalue w1, swvalue w2); serialized_length_eq s1 (swvalue w1); serialized_length_eq s2 (swvalue w2); let pos1 = swrite w1 pout_from in let pos2 = swrite w2 pos1 in let h' = HST.get () in valid_nondep_then h' p1 p2 sout pout_from; pos2 )
false
true
LowParse.Low.Writers.Instances.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 max (x1 x2: nat) : Tot nat
[]
LowParse.Low.Writers.Instances.max
{ "file_name": "src/lowparse/LowParse.Low.Writers.Instances.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
x1: Prims.nat -> x2: Prims.nat -> Prims.nat
{ "end_col": 59, "end_line": 72, "start_col": 33, "start_line": 72 }
Prims.Tot
val swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 {(k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong}) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 {swvalue w2 == swvalue w1} )
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowParse.Low.BitSum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 { (k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong }) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq s1 (swvalue w1); serialized_length_eq (serialize_weaken k2 s1) (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_weaken k2 p1 h sout pout_from; res )
val swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 {(k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong}) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 {swvalue w2 == swvalue w1} ) let swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 {(k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong}) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 {swvalue w2 == swvalue w1} ) =
false
null
false
SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq s1 (swvalue w1); serialized_length_eq (serialize_weaken k2 s1) (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_weaken k2 p1 h sout pout_from; res)
{ "checked_file": "LowParse.Low.Writers.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Endianness.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Low.Writers.fst.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Low.Bytes.fst.checked", "LowParse.Low.BitSum.fst.checked", "LowParse.Endianness.BitFields.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Writers.Instances.fst" }
[ "total" ]
[ "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.slice", "LowParse.Slice.srel_of_buffer_srel", "LowParse.Bytes.byte", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.t", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.nat", "LowParse.Low.Writers.swriter", "Prims.l_and", "LowParse.Spec.Base.is_weaker_than", "LowParse.Low.Writers.SWriter", "LowParse.Spec.Base.weaken", "LowParse.Spec.Combinators.serialize_weaken", "FStar.Ghost.hide", "LowParse.Low.Writers.swvalue", "Prims.unit", "LowParse.Low.Base.valid_weaken", "FStar.HyperStack.ST.get", "LowParse.Low.Writers.swrite", "LowParse.Low.Base.Spec.serialized_length_eq" ]
[]
module LowParse.Low.Writers.Instances include LowParse.Low.Writers include LowParse.Low.Combinators include LowParse.Low.Bytes include LowParse.Low.BitSum module HS = FStar.HyperStack module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST inline_for_extraction noextract let swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 { (k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong }) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1
false
false
LowParse.Low.Writers.Instances.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 swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 {(k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong}) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 {swvalue w2 == swvalue w1} )
[]
LowParse.Low.Writers.Instances.swrite_weaken
{ "file_name": "src/lowparse/LowParse.Low.Writers.Instances.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
k2: LowParse.Spec.Base.parser_kind -> w1: LowParse.Low.Writers.swriter s1 h0 space_beyond sout pout_from0 { LowParse.Spec.Base.is_weaker_than k2 k1 /\ Mkparser_kind'?.parser_kind_subkind k2 == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> w2: LowParse.Low.Writers.swriter (LowParse.Spec.Combinators.serialize_weaken k2 s1) h0 space_beyond sout pout_from0 {LowParse.Low.Writers.swvalue w2 == LowParse.Low.Writers.swvalue w1}
{ "end_col": 3, "end_line": 38, "start_col": 2, "start_line": 31 }
Prims.Tot
val swrite_filter (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (cond: (t1 -> GTot bool)) (w1: swriter s1 h0 space_beyond sout pout_from0 {cond (swvalue w1)}) : Tot (w2: swriter (serialize_filter s1 cond) h0 space_beyond sout pout_from0 {swvalue w2 == swvalue w1})
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowParse.Low.BitSum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let swrite_filter (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (cond: (t1 -> GTot bool)) (w1: swriter s1 h0 space_beyond sout pout_from0 { cond (swvalue w1) } ) : Tot (w2: swriter (serialize_filter s1 cond) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq (serialize_filter s1 cond) (swvalue w1); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_filter h p1 cond sout pout_from; res )
val swrite_filter (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (cond: (t1 -> GTot bool)) (w1: swriter s1 h0 space_beyond sout pout_from0 {cond (swvalue w1)}) : Tot (w2: swriter (serialize_filter s1 cond) h0 space_beyond sout pout_from0 {swvalue w2 == swvalue w1}) let swrite_filter (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (cond: (t1 -> GTot bool)) (w1: swriter s1 h0 space_beyond sout pout_from0 {cond (swvalue w1)}) : Tot (w2: swriter (serialize_filter s1 cond) h0 space_beyond sout pout_from0 {swvalue w2 == swvalue w1}) =
false
null
false
SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq (serialize_filter s1 cond) (swvalue w1); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_filter h p1 cond sout pout_from; res)
{ "checked_file": "LowParse.Low.Writers.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Endianness.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Low.Writers.fst.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Low.Bytes.fst.checked", "LowParse.Low.BitSum.fst.checked", "LowParse.Endianness.BitFields.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Writers.Instances.fst" }
[ "total" ]
[ "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.slice", "LowParse.Slice.srel_of_buffer_srel", "LowParse.Bytes.byte", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.t", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.nat", "Prims.bool", "LowParse.Low.Writers.swriter", "Prims.b2t", "LowParse.Low.Writers.swvalue", "LowParse.Low.Writers.SWriter", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.Combinators.serialize_filter", "FStar.Ghost.hide", "Prims.unit", "LowParse.Low.Combinators.valid_filter", "FStar.HyperStack.ST.get", "LowParse.Low.Writers.swrite", "LowParse.Low.Base.Spec.serialized_length_eq" ]
[]
module LowParse.Low.Writers.Instances include LowParse.Low.Writers include LowParse.Low.Combinators include LowParse.Low.Bytes include LowParse.Low.BitSum module HS = FStar.HyperStack module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST inline_for_extraction noextract let swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 { (k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong }) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq s1 (swvalue w1); serialized_length_eq (serialize_weaken k2 s1) (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_weaken k2 p1 h sout pout_from; res ) inline_for_extraction noextract let swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = SWriter (Ghost.hide (swvalue w1, swvalue w2)) (fun pout_from -> serialized_length_eq (s1 `serialize_nondep_then` s2) (swvalue w1, swvalue w2); serialize_nondep_then_eq s1 s2 (swvalue w1, swvalue w2); serialized_length_eq s1 (swvalue w1); serialized_length_eq s2 (swvalue w2); let pos1 = swrite w1 pout_from in let pos2 = swrite w2 pos1 in let h' = HST.get () in valid_nondep_then h' p1 p2 sout pout_from; pos2 ) let max (x1 x2: nat) : Tot nat = if x1 > x2 then x1 else x2 inline_for_extraction noextract let swrite_nondep_then (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond1: nat) (w1: swriter s1 h0 space_beyond1 sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (#space_beyond2: nat) (w2: swriter s2 h0 space_beyond2 sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = [@inline_let] let sbmax = space_beyond1 `max` space_beyond2 in weaken_swriter w1 h0 sbmax pout_from0 `swrite_nondep_then'` weaken_swriter w2 h0 sbmax pout_from0 inline_for_extraction noextract let swrite_filter (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (cond: (t1 -> GTot bool)) (w1: swriter s1 h0 space_beyond sout pout_from0 { cond (swvalue w1) } ) : Tot (w2: swriter (serialize_filter s1 cond) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1
false
false
LowParse.Low.Writers.Instances.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 swrite_filter (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (cond: (t1 -> GTot bool)) (w1: swriter s1 h0 space_beyond sout pout_from0 {cond (swvalue w1)}) : Tot (w2: swriter (serialize_filter s1 cond) h0 space_beyond sout pout_from0 {swvalue w2 == swvalue w1})
[]
LowParse.Low.Writers.Instances.swrite_filter
{ "file_name": "src/lowparse/LowParse.Low.Writers.Instances.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
cond: (_: t1 -> Prims.GTot Prims.bool) -> w1: LowParse.Low.Writers.swriter s1 h0 space_beyond sout pout_from0 {cond (LowParse.Low.Writers.swvalue w1)} -> w2: LowParse.Low.Writers.swriter (LowParse.Spec.Combinators.serialize_filter s1 cond) h0 space_beyond sout pout_from0 {LowParse.Low.Writers.swvalue w2 == LowParse.Low.Writers.swvalue w1}
{ "end_col": 3, "end_line": 122, "start_col": 2, "start_line": 115 }
Prims.Tot
val swrite_synth (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#t2: Type) (f12: (t1 -> GTot t2)) (f21: (t2 -> GTot t1)) (prf: squash (synth_injective f12 /\ synth_inverse f12 f21)) : Tot (w2: swriter (serialize_synth p1 f12 s1 f21 ()) h0 space_beyond sout pout_from0 {swvalue w2 == f12 (swvalue w1) /\ swvalue w1 == f21 (swvalue w2)})
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowParse.Low.BitSum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let swrite_synth (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#t2: Type) (f12: (t1 -> GTot t2)) (f21: (t2 -> GTot t1)) (prf: squash ( synth_injective f12 /\ synth_inverse f12 f21 )) : Tot (w2: swriter (serialize_synth p1 f12 s1 f21 ()) h0 space_beyond sout pout_from0 { swvalue w2 == f12 (swvalue w1) /\ swvalue w1 == f21 (swvalue w2) }) = [@inline_let] let _ = serialize_synth_eq p1 f12 s1 f21 () (f12 (swvalue w1)); synth_injective_synth_inverse_synth_inverse_recip f12 f21 () in SWriter (Ghost.hide (f12 (swvalue w1))) (fun pout_from -> serialized_length_eq (serialize_synth p1 f12 s1 f21 ()) (f12 (swvalue w1)); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_synth h p1 f12 sout pout_from; res )
val swrite_synth (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#t2: Type) (f12: (t1 -> GTot t2)) (f21: (t2 -> GTot t1)) (prf: squash (synth_injective f12 /\ synth_inverse f12 f21)) : Tot (w2: swriter (serialize_synth p1 f12 s1 f21 ()) h0 space_beyond sout pout_from0 {swvalue w2 == f12 (swvalue w1) /\ swvalue w1 == f21 (swvalue w2)}) let swrite_synth (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#t2: Type) (f12: (t1 -> GTot t2)) (f21: (t2 -> GTot t1)) (prf: squash (synth_injective f12 /\ synth_inverse f12 f21)) : Tot (w2: swriter (serialize_synth p1 f12 s1 f21 ()) h0 space_beyond sout pout_from0 {swvalue w2 == f12 (swvalue w1) /\ swvalue w1 == f21 (swvalue w2)}) =
false
null
false
[@@ inline_let ]let _ = serialize_synth_eq p1 f12 s1 f21 () (f12 (swvalue w1)); synth_injective_synth_inverse_synth_inverse_recip f12 f21 () in SWriter (Ghost.hide (f12 (swvalue w1))) (fun pout_from -> serialized_length_eq (serialize_synth p1 f12 s1 f21 ()) (f12 (swvalue w1)); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_synth h p1 f12 sout pout_from; res)
{ "checked_file": "LowParse.Low.Writers.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Endianness.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Low.Writers.fst.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Low.Bytes.fst.checked", "LowParse.Low.BitSum.fst.checked", "LowParse.Endianness.BitFields.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Writers.Instances.fst" }
[ "total" ]
[ "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.slice", "LowParse.Slice.srel_of_buffer_srel", "LowParse.Bytes.byte", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.t", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.nat", "LowParse.Low.Writers.swriter", "Prims.squash", "Prims.l_and", "LowParse.Spec.Combinators.synth_injective", "LowParse.Spec.Combinators.synth_inverse", "LowParse.Low.Writers.SWriter", "LowParse.Spec.Combinators.parse_synth", "LowParse.Spec.Combinators.serialize_synth", "FStar.Ghost.hide", "LowParse.Low.Writers.swvalue", "Prims.unit", "LowParse.Low.Combinators.valid_synth", "FStar.HyperStack.ST.get", "LowParse.Low.Writers.swrite", "LowParse.Low.Base.Spec.serialized_length_eq", "LowParse.Spec.Combinators.synth_injective_synth_inverse_synth_inverse_recip", "LowParse.Spec.Combinators.serialize_synth_eq" ]
[]
module LowParse.Low.Writers.Instances include LowParse.Low.Writers include LowParse.Low.Combinators include LowParse.Low.Bytes include LowParse.Low.BitSum module HS = FStar.HyperStack module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST inline_for_extraction noextract let swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 { (k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong }) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq s1 (swvalue w1); serialized_length_eq (serialize_weaken k2 s1) (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_weaken k2 p1 h sout pout_from; res ) inline_for_extraction noextract let swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = SWriter (Ghost.hide (swvalue w1, swvalue w2)) (fun pout_from -> serialized_length_eq (s1 `serialize_nondep_then` s2) (swvalue w1, swvalue w2); serialize_nondep_then_eq s1 s2 (swvalue w1, swvalue w2); serialized_length_eq s1 (swvalue w1); serialized_length_eq s2 (swvalue w2); let pos1 = swrite w1 pout_from in let pos2 = swrite w2 pos1 in let h' = HST.get () in valid_nondep_then h' p1 p2 sout pout_from; pos2 ) let max (x1 x2: nat) : Tot nat = if x1 > x2 then x1 else x2 inline_for_extraction noextract let swrite_nondep_then (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond1: nat) (w1: swriter s1 h0 space_beyond1 sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (#space_beyond2: nat) (w2: swriter s2 h0 space_beyond2 sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = [@inline_let] let sbmax = space_beyond1 `max` space_beyond2 in weaken_swriter w1 h0 sbmax pout_from0 `swrite_nondep_then'` weaken_swriter w2 h0 sbmax pout_from0 inline_for_extraction noextract let swrite_filter (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (cond: (t1 -> GTot bool)) (w1: swriter s1 h0 space_beyond sout pout_from0 { cond (swvalue w1) } ) : Tot (w2: swriter (serialize_filter s1 cond) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq (serialize_filter s1 cond) (swvalue w1); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_filter h p1 cond sout pout_from; res ) inline_for_extraction noextract let swrite_synth (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#t2: Type) (f12: (t1 -> GTot t2)) (f21: (t2 -> GTot t1)) (prf: squash ( synth_injective f12 /\ synth_inverse f12 f21 )) : Tot (w2: swriter (serialize_synth p1 f12 s1 f21 ()) h0 space_beyond sout pout_from0 { swvalue w2 == f12 (swvalue w1) /\ swvalue w1 == f21 (swvalue w2)
false
false
LowParse.Low.Writers.Instances.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 swrite_synth (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#t2: Type) (f12: (t1 -> GTot t2)) (f21: (t2 -> GTot t1)) (prf: squash (synth_injective f12 /\ synth_inverse f12 f21)) : Tot (w2: swriter (serialize_synth p1 f12 s1 f21 ()) h0 space_beyond sout pout_from0 {swvalue w2 == f12 (swvalue w1) /\ swvalue w1 == f21 (swvalue w2)})
[]
LowParse.Low.Writers.Instances.swrite_synth
{ "file_name": "src/lowparse/LowParse.Low.Writers.Instances.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
w1: LowParse.Low.Writers.swriter s1 h0 space_beyond sout pout_from0 -> f12: (_: t1 -> Prims.GTot t2) -> f21: (_: t2 -> Prims.GTot t1) -> prf: Prims.squash (LowParse.Spec.Combinators.synth_injective f12 /\ LowParse.Spec.Combinators.synth_inverse f12 f21) -> w2: LowParse.Low.Writers.swriter (LowParse.Spec.Combinators.serialize_synth p1 f12 s1 f21 ()) h0 space_beyond sout pout_from0 { LowParse.Low.Writers.swvalue w2 == f12 (LowParse.Low.Writers.swvalue w1) /\ LowParse.Low.Writers.swvalue w1 == f21 (LowParse.Low.Writers.swvalue w2) }
{ "end_col": 3, "end_line": 158, "start_col": 2, "start_line": 147 }
Prims.Tot
val swrite_nondep_then (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond1: nat) (w1: swriter s1 h0 space_beyond1 sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 {k2.parser_kind_subkind == Some ParserStrong}) (#space_beyond2: nat) (w2: swriter s2 h0 space_beyond2 sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 {swvalue w == (swvalue w1, swvalue w2)})
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowParse.Low.BitSum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let swrite_nondep_then (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond1: nat) (w1: swriter s1 h0 space_beyond1 sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (#space_beyond2: nat) (w2: swriter s2 h0 space_beyond2 sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = [@inline_let] let sbmax = space_beyond1 `max` space_beyond2 in weaken_swriter w1 h0 sbmax pout_from0 `swrite_nondep_then'` weaken_swriter w2 h0 sbmax pout_from0
val swrite_nondep_then (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond1: nat) (w1: swriter s1 h0 space_beyond1 sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 {k2.parser_kind_subkind == Some ParserStrong}) (#space_beyond2: nat) (w2: swriter s2 h0 space_beyond2 sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 {swvalue w == (swvalue w1, swvalue w2)}) let swrite_nondep_then (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond1: nat) (w1: swriter s1 h0 space_beyond1 sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 {k2.parser_kind_subkind == Some ParserStrong}) (#space_beyond2: nat) (w2: swriter s2 h0 space_beyond2 sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 {swvalue w == (swvalue w1, swvalue w2)}) =
false
null
false
[@@ inline_let ]let sbmax = space_beyond1 `max` space_beyond2 in (weaken_swriter w1 h0 sbmax pout_from0) `swrite_nondep_then'` (weaken_swriter w2 h0 sbmax pout_from0)
{ "checked_file": "LowParse.Low.Writers.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Endianness.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Low.Writers.fst.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Low.Bytes.fst.checked", "LowParse.Low.BitSum.fst.checked", "LowParse.Endianness.BitFields.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Writers.Instances.fst" }
[ "total" ]
[ "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.slice", "LowParse.Slice.srel_of_buffer_srel", "LowParse.Bytes.byte", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.t", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.nat", "LowParse.Low.Writers.swriter", "LowParse.Low.Writers.Instances.swrite_nondep_then'", "LowParse.Low.Writers.weaken_swriter", "LowParse.Low.Writers.Instances.max", "LowParse.Spec.Combinators.and_then_kind", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Combinators.nondep_then", "LowParse.Spec.Combinators.serialize_nondep_then", "LowParse.Low.Writers.swvalue", "FStar.Pervasives.Native.Mktuple2" ]
[]
module LowParse.Low.Writers.Instances include LowParse.Low.Writers include LowParse.Low.Combinators include LowParse.Low.Bytes include LowParse.Low.BitSum module HS = FStar.HyperStack module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST inline_for_extraction noextract let swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 { (k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong }) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq s1 (swvalue w1); serialized_length_eq (serialize_weaken k2 s1) (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_weaken k2 p1 h sout pout_from; res ) inline_for_extraction noextract let swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = SWriter (Ghost.hide (swvalue w1, swvalue w2)) (fun pout_from -> serialized_length_eq (s1 `serialize_nondep_then` s2) (swvalue w1, swvalue w2); serialize_nondep_then_eq s1 s2 (swvalue w1, swvalue w2); serialized_length_eq s1 (swvalue w1); serialized_length_eq s2 (swvalue w2); let pos1 = swrite w1 pout_from in let pos2 = swrite w2 pos1 in let h' = HST.get () in valid_nondep_then h' p1 p2 sout pout_from; pos2 ) let max (x1 x2: nat) : Tot nat = if x1 > x2 then x1 else x2 inline_for_extraction noextract let swrite_nondep_then (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond1: nat) (w1: swriter s1 h0 space_beyond1 sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (#space_beyond2: nat) (w2: swriter s2 h0 space_beyond2 sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 { swvalue w == (swvalue w1, swvalue w2)
false
false
LowParse.Low.Writers.Instances.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 swrite_nondep_then (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond1: nat) (w1: swriter s1 h0 space_beyond1 sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 {k2.parser_kind_subkind == Some ParserStrong}) (#space_beyond2: nat) (w2: swriter s2 h0 space_beyond2 sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 {swvalue w == (swvalue w1, swvalue w2)})
[]
LowParse.Low.Writers.Instances.swrite_nondep_then
{ "file_name": "src/lowparse/LowParse.Low.Writers.Instances.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
w1: LowParse.Low.Writers.swriter s1 h0 space_beyond1 sout pout_from0 -> w2: LowParse.Low.Writers.swriter s2 h0 space_beyond2 sout pout_from0 -> w: LowParse.Low.Writers.swriter (LowParse.Spec.Combinators.serialize_nondep_then s1 s2) h0 (LowParse.Low.Writers.Instances.max space_beyond1 space_beyond2) sout pout_from0 { LowParse.Low.Writers.swvalue w == FStar.Pervasives.Native.Mktuple2 (LowParse.Low.Writers.swvalue w1) (LowParse.Low.Writers.swvalue w2) }
{ "end_col": 99, "end_line": 97, "start_col": 2, "start_line": 95 }
Prims.Tot
val swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 {k2.parser_kind_subkind == Some ParserStrong}) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 {swvalue w == (swvalue w1, swvalue w2)})
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowParse.Low.BitSum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = SWriter (Ghost.hide (swvalue w1, swvalue w2)) (fun pout_from -> serialized_length_eq (s1 `serialize_nondep_then` s2) (swvalue w1, swvalue w2); serialize_nondep_then_eq s1 s2 (swvalue w1, swvalue w2); serialized_length_eq s1 (swvalue w1); serialized_length_eq s2 (swvalue w2); let pos1 = swrite w1 pout_from in let pos2 = swrite w2 pos1 in let h' = HST.get () in valid_nondep_then h' p1 p2 sout pout_from; pos2 )
val swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 {k2.parser_kind_subkind == Some ParserStrong}) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 {swvalue w == (swvalue w1, swvalue w2)}) let swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 {k2.parser_kind_subkind == Some ParserStrong}) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 {swvalue w == (swvalue w1, swvalue w2)}) =
false
null
false
SWriter (Ghost.hide (swvalue w1, swvalue w2)) (fun pout_from -> serialized_length_eq (s1 `serialize_nondep_then` s2) (swvalue w1, swvalue w2); serialize_nondep_then_eq s1 s2 (swvalue w1, swvalue w2); serialized_length_eq s1 (swvalue w1); serialized_length_eq s2 (swvalue w2); let pos1 = swrite w1 pout_from in let pos2 = swrite w2 pos1 in let h' = HST.get () in valid_nondep_then h' p1 p2 sout pout_from; pos2)
{ "checked_file": "LowParse.Low.Writers.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Endianness.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Low.Writers.fst.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Low.Bytes.fst.checked", "LowParse.Low.BitSum.fst.checked", "LowParse.Endianness.BitFields.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Writers.Instances.fst" }
[ "total" ]
[ "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.slice", "LowParse.Slice.srel_of_buffer_srel", "LowParse.Bytes.byte", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.t", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "Prims.nat", "LowParse.Low.Writers.swriter", "LowParse.Low.Writers.SWriter", "LowParse.Spec.Combinators.and_then_kind", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.Combinators.nondep_then", "LowParse.Spec.Combinators.serialize_nondep_then", "FStar.Ghost.hide", "FStar.Pervasives.Native.Mktuple2", "LowParse.Low.Writers.swvalue", "Prims.unit", "LowParse.Low.Combinators.valid_nondep_then", "FStar.HyperStack.ST.get", "LowParse.Low.Writers.swrite", "LowParse.Low.Base.Spec.serialized_length_eq", "LowParse.Spec.Combinators.serialize_nondep_then_eq" ]
[]
module LowParse.Low.Writers.Instances include LowParse.Low.Writers include LowParse.Low.Combinators include LowParse.Low.Bytes include LowParse.Low.BitSum module HS = FStar.HyperStack module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST inline_for_extraction noextract let swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 { (k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong }) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq s1 (swvalue w1); serialized_length_eq (serialize_weaken k2 s1) (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_weaken k2 p1 h sout pout_from; res ) inline_for_extraction noextract let swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 { swvalue w == (swvalue w1, swvalue w2)
false
false
LowParse.Low.Writers.Instances.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 swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 {k1.parser_kind_subkind == Some ParserStrong}) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 {k2.parser_kind_subkind == Some ParserStrong}) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 {swvalue w == (swvalue w1, swvalue w2)})
[]
LowParse.Low.Writers.Instances.swrite_nondep_then'
{ "file_name": "src/lowparse/LowParse.Low.Writers.Instances.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
w1: LowParse.Low.Writers.swriter s1 h0 space_beyond sout pout_from0 -> w2: LowParse.Low.Writers.swriter s2 h0 space_beyond sout pout_from0 -> w: LowParse.Low.Writers.swriter (LowParse.Spec.Combinators.serialize_nondep_then s1 s2) h0 space_beyond sout pout_from0 { LowParse.Low.Writers.swvalue w == FStar.Pervasives.Native.Mktuple2 (LowParse.Low.Writers.swvalue w1) (LowParse.Low.Writers.swvalue w2) }
{ "end_col": 3, "end_line": 70, "start_col": 2, "start_line": 60 }
Prims.Tot
val swrite_flbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0 len: U32.t) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_flbytes (U32.v len)) h0 0 sout pout_from0 {swvalue w == FB.hide (B.as_seq h0 b)})
[ { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "FB" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowParse.Low.BitSum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let swrite_flbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (len: U32.t) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_flbytes (U32.v len)) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_flbytes (U32.v len)) (FB.hide (B.as_seq h0 b)); let payload = B.sub sout.base pout_from len in B.blit b 0ul payload 0ul len; let h = HST.get () in valid_flbytes_intro h (U32.v len) sout pout_from; pout_from `U32.add` len )
val swrite_flbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0 len: U32.t) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_flbytes (U32.v len)) h0 0 sout pout_from0 {swvalue w == FB.hide (B.as_seq h0 b)}) let swrite_flbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0 len: U32.t) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_flbytes (U32.v len)) h0 0 sout pout_from0 {swvalue w == FB.hide (B.as_seq h0 b)}) =
false
null
false
SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_flbytes (U32.v len)) (FB.hide (B.as_seq h0 b)); let payload = B.sub sout.base pout_from len in B.blit b 0ul payload 0ul len; let h = HST.get () in valid_flbytes_intro h (U32.v len) sout pout_from; pout_from `U32.add` len)
{ "checked_file": "LowParse.Low.Writers.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Endianness.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Low.Writers.fst.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Low.Bytes.fst.checked", "LowParse.Low.BitSum.fst.checked", "LowParse.Endianness.BitFields.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Writers.Instances.fst" }
[ "total" ]
[ "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.slice", "LowParse.Slice.srel_of_buffer_srel", "LowParse.Bytes.byte", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.t", "LowStar.Buffer.buffer", "FStar.UInt8.t", "Prims.l_and", "LowStar.Monotonic.Buffer.live", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt32.n", "LowStar.Monotonic.Buffer.length", "FStar.UInt32.v", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.Monotonic.Buffer.loc_buffer", "LowParse.Slice.loc_slice_from", "LowParse.Low.Writers.SWriter", "LowParse.Spec.Base.total_constant_size_parser_kind", "FStar.Bytes.lbytes", "LowParse.Spec.Bytes.parse_flbytes", "LowParse.Spec.Bytes.serialize_flbytes", "FStar.Ghost.hide", "FStar.Bytes.hide", "LowStar.Monotonic.Buffer.as_seq", "FStar.UInt32.add", "Prims.unit", "LowParse.Low.Bytes.valid_flbytes_intro", "FStar.HyperStack.ST.get", "LowStar.Monotonic.Buffer.blit", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.sub", "LowParse.Slice.__proj__Mkslice__item__base", "LowParse.Low.Base.Spec.serialized_length_eq", "LowParse.Low.Writers.swriter", "FStar.Bytes.bytes", "LowParse.Low.Writers.swvalue" ]
[]
module LowParse.Low.Writers.Instances include LowParse.Low.Writers include LowParse.Low.Combinators include LowParse.Low.Bytes include LowParse.Low.BitSum module HS = FStar.HyperStack module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST inline_for_extraction noextract let swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 { (k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong }) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq s1 (swvalue w1); serialized_length_eq (serialize_weaken k2 s1) (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_weaken k2 p1 h sout pout_from; res ) inline_for_extraction noextract let swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = SWriter (Ghost.hide (swvalue w1, swvalue w2)) (fun pout_from -> serialized_length_eq (s1 `serialize_nondep_then` s2) (swvalue w1, swvalue w2); serialize_nondep_then_eq s1 s2 (swvalue w1, swvalue w2); serialized_length_eq s1 (swvalue w1); serialized_length_eq s2 (swvalue w2); let pos1 = swrite w1 pout_from in let pos2 = swrite w2 pos1 in let h' = HST.get () in valid_nondep_then h' p1 p2 sout pout_from; pos2 ) let max (x1 x2: nat) : Tot nat = if x1 > x2 then x1 else x2 inline_for_extraction noextract let swrite_nondep_then (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond1: nat) (w1: swriter s1 h0 space_beyond1 sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (#space_beyond2: nat) (w2: swriter s2 h0 space_beyond2 sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = [@inline_let] let sbmax = space_beyond1 `max` space_beyond2 in weaken_swriter w1 h0 sbmax pout_from0 `swrite_nondep_then'` weaken_swriter w2 h0 sbmax pout_from0 inline_for_extraction noextract let swrite_filter (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (cond: (t1 -> GTot bool)) (w1: swriter s1 h0 space_beyond sout pout_from0 { cond (swvalue w1) } ) : Tot (w2: swriter (serialize_filter s1 cond) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq (serialize_filter s1 cond) (swvalue w1); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_filter h p1 cond sout pout_from; res ) inline_for_extraction noextract let swrite_synth (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#t2: Type) (f12: (t1 -> GTot t2)) (f21: (t2 -> GTot t1)) (prf: squash ( synth_injective f12 /\ synth_inverse f12 f21 )) : Tot (w2: swriter (serialize_synth p1 f12 s1 f21 ()) h0 space_beyond sout pout_from0 { swvalue w2 == f12 (swvalue w1) /\ swvalue w1 == f21 (swvalue w2) }) = [@inline_let] let _ = serialize_synth_eq p1 f12 s1 f21 () (f12 (swvalue w1)); synth_injective_synth_inverse_synth_inverse_recip f12 f21 () in SWriter (Ghost.hide (f12 (swvalue w1))) (fun pout_from -> serialized_length_eq (serialize_synth p1 f12 s1 f21 ()) (f12 (swvalue w1)); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_synth h p1 f12 sout pout_from; res ) module U8 = FStar.UInt8 module FB = FStar.Bytes #push-options "--z3rlimit 16" inline_for_extraction noextract let swrite_flbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (len: U32.t) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_flbytes (U32.v len)) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b)
false
false
LowParse.Low.Writers.Instances.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val swrite_flbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0 len: U32.t) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_flbytes (U32.v len)) h0 0 sout pout_from0 {swvalue w == FB.hide (B.as_seq h0 b)})
[]
LowParse.Low.Writers.Instances.swrite_flbytes
{ "file_name": "src/lowparse/LowParse.Low.Writers.Instances.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
h0: FStar.Monotonic.HyperStack.mem -> sout: LowParse.Slice.slice (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte )) (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte)) -> pout_from0: FStar.UInt32.t -> len: FStar.UInt32.t -> b: LowStar.Buffer.buffer FStar.UInt8.t { LowStar.Monotonic.Buffer.live h0 b /\ LowStar.Monotonic.Buffer.length b == FStar.UInt32.v len /\ LowStar.Monotonic.Buffer.loc_disjoint (LowStar.Monotonic.Buffer.loc_buffer b) (LowParse.Slice.loc_slice_from sout pout_from0) } -> w: LowParse.Low.Writers.swriter (LowParse.Spec.Bytes.serialize_flbytes (FStar.UInt32.v len)) h0 0 sout pout_from0 {LowParse.Low.Writers.swvalue w == FStar.Bytes.hide (LowStar.Monotonic.Buffer.as_seq h0 b)}
{ "end_col": 3, "end_line": 187, "start_col": 2, "start_line": 180 }
Prims.Tot
val swrite_bounded_integer_ct (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) (pout_from0: U32.t) (x: bounded_integer (U32.v i)) : Tot (y: swriter (serialize_bounded_integer (U32.v i)) h0 (4 - U32.v i) sout pout_from0 {swvalue y == x})
[ { "abbrev": true, "full_module": "LowStar.Endianness", "short_module": "LE" }, { "abbrev": true, "full_module": "LowParse.Endianness.BitFields", "short_module": "E" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "FB" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowParse.Low.BitSum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let swrite_bounded_integer_ct (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (pout_from0: U32.t) (x: bounded_integer (U32.v i)) : Tot (y: swriter (serialize_bounded_integer (U32.v i)) h0 (4 - U32.v i) sout pout_from0 { swvalue y == x } ) = SWriter (Ghost.hide x) (fun pout_from -> serialized_length_eq (serialize_bounded_integer (U32.v i)) x; serialize32_bounded_integer_ct i x sout.base pout_from; let h = HST.get () in [@inline_let] let _ = let large = bytes_of_slice_from h sout pout_from in let small = bytes_of_slice_from_to h sout pout_from (pout_from `U32.add` i) in parse_strong_prefix (parse_bounded_integer (U32.v i)) small large; valid_facts (parse_bounded_integer (U32.v i)) h sout pout_from in pout_from `U32.add` i )
val swrite_bounded_integer_ct (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) (pout_from0: U32.t) (x: bounded_integer (U32.v i)) : Tot (y: swriter (serialize_bounded_integer (U32.v i)) h0 (4 - U32.v i) sout pout_from0 {swvalue y == x}) let swrite_bounded_integer_ct (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) (pout_from0: U32.t) (x: bounded_integer (U32.v i)) : Tot (y: swriter (serialize_bounded_integer (U32.v i)) h0 (4 - U32.v i) sout pout_from0 {swvalue y == x}) =
false
null
false
SWriter (Ghost.hide x) (fun pout_from -> serialized_length_eq (serialize_bounded_integer (U32.v i)) x; serialize32_bounded_integer_ct i x sout.base pout_from; let h = HST.get () in [@@ inline_let ]let _ = let large = bytes_of_slice_from h sout pout_from in let small = bytes_of_slice_from_to h sout pout_from (pout_from `U32.add` i) in parse_strong_prefix (parse_bounded_integer (U32.v i)) small large; valid_facts (parse_bounded_integer (U32.v i)) h sout pout_from in pout_from `U32.add` i)
{ "checked_file": "LowParse.Low.Writers.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Endianness.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Low.Writers.fst.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Low.Bytes.fst.checked", "LowParse.Low.BitSum.fst.checked", "LowParse.Endianness.BitFields.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Writers.Instances.fst" }
[ "total" ]
[ "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.slice", "LowParse.Slice.srel_of_buffer_srel", "LowParse.Bytes.byte", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Low.Writers.SWriter", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "Prims.op_Subtraction", "FStar.Ghost.hide", "FStar.UInt32.add", "Prims.unit", "LowParse.Low.Base.Spec.valid_facts", "LowParse.Spec.Base.parse_strong_prefix", "LowParse.Bytes.bytes", "LowParse.Low.Base.Spec.bytes_of_slice_from_to", "LowParse.Slice.bytes_of_slice_from", "FStar.HyperStack.ST.get", "LowParse.Low.Writers.Instances.serialize32_bounded_integer_ct", "LowParse.Slice.__proj__Mkslice__item__base", "LowParse.Low.Base.Spec.serialized_length_eq", "LowParse.Low.Writers.swriter", "Prims.eq2", "LowParse.Low.Writers.swvalue" ]
[]
module LowParse.Low.Writers.Instances include LowParse.Low.Writers include LowParse.Low.Combinators include LowParse.Low.Bytes include LowParse.Low.BitSum module HS = FStar.HyperStack module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST inline_for_extraction noextract let swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 { (k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong }) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq s1 (swvalue w1); serialized_length_eq (serialize_weaken k2 s1) (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_weaken k2 p1 h sout pout_from; res ) inline_for_extraction noextract let swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = SWriter (Ghost.hide (swvalue w1, swvalue w2)) (fun pout_from -> serialized_length_eq (s1 `serialize_nondep_then` s2) (swvalue w1, swvalue w2); serialize_nondep_then_eq s1 s2 (swvalue w1, swvalue w2); serialized_length_eq s1 (swvalue w1); serialized_length_eq s2 (swvalue w2); let pos1 = swrite w1 pout_from in let pos2 = swrite w2 pos1 in let h' = HST.get () in valid_nondep_then h' p1 p2 sout pout_from; pos2 ) let max (x1 x2: nat) : Tot nat = if x1 > x2 then x1 else x2 inline_for_extraction noextract let swrite_nondep_then (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond1: nat) (w1: swriter s1 h0 space_beyond1 sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (#space_beyond2: nat) (w2: swriter s2 h0 space_beyond2 sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = [@inline_let] let sbmax = space_beyond1 `max` space_beyond2 in weaken_swriter w1 h0 sbmax pout_from0 `swrite_nondep_then'` weaken_swriter w2 h0 sbmax pout_from0 inline_for_extraction noextract let swrite_filter (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (cond: (t1 -> GTot bool)) (w1: swriter s1 h0 space_beyond sout pout_from0 { cond (swvalue w1) } ) : Tot (w2: swriter (serialize_filter s1 cond) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq (serialize_filter s1 cond) (swvalue w1); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_filter h p1 cond sout pout_from; res ) inline_for_extraction noextract let swrite_synth (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#t2: Type) (f12: (t1 -> GTot t2)) (f21: (t2 -> GTot t1)) (prf: squash ( synth_injective f12 /\ synth_inverse f12 f21 )) : Tot (w2: swriter (serialize_synth p1 f12 s1 f21 ()) h0 space_beyond sout pout_from0 { swvalue w2 == f12 (swvalue w1) /\ swvalue w1 == f21 (swvalue w2) }) = [@inline_let] let _ = serialize_synth_eq p1 f12 s1 f21 () (f12 (swvalue w1)); synth_injective_synth_inverse_synth_inverse_recip f12 f21 () in SWriter (Ghost.hide (f12 (swvalue w1))) (fun pout_from -> serialized_length_eq (serialize_synth p1 f12 s1 f21 ()) (f12 (swvalue w1)); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_synth h p1 f12 sout pout_from; res ) module U8 = FStar.UInt8 module FB = FStar.Bytes #push-options "--z3rlimit 16" inline_for_extraction noextract let swrite_flbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (len: U32.t) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_flbytes (U32.v len)) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_flbytes (U32.v len)) (FB.hide (B.as_seq h0 b)); let payload = B.sub sout.base pout_from len in B.blit b 0ul payload 0ul len; let h = HST.get () in valid_flbytes_intro h (U32.v len) sout pout_from; pout_from `U32.add` len ) inline_for_extraction noextract let swrite_bounded_vlbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (len: U32.t { min <= U32.v len /\ U32.v len <= max }) (b: B.buffer U8.t { B.length b == U32.v len /\ B.live h0 b /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlbytes min max) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_bounded_vlbytes min max) (FB.hide (B.as_seq h0 b)); length_serialize_bounded_vlbytes min max (FB.hide (B.as_seq h0 b)); let pout_payload = pout_from `U32.add` U32.uint_to_t (log256' max) in let payload = B.sub sout.base pout_payload len in B.blit b 0ul payload 0ul len; finalize_bounded_vlbytes min max sout pout_from len ) inline_for_extraction noextract let swrite_bounded_vlgenbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk { kk.parser_kind_subkind == Some ParserStrong }) (wk: leaf_writer_strong sk) (len: U32.t { min <= U32.v len /\ U32.v len <= max }) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlgenbytes min max sk) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_bounded_vlgenbytes min max sk) (FB.hide (B.as_seq h0 b)); length_serialize_bounded_vlgenbytes min max sk (FB.hide (B.as_seq h0 b)); serialized_length_eq sk len; let pout_payload = swrite (swrite_leaf wk h0 sout pout_from0 len) pout_from in let payload = B.sub sout.base pout_payload len in B.blit b 0ul payload 0ul len; let h = HST.get () in valid_bounded_vlgenbytes min max pk sout pout_from h; pout_payload `U32.add` len ) #pop-options #push-options "--z3rlimit 32" inline_for_extraction noextract let swrite_bitsum (h0: HS.mem) (space_beyond: nat) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (#kt: parser_kind) (#tot: pos) (#t: eqtype) (#cl: uint_t tot t) (b: bitsum' cl tot) (#data: Type) (tag_of_data: (data -> Tot (bitsum'_type b))) (type_of_tag: (bitsum'_key_type b -> Tot Type)) (synth_case: synth_case_t b data tag_of_data type_of_tag) (#p: parser kt t) (#s: serializer p { kt.parser_kind_subkind == Some ParserStrong } ) (w_tg: leaf_writer_strong s) (mk: synth_bitsum'_recip_t b) (#f: (x: bitsum'_key_type b) -> Tot (k: parser_kind & parser k (type_of_tag x))) (g: (x: bitsum'_key_type b) -> Tot (serializer (dsnd (f x)))) (k: bitsum'_type b { (parse_bitsum_kind kt b type_of_tag f).parser_kind_subkind == Some ParserStrong /\ (dfst (f (bitsum'_key_of_t b k))).parser_kind_subkind == Some ParserStrong }) (w_pl: swriter (g (bitsum'_key_of_t b k)) h0 space_beyond sout pout_from0) : Tot (w' : swriter (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g) h0 space_beyond sout pout_from0 { swvalue w' == synth_case.f k (swvalue w_pl) }) = SWriter (Ghost.hide (synth_case.f k (swvalue w_pl))) (fun pout_from -> serialized_length_eq (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g) (synth_case.f k (swvalue w_pl)); serialized_length_eq s (synth_bitsum'_recip b k); serialized_length_eq (g (bitsum'_key_of_t b k)) (swvalue w_pl); serialize_bitsum_eq_2 b tag_of_data type_of_tag synth_case s g k (swvalue w_pl); let pos1 = w_tg (mk k) sout pout_from in let pos2 = swrite w_pl pos1 in let h = HST.get () in valid_filter h p (filter_bitsum' b) sout pout_from; synth_bitsum'_injective b; synth_bitsum'_recip_inverse b; assert (filter_bitsum' b (mk k) == true); assert (synth_bitsum' b (mk k) == k); valid_synth h (p `parse_filter` filter_bitsum' b) (synth_bitsum' b) sout pout_from; valid_bitsum_intro b tag_of_data type_of_tag synth_case p f h sout pout_from; pos2 ) #pop-options module BF = LowParse.BitFields module E = LowParse.Endianness.BitFields module LE = LowStar.Endianness #push-options "--z3rlimit 16" inline_for_extraction let serialize32_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (x: bounded_integer (U32.v i)) (b: B.buffer byte) (pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h b /\ U32.v pos + 4 <= B.length b )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` i)) h h' /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v i) == serialize (serialize_bounded_integer (U32.v i)) x )) = let h = HST.get () in let before = LE.load32_be_i b pos in bounded_integer_prop_equiv (U32.v i) x; let after = BF.uint32.BF.set_bitfield_gen before (8ul `U32.mul` (4ul `U32.sub` i)) 32ul x in LE.store32_be_i b pos after; let h' = HST.get () in parse_bounded_integer_spec (U32.v i) (Seq.slice (B.as_seq h b) (U32.v pos) (B.length b)); E.n_to_be_be_to_n 4 (Seq.slice (Seq.slice (B.as_seq h b) (U32.v pos) (B.length b)) 0 4); Seq.slice_slice (B.as_seq h b) (U32.v pos) (B.length b) 0 4; Seq.slice_slice (B.as_seq h' b) (U32.v pos) (B.length b) 0 4; E.slice_n_to_be_bitfield 4 (U32.v before) (U32.v i) 4; E.slice_n_to_be_bitfield 4 (U32.v after) (U32.v i) 4; Seq.lemma_split (Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + 4)) (U32.v i); Seq.lemma_split (Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + 4)) (U32.v i); BF.get_bitfield_set_bitfield_other #32 (U32.v before) (8 `op_Multiply` (4 - U32.v i)) 32 (U32.v x) 0 (8 `op_Multiply` (4 - U32.v i)); Seq.lemma_split (Seq.slice (B.as_seq h' b) (U32.v pos + U32.v i) (B.length b)) (4 - U32.v i); Seq.lemma_split (Seq.slice (B.as_seq h b) (U32.v pos + U32.v i) (B.length b)) (4 - U32.v i); B.modifies_loc_buffer_from_to_intro b pos (pos `U32.add` i) B.loc_none h h'; E.slice_n_to_be_bitfield 4 (U32.v after) 0 (U32.v i); BF.get_bitfield_set_bitfield_same #32 (U32.v before) (8 `op_Multiply` (4 - U32.v i)) 32 (U32.v x); serialize_bounded_integer_spec (U32.v i) x #pop-options inline_for_extraction noextract let swrite_bounded_integer_ct (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (pout_from0: U32.t) (x: bounded_integer (U32.v i))
false
false
LowParse.Low.Writers.Instances.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 swrite_bounded_integer_ct (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) (pout_from0: U32.t) (x: bounded_integer (U32.v i)) : Tot (y: swriter (serialize_bounded_integer (U32.v i)) h0 (4 - U32.v i) sout pout_from0 {swvalue y == x})
[]
LowParse.Low.Writers.Instances.swrite_bounded_integer_ct
{ "file_name": "src/lowparse/LowParse.Low.Writers.Instances.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
h0: FStar.Monotonic.HyperStack.mem -> sout: LowParse.Slice.slice (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte )) (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte)) -> i: FStar.UInt32.t{1 <= FStar.UInt32.v i /\ FStar.UInt32.v i <= 4} -> pout_from0: FStar.UInt32.t -> x: LowParse.Spec.BoundedInt.bounded_integer (FStar.UInt32.v i) -> y: LowParse.Low.Writers.swriter (LowParse.Spec.BoundedInt.serialize_bounded_integer (FStar.UInt32.v i)) h0 (4 - FStar.UInt32.v i) sout pout_from0 {LowParse.Low.Writers.swvalue y == x}
{ "end_col": 3, "end_line": 368, "start_col": 2, "start_line": 356 }
Prims.Tot
val swrite_bounded_vlbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (len: U32.t{min <= U32.v len /\ U32.v len <= max}) (b: B.buffer U8.t { B.length b == U32.v len /\ B.live h0 b /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlbytes min max) h0 0 sout pout_from0 {swvalue w == FB.hide (B.as_seq h0 b)})
[ { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "FB" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowParse.Low.BitSum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let swrite_bounded_vlbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (len: U32.t { min <= U32.v len /\ U32.v len <= max }) (b: B.buffer U8.t { B.length b == U32.v len /\ B.live h0 b /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlbytes min max) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_bounded_vlbytes min max) (FB.hide (B.as_seq h0 b)); length_serialize_bounded_vlbytes min max (FB.hide (B.as_seq h0 b)); let pout_payload = pout_from `U32.add` U32.uint_to_t (log256' max) in let payload = B.sub sout.base pout_payload len in B.blit b 0ul payload 0ul len; finalize_bounded_vlbytes min max sout pout_from len )
val swrite_bounded_vlbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (len: U32.t{min <= U32.v len /\ U32.v len <= max}) (b: B.buffer U8.t { B.length b == U32.v len /\ B.live h0 b /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlbytes min max) h0 0 sout pout_from0 {swvalue w == FB.hide (B.as_seq h0 b)}) let swrite_bounded_vlbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (len: U32.t{min <= U32.v len /\ U32.v len <= max}) (b: B.buffer U8.t { B.length b == U32.v len /\ B.live h0 b /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlbytes min max) h0 0 sout pout_from0 {swvalue w == FB.hide (B.as_seq h0 b)}) =
false
null
false
SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_bounded_vlbytes min max) (FB.hide (B.as_seq h0 b)); length_serialize_bounded_vlbytes min max (FB.hide (B.as_seq h0 b)); let pout_payload = pout_from `U32.add` (U32.uint_to_t (log256' max)) in let payload = B.sub sout.base pout_payload len in B.blit b 0ul payload 0ul len; finalize_bounded_vlbytes min max sout pout_from len)
{ "checked_file": "LowParse.Low.Writers.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Endianness.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Low.Writers.fst.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Low.Bytes.fst.checked", "LowParse.Low.BitSum.fst.checked", "LowParse.Endianness.BitFields.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Writers.Instances.fst" }
[ "total" ]
[ "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.slice", "LowParse.Slice.srel_of_buffer_srel", "LowParse.Bytes.byte", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.t", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "FStar.UInt32.v", "LowStar.Buffer.buffer", "FStar.UInt8.t", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt32.n", "LowStar.Monotonic.Buffer.length", "LowStar.Monotonic.Buffer.live", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.Monotonic.Buffer.loc_buffer", "LowParse.Slice.loc_slice_from", "LowParse.Low.Writers.SWriter", "LowParse.Spec.VLData.parse_bounded_vldata_strong_kind", "LowParse.Spec.BoundedInt.log256'", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlbytes", "LowParse.Spec.Bytes.serialize_bounded_vlbytes", "FStar.Ghost.hide", "FStar.Bytes.hide", "LowStar.Monotonic.Buffer.as_seq", "LowParse.Low.Bytes.finalize_bounded_vlbytes", "Prims.unit", "LowStar.Monotonic.Buffer.blit", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.sub", "LowParse.Slice.__proj__Mkslice__item__base", "FStar.UInt32.add", "FStar.UInt32.uint_to_t", "LowParse.Spec.Bytes.length_serialize_bounded_vlbytes", "LowParse.Low.Base.Spec.serialized_length_eq", "LowParse.Low.Writers.swriter", "FStar.Bytes.bytes", "LowParse.Low.Writers.swvalue" ]
[]
module LowParse.Low.Writers.Instances include LowParse.Low.Writers include LowParse.Low.Combinators include LowParse.Low.Bytes include LowParse.Low.BitSum module HS = FStar.HyperStack module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST inline_for_extraction noextract let swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 { (k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong }) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq s1 (swvalue w1); serialized_length_eq (serialize_weaken k2 s1) (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_weaken k2 p1 h sout pout_from; res ) inline_for_extraction noextract let swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = SWriter (Ghost.hide (swvalue w1, swvalue w2)) (fun pout_from -> serialized_length_eq (s1 `serialize_nondep_then` s2) (swvalue w1, swvalue w2); serialize_nondep_then_eq s1 s2 (swvalue w1, swvalue w2); serialized_length_eq s1 (swvalue w1); serialized_length_eq s2 (swvalue w2); let pos1 = swrite w1 pout_from in let pos2 = swrite w2 pos1 in let h' = HST.get () in valid_nondep_then h' p1 p2 sout pout_from; pos2 ) let max (x1 x2: nat) : Tot nat = if x1 > x2 then x1 else x2 inline_for_extraction noextract let swrite_nondep_then (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond1: nat) (w1: swriter s1 h0 space_beyond1 sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (#space_beyond2: nat) (w2: swriter s2 h0 space_beyond2 sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = [@inline_let] let sbmax = space_beyond1 `max` space_beyond2 in weaken_swriter w1 h0 sbmax pout_from0 `swrite_nondep_then'` weaken_swriter w2 h0 sbmax pout_from0 inline_for_extraction noextract let swrite_filter (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (cond: (t1 -> GTot bool)) (w1: swriter s1 h0 space_beyond sout pout_from0 { cond (swvalue w1) } ) : Tot (w2: swriter (serialize_filter s1 cond) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq (serialize_filter s1 cond) (swvalue w1); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_filter h p1 cond sout pout_from; res ) inline_for_extraction noextract let swrite_synth (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#t2: Type) (f12: (t1 -> GTot t2)) (f21: (t2 -> GTot t1)) (prf: squash ( synth_injective f12 /\ synth_inverse f12 f21 )) : Tot (w2: swriter (serialize_synth p1 f12 s1 f21 ()) h0 space_beyond sout pout_from0 { swvalue w2 == f12 (swvalue w1) /\ swvalue w1 == f21 (swvalue w2) }) = [@inline_let] let _ = serialize_synth_eq p1 f12 s1 f21 () (f12 (swvalue w1)); synth_injective_synth_inverse_synth_inverse_recip f12 f21 () in SWriter (Ghost.hide (f12 (swvalue w1))) (fun pout_from -> serialized_length_eq (serialize_synth p1 f12 s1 f21 ()) (f12 (swvalue w1)); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_synth h p1 f12 sout pout_from; res ) module U8 = FStar.UInt8 module FB = FStar.Bytes #push-options "--z3rlimit 16" inline_for_extraction noextract let swrite_flbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (len: U32.t) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_flbytes (U32.v len)) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_flbytes (U32.v len)) (FB.hide (B.as_seq h0 b)); let payload = B.sub sout.base pout_from len in B.blit b 0ul payload 0ul len; let h = HST.get () in valid_flbytes_intro h (U32.v len) sout pout_from; pout_from `U32.add` len ) inline_for_extraction noextract let swrite_bounded_vlbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (len: U32.t { min <= U32.v len /\ U32.v len <= max }) (b: B.buffer U8.t { B.length b == U32.v len /\ B.live h0 b /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlbytes min max) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b)
false
false
LowParse.Low.Writers.Instances.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val swrite_bounded_vlbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (len: U32.t{min <= U32.v len /\ U32.v len <= max}) (b: B.buffer U8.t { B.length b == U32.v len /\ B.live h0 b /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlbytes min max) h0 0 sout pout_from0 {swvalue w == FB.hide (B.as_seq h0 b)})
[]
LowParse.Low.Writers.Instances.swrite_bounded_vlbytes
{ "file_name": "src/lowparse/LowParse.Low.Writers.Instances.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
h0: FStar.Monotonic.HyperStack.mem -> sout: LowParse.Slice.slice (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte )) (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte)) -> pout_from0: FStar.UInt32.t -> min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> len: FStar.UInt32.t{min <= FStar.UInt32.v len /\ FStar.UInt32.v len <= max} -> b: LowStar.Buffer.buffer FStar.UInt8.t { LowStar.Monotonic.Buffer.length b == FStar.UInt32.v len /\ LowStar.Monotonic.Buffer.live h0 b /\ LowStar.Monotonic.Buffer.loc_disjoint (LowStar.Monotonic.Buffer.loc_buffer b) (LowParse.Slice.loc_slice_from sout pout_from0) } -> w: LowParse.Low.Writers.swriter (LowParse.Spec.Bytes.serialize_bounded_vlbytes min max) h0 0 sout pout_from0 {LowParse.Low.Writers.swvalue w == FStar.Bytes.hide (LowStar.Monotonic.Buffer.as_seq h0 b)}
{ "end_col": 3, "end_line": 213, "start_col": 2, "start_line": 206 }
FStar.HyperStack.ST.Stack
val serialize32_bounded_integer_ct (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) (x: bounded_integer (U32.v i)) (b: B.buffer byte) (pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h b /\ U32.v pos + 4 <= B.length b)) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` i)) h h' /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v i) == serialize (serialize_bounded_integer (U32.v i)) x))
[ { "abbrev": true, "full_module": "LowStar.Endianness", "short_module": "LE" }, { "abbrev": true, "full_module": "LowParse.Endianness.BitFields", "short_module": "E" }, { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "BF" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "FB" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowParse.Low.BitSum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (x: bounded_integer (U32.v i)) (b: B.buffer byte) (pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h b /\ U32.v pos + 4 <= B.length b )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` i)) h h' /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v i) == serialize (serialize_bounded_integer (U32.v i)) x )) = let h = HST.get () in let before = LE.load32_be_i b pos in bounded_integer_prop_equiv (U32.v i) x; let after = BF.uint32.BF.set_bitfield_gen before (8ul `U32.mul` (4ul `U32.sub` i)) 32ul x in LE.store32_be_i b pos after; let h' = HST.get () in parse_bounded_integer_spec (U32.v i) (Seq.slice (B.as_seq h b) (U32.v pos) (B.length b)); E.n_to_be_be_to_n 4 (Seq.slice (Seq.slice (B.as_seq h b) (U32.v pos) (B.length b)) 0 4); Seq.slice_slice (B.as_seq h b) (U32.v pos) (B.length b) 0 4; Seq.slice_slice (B.as_seq h' b) (U32.v pos) (B.length b) 0 4; E.slice_n_to_be_bitfield 4 (U32.v before) (U32.v i) 4; E.slice_n_to_be_bitfield 4 (U32.v after) (U32.v i) 4; Seq.lemma_split (Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + 4)) (U32.v i); Seq.lemma_split (Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + 4)) (U32.v i); BF.get_bitfield_set_bitfield_other #32 (U32.v before) (8 `op_Multiply` (4 - U32.v i)) 32 (U32.v x) 0 (8 `op_Multiply` (4 - U32.v i)); Seq.lemma_split (Seq.slice (B.as_seq h' b) (U32.v pos + U32.v i) (B.length b)) (4 - U32.v i); Seq.lemma_split (Seq.slice (B.as_seq h b) (U32.v pos + U32.v i) (B.length b)) (4 - U32.v i); B.modifies_loc_buffer_from_to_intro b pos (pos `U32.add` i) B.loc_none h h'; E.slice_n_to_be_bitfield 4 (U32.v after) 0 (U32.v i); BF.get_bitfield_set_bitfield_same #32 (U32.v before) (8 `op_Multiply` (4 - U32.v i)) 32 (U32.v x); serialize_bounded_integer_spec (U32.v i) x
val serialize32_bounded_integer_ct (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) (x: bounded_integer (U32.v i)) (b: B.buffer byte) (pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h b /\ U32.v pos + 4 <= B.length b)) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` i)) h h' /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v i) == serialize (serialize_bounded_integer (U32.v i)) x)) let serialize32_bounded_integer_ct (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) (x: bounded_integer (U32.v i)) (b: B.buffer byte) (pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h b /\ U32.v pos + 4 <= B.length b)) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` i)) h h' /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v i) == serialize (serialize_bounded_integer (U32.v i)) x)) =
true
null
false
let h = HST.get () in let before = LE.load32_be_i b pos in bounded_integer_prop_equiv (U32.v i) x; let after = BF.uint32.BF.set_bitfield_gen before (8ul `U32.mul` (4ul `U32.sub` i)) 32ul x in LE.store32_be_i b pos after; let h' = HST.get () in parse_bounded_integer_spec (U32.v i) (Seq.slice (B.as_seq h b) (U32.v pos) (B.length b)); E.n_to_be_be_to_n 4 (Seq.slice (Seq.slice (B.as_seq h b) (U32.v pos) (B.length b)) 0 4); Seq.slice_slice (B.as_seq h b) (U32.v pos) (B.length b) 0 4; Seq.slice_slice (B.as_seq h' b) (U32.v pos) (B.length b) 0 4; E.slice_n_to_be_bitfield 4 (U32.v before) (U32.v i) 4; E.slice_n_to_be_bitfield 4 (U32.v after) (U32.v i) 4; Seq.lemma_split (Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + 4)) (U32.v i); Seq.lemma_split (Seq.slice (B.as_seq h b) (U32.v pos) (U32.v pos + 4)) (U32.v i); BF.get_bitfield_set_bitfield_other #32 (U32.v before) (8 `op_Multiply` (4 - U32.v i)) 32 (U32.v x) 0 (8 `op_Multiply` (4 - U32.v i)); Seq.lemma_split (Seq.slice (B.as_seq h' b) (U32.v pos + U32.v i) (B.length b)) (4 - U32.v i); Seq.lemma_split (Seq.slice (B.as_seq h b) (U32.v pos + U32.v i) (B.length b)) (4 - U32.v i); B.modifies_loc_buffer_from_to_intro b pos (pos `U32.add` i) B.loc_none h h'; E.slice_n_to_be_bitfield 4 (U32.v after) 0 (U32.v i); BF.get_bitfield_set_bitfield_same #32 (U32.v before) (8 `op_Multiply` (4 - U32.v i)) 32 (U32.v x); serialize_bounded_integer_spec (U32.v i) x
{ "checked_file": "LowParse.Low.Writers.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Endianness.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Low.Writers.fst.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Low.Bytes.fst.checked", "LowParse.Low.BitSum.fst.checked", "LowParse.Endianness.BitFields.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Writers.Instances.fst" }
[]
[ "FStar.UInt32.t", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt32.v", "LowParse.Spec.BoundedInt.bounded_integer", "LowStar.Buffer.buffer", "LowParse.Bytes.byte", "LowParse.Spec.BoundedInt.serialize_bounded_integer_spec", "Prims.unit", "LowParse.BitFields.get_bitfield_set_bitfield_same", "Prims.op_Multiply", "Prims.op_Subtraction", "LowParse.Endianness.BitFields.slice_n_to_be_bitfield", "LowStar.Monotonic.Buffer.modifies_loc_buffer_from_to_intro", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.add", "LowStar.Monotonic.Buffer.loc_none", "FStar.Seq.Properties.lemma_split", "FStar.Seq.Base.slice", "LowStar.Monotonic.Buffer.as_seq", "Prims.op_Addition", "LowStar.Monotonic.Buffer.length", "LowParse.BitFields.get_bitfield_set_bitfield_other", "FStar.Seq.Properties.slice_slice", "FStar.Endianness.n_to_be_be_to_n", "LowParse.Spec.BoundedInt.parse_bounded_integer_spec", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "LowStar.Endianness.store32_be_i", "Prims.eq2", "FStar.UInt.uint_t", "LowParse.BitFields.__proj__Mkuint_t__item__v", "LowParse.BitFields.uint32", "LowParse.BitFields.set_bitfield", "FStar.UInt32.mul", "FStar.UInt32.uint_to_t", "FStar.UInt32.sub", "LowParse.BitFields.__proj__Mkuint_t__item__set_bitfield_gen", "FStar.UInt32.__uint_to_t", "LowParse.Spec.BoundedInt.bounded_integer_prop_equiv", "LowStar.Endianness.u32", "LowStar.Endianness.load32_be_i", "LowStar.Monotonic.Buffer.live", "LowStar.Monotonic.Buffer.modifies", "LowStar.Monotonic.Buffer.loc_buffer_from_to", "FStar.Seq.Base.seq", "LowParse.Spec.Base.serialize", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer" ]
[]
module LowParse.Low.Writers.Instances include LowParse.Low.Writers include LowParse.Low.Combinators include LowParse.Low.Bytes include LowParse.Low.BitSum module HS = FStar.HyperStack module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST inline_for_extraction noextract let swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 { (k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong }) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq s1 (swvalue w1); serialized_length_eq (serialize_weaken k2 s1) (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_weaken k2 p1 h sout pout_from; res ) inline_for_extraction noextract let swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = SWriter (Ghost.hide (swvalue w1, swvalue w2)) (fun pout_from -> serialized_length_eq (s1 `serialize_nondep_then` s2) (swvalue w1, swvalue w2); serialize_nondep_then_eq s1 s2 (swvalue w1, swvalue w2); serialized_length_eq s1 (swvalue w1); serialized_length_eq s2 (swvalue w2); let pos1 = swrite w1 pout_from in let pos2 = swrite w2 pos1 in let h' = HST.get () in valid_nondep_then h' p1 p2 sout pout_from; pos2 ) let max (x1 x2: nat) : Tot nat = if x1 > x2 then x1 else x2 inline_for_extraction noextract let swrite_nondep_then (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond1: nat) (w1: swriter s1 h0 space_beyond1 sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (#space_beyond2: nat) (w2: swriter s2 h0 space_beyond2 sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = [@inline_let] let sbmax = space_beyond1 `max` space_beyond2 in weaken_swriter w1 h0 sbmax pout_from0 `swrite_nondep_then'` weaken_swriter w2 h0 sbmax pout_from0 inline_for_extraction noextract let swrite_filter (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (cond: (t1 -> GTot bool)) (w1: swriter s1 h0 space_beyond sout pout_from0 { cond (swvalue w1) } ) : Tot (w2: swriter (serialize_filter s1 cond) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq (serialize_filter s1 cond) (swvalue w1); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_filter h p1 cond sout pout_from; res ) inline_for_extraction noextract let swrite_synth (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#t2: Type) (f12: (t1 -> GTot t2)) (f21: (t2 -> GTot t1)) (prf: squash ( synth_injective f12 /\ synth_inverse f12 f21 )) : Tot (w2: swriter (serialize_synth p1 f12 s1 f21 ()) h0 space_beyond sout pout_from0 { swvalue w2 == f12 (swvalue w1) /\ swvalue w1 == f21 (swvalue w2) }) = [@inline_let] let _ = serialize_synth_eq p1 f12 s1 f21 () (f12 (swvalue w1)); synth_injective_synth_inverse_synth_inverse_recip f12 f21 () in SWriter (Ghost.hide (f12 (swvalue w1))) (fun pout_from -> serialized_length_eq (serialize_synth p1 f12 s1 f21 ()) (f12 (swvalue w1)); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_synth h p1 f12 sout pout_from; res ) module U8 = FStar.UInt8 module FB = FStar.Bytes #push-options "--z3rlimit 16" inline_for_extraction noextract let swrite_flbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (len: U32.t) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_flbytes (U32.v len)) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_flbytes (U32.v len)) (FB.hide (B.as_seq h0 b)); let payload = B.sub sout.base pout_from len in B.blit b 0ul payload 0ul len; let h = HST.get () in valid_flbytes_intro h (U32.v len) sout pout_from; pout_from `U32.add` len ) inline_for_extraction noextract let swrite_bounded_vlbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (len: U32.t { min <= U32.v len /\ U32.v len <= max }) (b: B.buffer U8.t { B.length b == U32.v len /\ B.live h0 b /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlbytes min max) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_bounded_vlbytes min max) (FB.hide (B.as_seq h0 b)); length_serialize_bounded_vlbytes min max (FB.hide (B.as_seq h0 b)); let pout_payload = pout_from `U32.add` U32.uint_to_t (log256' max) in let payload = B.sub sout.base pout_payload len in B.blit b 0ul payload 0ul len; finalize_bounded_vlbytes min max sout pout_from len ) inline_for_extraction noextract let swrite_bounded_vlgenbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk { kk.parser_kind_subkind == Some ParserStrong }) (wk: leaf_writer_strong sk) (len: U32.t { min <= U32.v len /\ U32.v len <= max }) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlgenbytes min max sk) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_bounded_vlgenbytes min max sk) (FB.hide (B.as_seq h0 b)); length_serialize_bounded_vlgenbytes min max sk (FB.hide (B.as_seq h0 b)); serialized_length_eq sk len; let pout_payload = swrite (swrite_leaf wk h0 sout pout_from0 len) pout_from in let payload = B.sub sout.base pout_payload len in B.blit b 0ul payload 0ul len; let h = HST.get () in valid_bounded_vlgenbytes min max pk sout pout_from h; pout_payload `U32.add` len ) #pop-options #push-options "--z3rlimit 32" inline_for_extraction noextract let swrite_bitsum (h0: HS.mem) (space_beyond: nat) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (#kt: parser_kind) (#tot: pos) (#t: eqtype) (#cl: uint_t tot t) (b: bitsum' cl tot) (#data: Type) (tag_of_data: (data -> Tot (bitsum'_type b))) (type_of_tag: (bitsum'_key_type b -> Tot Type)) (synth_case: synth_case_t b data tag_of_data type_of_tag) (#p: parser kt t) (#s: serializer p { kt.parser_kind_subkind == Some ParserStrong } ) (w_tg: leaf_writer_strong s) (mk: synth_bitsum'_recip_t b) (#f: (x: bitsum'_key_type b) -> Tot (k: parser_kind & parser k (type_of_tag x))) (g: (x: bitsum'_key_type b) -> Tot (serializer (dsnd (f x)))) (k: bitsum'_type b { (parse_bitsum_kind kt b type_of_tag f).parser_kind_subkind == Some ParserStrong /\ (dfst (f (bitsum'_key_of_t b k))).parser_kind_subkind == Some ParserStrong }) (w_pl: swriter (g (bitsum'_key_of_t b k)) h0 space_beyond sout pout_from0) : Tot (w' : swriter (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g) h0 space_beyond sout pout_from0 { swvalue w' == synth_case.f k (swvalue w_pl) }) = SWriter (Ghost.hide (synth_case.f k (swvalue w_pl))) (fun pout_from -> serialized_length_eq (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g) (synth_case.f k (swvalue w_pl)); serialized_length_eq s (synth_bitsum'_recip b k); serialized_length_eq (g (bitsum'_key_of_t b k)) (swvalue w_pl); serialize_bitsum_eq_2 b tag_of_data type_of_tag synth_case s g k (swvalue w_pl); let pos1 = w_tg (mk k) sout pout_from in let pos2 = swrite w_pl pos1 in let h = HST.get () in valid_filter h p (filter_bitsum' b) sout pout_from; synth_bitsum'_injective b; synth_bitsum'_recip_inverse b; assert (filter_bitsum' b (mk k) == true); assert (synth_bitsum' b (mk k) == k); valid_synth h (p `parse_filter` filter_bitsum' b) (synth_bitsum' b) sout pout_from; valid_bitsum_intro b tag_of_data type_of_tag synth_case p f h sout pout_from; pos2 ) #pop-options module BF = LowParse.BitFields module E = LowParse.Endianness.BitFields module LE = LowStar.Endianness #push-options "--z3rlimit 16" inline_for_extraction let serialize32_bounded_integer_ct (i: U32.t { 1 <= U32.v i /\ U32.v i <= 4 }) (x: bounded_integer (U32.v i)) (b: B.buffer byte) (pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h b /\ U32.v pos + 4 <= B.length b )) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` i)) h h' /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v i) == serialize (serialize_bounded_integer (U32.v i)) x
false
false
LowParse.Low.Writers.Instances.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_integer_ct (i: U32.t{1 <= U32.v i /\ U32.v i <= 4}) (x: bounded_integer (U32.v i)) (b: B.buffer byte) (pos: U32.t) : HST.Stack unit (requires (fun h -> B.live h b /\ U32.v pos + 4 <= B.length b)) (ensures (fun h _ h' -> B.modifies (B.loc_buffer_from_to b pos (pos `U32.add` i)) h h' /\ Seq.slice (B.as_seq h' b) (U32.v pos) (U32.v pos + U32.v i) == serialize (serialize_bounded_integer (U32.v i)) x))
[]
LowParse.Low.Writers.Instances.serialize32_bounded_integer_ct
{ "file_name": "src/lowparse/LowParse.Low.Writers.Instances.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
i: FStar.UInt32.t{1 <= FStar.UInt32.v i /\ FStar.UInt32.v i <= 4} -> x: LowParse.Spec.BoundedInt.bounded_integer (FStar.UInt32.v i) -> b: LowStar.Buffer.buffer LowParse.Bytes.byte -> pos: FStar.UInt32.t -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 44, "end_line": 343, "start_col": 1, "start_line": 323 }
Prims.Tot
val swrite_bounded_vlgenbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk {kk.parser_kind_subkind == Some ParserStrong}) (wk: leaf_writer_strong sk) (len: U32.t{min <= U32.v len /\ U32.v len <= max}) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlgenbytes min max sk) h0 0 sout pout_from0 {swvalue w == FB.hide (B.as_seq h0 b)})
[ { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "FB" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowParse.Low.BitSum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let swrite_bounded_vlgenbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk { kk.parser_kind_subkind == Some ParserStrong }) (wk: leaf_writer_strong sk) (len: U32.t { min <= U32.v len /\ U32.v len <= max }) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlgenbytes min max sk) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_bounded_vlgenbytes min max sk) (FB.hide (B.as_seq h0 b)); length_serialize_bounded_vlgenbytes min max sk (FB.hide (B.as_seq h0 b)); serialized_length_eq sk len; let pout_payload = swrite (swrite_leaf wk h0 sout pout_from0 len) pout_from in let payload = B.sub sout.base pout_payload len in B.blit b 0ul payload 0ul len; let h = HST.get () in valid_bounded_vlgenbytes min max pk sout pout_from h; pout_payload `U32.add` len )
val swrite_bounded_vlgenbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk {kk.parser_kind_subkind == Some ParserStrong}) (wk: leaf_writer_strong sk) (len: U32.t{min <= U32.v len /\ U32.v len <= max}) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlgenbytes min max sk) h0 0 sout pout_from0 {swvalue w == FB.hide (B.as_seq h0 b)}) let swrite_bounded_vlgenbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk {kk.parser_kind_subkind == Some ParserStrong}) (wk: leaf_writer_strong sk) (len: U32.t{min <= U32.v len /\ U32.v len <= max}) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlgenbytes min max sk) h0 0 sout pout_from0 {swvalue w == FB.hide (B.as_seq h0 b)}) =
false
null
false
SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_bounded_vlgenbytes min max sk) (FB.hide (B.as_seq h0 b)); length_serialize_bounded_vlgenbytes min max sk (FB.hide (B.as_seq h0 b)); serialized_length_eq sk len; let pout_payload = swrite (swrite_leaf wk h0 sout pout_from0 len) pout_from in let payload = B.sub sout.base pout_payload len in B.blit b 0ul payload 0ul len; let h = HST.get () in valid_bounded_vlgenbytes min max pk sout pout_from h; pout_payload `U32.add` len)
{ "checked_file": "LowParse.Low.Writers.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Endianness.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Low.Writers.fst.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Low.Bytes.fst.checked", "LowParse.Low.BitSum.fst.checked", "LowParse.Endianness.BitFields.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Writers.Instances.fst" }
[ "total" ]
[ "FStar.Monotonic.HyperStack.mem", "LowParse.Slice.slice", "LowParse.Slice.srel_of_buffer_srel", "LowParse.Bytes.byte", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.t", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThan", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.Base.serializer", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "LowParse.Low.Base.leaf_writer_strong", "FStar.UInt32.v", "LowStar.Buffer.buffer", "FStar.UInt8.t", "LowStar.Monotonic.Buffer.live", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt32.n", "LowStar.Monotonic.Buffer.length", "LowStar.Monotonic.Buffer.loc_disjoint", "LowStar.Monotonic.Buffer.loc_buffer", "LowParse.Slice.loc_slice_from", "LowParse.Low.Writers.SWriter", "LowParse.Spec.VLGen.parse_bounded_vlgen_kind", "LowParse.Spec.Bytes.parse_all_bytes_kind", "LowParse.Spec.Bytes.parse_bounded_vlbytes_t", "LowParse.Spec.Bytes.parse_bounded_vlgenbytes", "LowParse.Spec.Bytes.serialize_bounded_vlgenbytes", "FStar.Ghost.hide", "FStar.Bytes.hide", "LowStar.Monotonic.Buffer.as_seq", "FStar.UInt32.add", "Prims.unit", "LowParse.Low.Bytes.valid_bounded_vlgenbytes", "FStar.HyperStack.ST.get", "LowStar.Monotonic.Buffer.blit", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.sub", "LowParse.Slice.__proj__Mkslice__item__base", "LowParse.Low.Writers.swrite", "LowParse.Low.Writers.swrite_leaf", "LowParse.Low.Base.Spec.serialized_length_eq", "LowParse.Spec.Bytes.length_serialize_bounded_vlgenbytes", "LowParse.Low.Writers.swriter", "FStar.Bytes.bytes", "LowParse.Low.Writers.swvalue" ]
[]
module LowParse.Low.Writers.Instances include LowParse.Low.Writers include LowParse.Low.Combinators include LowParse.Low.Bytes include LowParse.Low.BitSum module HS = FStar.HyperStack module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST inline_for_extraction noextract let swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 { (k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong }) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq s1 (swvalue w1); serialized_length_eq (serialize_weaken k2 s1) (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_weaken k2 p1 h sout pout_from; res ) inline_for_extraction noextract let swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = SWriter (Ghost.hide (swvalue w1, swvalue w2)) (fun pout_from -> serialized_length_eq (s1 `serialize_nondep_then` s2) (swvalue w1, swvalue w2); serialize_nondep_then_eq s1 s2 (swvalue w1, swvalue w2); serialized_length_eq s1 (swvalue w1); serialized_length_eq s2 (swvalue w2); let pos1 = swrite w1 pout_from in let pos2 = swrite w2 pos1 in let h' = HST.get () in valid_nondep_then h' p1 p2 sout pout_from; pos2 ) let max (x1 x2: nat) : Tot nat = if x1 > x2 then x1 else x2 inline_for_extraction noextract let swrite_nondep_then (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond1: nat) (w1: swriter s1 h0 space_beyond1 sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (#space_beyond2: nat) (w2: swriter s2 h0 space_beyond2 sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = [@inline_let] let sbmax = space_beyond1 `max` space_beyond2 in weaken_swriter w1 h0 sbmax pout_from0 `swrite_nondep_then'` weaken_swriter w2 h0 sbmax pout_from0 inline_for_extraction noextract let swrite_filter (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (cond: (t1 -> GTot bool)) (w1: swriter s1 h0 space_beyond sout pout_from0 { cond (swvalue w1) } ) : Tot (w2: swriter (serialize_filter s1 cond) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq (serialize_filter s1 cond) (swvalue w1); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_filter h p1 cond sout pout_from; res ) inline_for_extraction noextract let swrite_synth (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#t2: Type) (f12: (t1 -> GTot t2)) (f21: (t2 -> GTot t1)) (prf: squash ( synth_injective f12 /\ synth_inverse f12 f21 )) : Tot (w2: swriter (serialize_synth p1 f12 s1 f21 ()) h0 space_beyond sout pout_from0 { swvalue w2 == f12 (swvalue w1) /\ swvalue w1 == f21 (swvalue w2) }) = [@inline_let] let _ = serialize_synth_eq p1 f12 s1 f21 () (f12 (swvalue w1)); synth_injective_synth_inverse_synth_inverse_recip f12 f21 () in SWriter (Ghost.hide (f12 (swvalue w1))) (fun pout_from -> serialized_length_eq (serialize_synth p1 f12 s1 f21 ()) (f12 (swvalue w1)); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_synth h p1 f12 sout pout_from; res ) module U8 = FStar.UInt8 module FB = FStar.Bytes #push-options "--z3rlimit 16" inline_for_extraction noextract let swrite_flbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (len: U32.t) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_flbytes (U32.v len)) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_flbytes (U32.v len)) (FB.hide (B.as_seq h0 b)); let payload = B.sub sout.base pout_from len in B.blit b 0ul payload 0ul len; let h = HST.get () in valid_flbytes_intro h (U32.v len) sout pout_from; pout_from `U32.add` len ) inline_for_extraction noextract let swrite_bounded_vlbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (len: U32.t { min <= U32.v len /\ U32.v len <= max }) (b: B.buffer U8.t { B.length b == U32.v len /\ B.live h0 b /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlbytes min max) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_bounded_vlbytes min max) (FB.hide (B.as_seq h0 b)); length_serialize_bounded_vlbytes min max (FB.hide (B.as_seq h0 b)); let pout_payload = pout_from `U32.add` U32.uint_to_t (log256' max) in let payload = B.sub sout.base pout_payload len in B.blit b 0ul payload 0ul len; finalize_bounded_vlbytes min max sout pout_from len ) inline_for_extraction noextract let swrite_bounded_vlgenbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk { kk.parser_kind_subkind == Some ParserStrong }) (wk: leaf_writer_strong sk) (len: U32.t { min <= U32.v len /\ U32.v len <= max }) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlgenbytes min max sk) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b)
false
false
LowParse.Low.Writers.Instances.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": 16, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val swrite_bounded_vlgenbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat{min <= max /\ max > 0 /\ max < 4294967296}) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk {kk.parser_kind_subkind == Some ParserStrong}) (wk: leaf_writer_strong sk) (len: U32.t{min <= U32.v len /\ U32.v len <= max}) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlgenbytes min max sk) h0 0 sout pout_from0 {swvalue w == FB.hide (B.as_seq h0 b)})
[]
LowParse.Low.Writers.Instances.swrite_bounded_vlgenbytes
{ "file_name": "src/lowparse/LowParse.Low.Writers.Instances.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
h0: FStar.Monotonic.HyperStack.mem -> sout: LowParse.Slice.slice (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte )) (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte)) -> pout_from0: FStar.UInt32.t -> min: Prims.nat -> max: Prims.nat{min <= max /\ max > 0 /\ max < 4294967296} -> wk: LowParse.Low.Base.leaf_writer_strong sk -> len: FStar.UInt32.t{min <= FStar.UInt32.v len /\ FStar.UInt32.v len <= max} -> b: LowStar.Buffer.buffer FStar.UInt8.t { LowStar.Monotonic.Buffer.live h0 b /\ LowStar.Monotonic.Buffer.length b == FStar.UInt32.v len /\ LowStar.Monotonic.Buffer.loc_disjoint (LowStar.Monotonic.Buffer.loc_buffer b) (LowParse.Slice.loc_slice_from sout pout_from0) } -> w: LowParse.Low.Writers.swriter (LowParse.Spec.Bytes.serialize_bounded_vlgenbytes min max sk) h0 0 sout pout_from0 {LowParse.Low.Writers.swvalue w == FStar.Bytes.hide (LowStar.Monotonic.Buffer.as_seq h0 b)}
{ "end_col": 3, "end_line": 246, "start_col": 2, "start_line": 236 }
Prims.Tot
val swrite_bitsum (h0: HS.mem) (space_beyond: nat) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (#kt: parser_kind) (#tot: pos) (#t: eqtype) (#cl: uint_t tot t) (b: bitsum' cl tot) (#data: Type) (tag_of_data: (data -> Tot (bitsum'_type b))) (type_of_tag: (bitsum'_key_type b -> Tot Type)) (synth_case: synth_case_t b data tag_of_data type_of_tag) (#p: parser kt t) (#s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (w_tg: leaf_writer_strong s) (mk: synth_bitsum'_recip_t b) (#f: (x: bitsum'_key_type b -> Tot (k: parser_kind & parser k (type_of_tag x)))) (g: (x: bitsum'_key_type b -> Tot (serializer (dsnd (f x))))) (k: bitsum'_type b { (parse_bitsum_kind kt b type_of_tag f).parser_kind_subkind == Some ParserStrong /\ (dfst (f (bitsum'_key_of_t b k))).parser_kind_subkind == Some ParserStrong }) (w_pl: swriter (g (bitsum'_key_of_t b k)) h0 space_beyond sout pout_from0) : Tot (w': swriter (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g) h0 space_beyond sout pout_from0 {swvalue w' == synth_case.f k (swvalue w_pl)})
[ { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "FB" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "LowParse.Low.BitSum", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Bytes", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Low.Writers", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let swrite_bitsum (h0: HS.mem) (space_beyond: nat) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (#kt: parser_kind) (#tot: pos) (#t: eqtype) (#cl: uint_t tot t) (b: bitsum' cl tot) (#data: Type) (tag_of_data: (data -> Tot (bitsum'_type b))) (type_of_tag: (bitsum'_key_type b -> Tot Type)) (synth_case: synth_case_t b data tag_of_data type_of_tag) (#p: parser kt t) (#s: serializer p { kt.parser_kind_subkind == Some ParserStrong } ) (w_tg: leaf_writer_strong s) (mk: synth_bitsum'_recip_t b) (#f: (x: bitsum'_key_type b) -> Tot (k: parser_kind & parser k (type_of_tag x))) (g: (x: bitsum'_key_type b) -> Tot (serializer (dsnd (f x)))) (k: bitsum'_type b { (parse_bitsum_kind kt b type_of_tag f).parser_kind_subkind == Some ParserStrong /\ (dfst (f (bitsum'_key_of_t b k))).parser_kind_subkind == Some ParserStrong }) (w_pl: swriter (g (bitsum'_key_of_t b k)) h0 space_beyond sout pout_from0) : Tot (w' : swriter (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g) h0 space_beyond sout pout_from0 { swvalue w' == synth_case.f k (swvalue w_pl) }) = SWriter (Ghost.hide (synth_case.f k (swvalue w_pl))) (fun pout_from -> serialized_length_eq (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g) (synth_case.f k (swvalue w_pl)); serialized_length_eq s (synth_bitsum'_recip b k); serialized_length_eq (g (bitsum'_key_of_t b k)) (swvalue w_pl); serialize_bitsum_eq_2 b tag_of_data type_of_tag synth_case s g k (swvalue w_pl); let pos1 = w_tg (mk k) sout pout_from in let pos2 = swrite w_pl pos1 in let h = HST.get () in valid_filter h p (filter_bitsum' b) sout pout_from; synth_bitsum'_injective b; synth_bitsum'_recip_inverse b; assert (filter_bitsum' b (mk k) == true); assert (synth_bitsum' b (mk k) == k); valid_synth h (p `parse_filter` filter_bitsum' b) (synth_bitsum' b) sout pout_from; valid_bitsum_intro b tag_of_data type_of_tag synth_case p f h sout pout_from; pos2 )
val swrite_bitsum (h0: HS.mem) (space_beyond: nat) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (#kt: parser_kind) (#tot: pos) (#t: eqtype) (#cl: uint_t tot t) (b: bitsum' cl tot) (#data: Type) (tag_of_data: (data -> Tot (bitsum'_type b))) (type_of_tag: (bitsum'_key_type b -> Tot Type)) (synth_case: synth_case_t b data tag_of_data type_of_tag) (#p: parser kt t) (#s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (w_tg: leaf_writer_strong s) (mk: synth_bitsum'_recip_t b) (#f: (x: bitsum'_key_type b -> Tot (k: parser_kind & parser k (type_of_tag x)))) (g: (x: bitsum'_key_type b -> Tot (serializer (dsnd (f x))))) (k: bitsum'_type b { (parse_bitsum_kind kt b type_of_tag f).parser_kind_subkind == Some ParserStrong /\ (dfst (f (bitsum'_key_of_t b k))).parser_kind_subkind == Some ParserStrong }) (w_pl: swriter (g (bitsum'_key_of_t b k)) h0 space_beyond sout pout_from0) : Tot (w': swriter (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g) h0 space_beyond sout pout_from0 {swvalue w' == synth_case.f k (swvalue w_pl)}) let swrite_bitsum (h0: HS.mem) (space_beyond: nat) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (#kt: parser_kind) (#tot: pos) (#t: eqtype) (#cl: uint_t tot t) (b: bitsum' cl tot) (#data: Type) (tag_of_data: (data -> Tot (bitsum'_type b))) (type_of_tag: (bitsum'_key_type b -> Tot Type)) (synth_case: synth_case_t b data tag_of_data type_of_tag) (#p: parser kt t) (#s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (w_tg: leaf_writer_strong s) (mk: synth_bitsum'_recip_t b) (#f: (x: bitsum'_key_type b -> Tot (k: parser_kind & parser k (type_of_tag x)))) (g: (x: bitsum'_key_type b -> Tot (serializer (dsnd (f x))))) (k: bitsum'_type b { (parse_bitsum_kind kt b type_of_tag f).parser_kind_subkind == Some ParserStrong /\ (dfst (f (bitsum'_key_of_t b k))).parser_kind_subkind == Some ParserStrong }) (w_pl: swriter (g (bitsum'_key_of_t b k)) h0 space_beyond sout pout_from0) : Tot (w': swriter (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g) h0 space_beyond sout pout_from0 {swvalue w' == synth_case.f k (swvalue w_pl)}) =
false
null
false
SWriter (Ghost.hide (synth_case.f k (swvalue w_pl))) (fun pout_from -> serialized_length_eq (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g) (synth_case.f k (swvalue w_pl)); serialized_length_eq s (synth_bitsum'_recip b k); serialized_length_eq (g (bitsum'_key_of_t b k)) (swvalue w_pl); serialize_bitsum_eq_2 b tag_of_data type_of_tag synth_case s g k (swvalue w_pl); let pos1 = w_tg (mk k) sout pout_from in let pos2 = swrite w_pl pos1 in let h = HST.get () in valid_filter h p (filter_bitsum' b) sout pout_from; synth_bitsum'_injective b; synth_bitsum'_recip_inverse b; assert (filter_bitsum' b (mk k) == true); assert (synth_bitsum' b (mk k) == k); valid_synth h (p `parse_filter` (filter_bitsum' b)) (synth_bitsum' b) sout pout_from; valid_bitsum_intro b tag_of_data type_of_tag synth_case p f h sout pout_from; pos2)
{ "checked_file": "LowParse.Low.Writers.Instances.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Endianness.fst.checked", "LowStar.Buffer.fst.checked", "LowParse.Low.Writers.fst.checked", "LowParse.Low.Combinators.fsti.checked", "LowParse.Low.Bytes.fst.checked", "LowParse.Low.BitSum.fst.checked", "LowParse.Endianness.BitFields.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Bytes.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Low.Writers.Instances.fst" }
[ "total" ]
[ "FStar.Monotonic.HyperStack.mem", "Prims.nat", "LowParse.Slice.slice", "LowParse.Slice.srel_of_buffer_srel", "LowParse.Bytes.byte", "LowStar.Buffer.trivial_preorder", "FStar.UInt32.t", "LowParse.Spec.Base.parser_kind", "Prims.pos", "Prims.eqtype", "LowParse.BitFields.uint_t", "LowParse.Spec.BitSum.bitsum'", "LowParse.Spec.BitSum.bitsum'_type", "LowParse.Spec.BitSum.bitsum'_key_type", "LowParse.Spec.BitSum.synth_case_t", "LowParse.Spec.Base.parser", "LowParse.Spec.Base.serializer", "Prims.eq2", "FStar.Pervasives.Native.option", "LowParse.Spec.Base.parser_subkind", "LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind", "FStar.Pervasives.Native.Some", "LowParse.Spec.Base.ParserStrong", "LowParse.Low.Base.leaf_writer_strong", "LowParse.Spec.BitSum.synth_bitsum'_recip_t", "Prims.dtuple2", "Prims.__proj__Mkdtuple2__item___1", "FStar.Pervasives.dsnd", "Prims.l_and", "LowParse.Spec.BitSum.parse_bitsum_kind", "FStar.Pervasives.dfst", "LowParse.Spec.BitSum.bitsum'_key_of_t", "LowParse.Low.Writers.swriter", "LowParse.Low.Writers.SWriter", "LowParse.Spec.BitSum.parse_bitsum", "LowParse.Spec.BitSum.serialize_bitsum", "FStar.Ghost.hide", "LowParse.Spec.BitSum.__proj__SynthCase__item__f", "LowParse.Low.Writers.swvalue", "Prims.unit", "LowParse.Low.BitSum.valid_bitsum_intro", "LowParse.Low.Combinators.valid_synth", "LowParse.Spec.Combinators.parse_filter_kind", "LowParse.Spec.Combinators.parse_filter_refine", "LowParse.Spec.BitSum.filter_bitsum'", "LowParse.Spec.Combinators.parse_filter", "LowParse.Spec.BitSum.synth_bitsum'", "Prims._assert", "Prims.bool", "LowParse.Spec.BitSum.synth_bitsum'_recip_inverse", "LowParse.Spec.BitSum.synth_bitsum'_injective", "LowParse.Low.Combinators.valid_filter", "FStar.HyperStack.ST.get", "LowParse.Low.Writers.swrite", "LowParse.Spec.BitSum.serialize_bitsum_eq_2", "LowParse.Low.Base.Spec.serialized_length_eq", "LowParse.Spec.BitSum.synth_bitsum'_recip" ]
[]
module LowParse.Low.Writers.Instances include LowParse.Low.Writers include LowParse.Low.Combinators include LowParse.Low.Bytes include LowParse.Low.BitSum module HS = FStar.HyperStack module B = LowStar.Buffer module U32 = FStar.UInt32 module HST = FStar.HyperStack.ST inline_for_extraction noextract let swrite_weaken (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (k2: parser_kind) (w1: swriter s1 h0 space_beyond sout pout_from0 { (k2 `is_weaker_than` k1) /\ k2.parser_kind_subkind == Some ParserStrong }) : Tot (w2: swriter (serialize_weaken k2 s1) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq s1 (swvalue w1); serialized_length_eq (serialize_weaken k2 s1) (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_weaken k2 p1 h sout pout_from; res ) inline_for_extraction noextract let swrite_nondep_then' (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (w2: swriter s2 h0 space_beyond sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 space_beyond sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = SWriter (Ghost.hide (swvalue w1, swvalue w2)) (fun pout_from -> serialized_length_eq (s1 `serialize_nondep_then` s2) (swvalue w1, swvalue w2); serialize_nondep_then_eq s1 s2 (swvalue w1, swvalue w2); serialized_length_eq s1 (swvalue w1); serialized_length_eq s2 (swvalue w2); let pos1 = swrite w1 pout_from in let pos2 = swrite w2 pos1 in let h' = HST.get () in valid_nondep_then h' p1 p2 sout pout_from; pos2 ) let max (x1 x2: nat) : Tot nat = if x1 > x2 then x1 else x2 inline_for_extraction noextract let swrite_nondep_then (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond1: nat) (w1: swriter s1 h0 space_beyond1 sout pout_from0) (#k2: parser_kind) (#t2: Type) (#p2: parser k2 t2) (#s2: serializer p2 { k2.parser_kind_subkind == Some ParserStrong }) (#space_beyond2: nat) (w2: swriter s2 h0 space_beyond2 sout pout_from0) : Tot (w: swriter (s1 `serialize_nondep_then` s2) h0 (space_beyond1 `max` space_beyond2) sout pout_from0 { swvalue w == (swvalue w1, swvalue w2) }) = [@inline_let] let sbmax = space_beyond1 `max` space_beyond2 in weaken_swriter w1 h0 sbmax pout_from0 `swrite_nondep_then'` weaken_swriter w2 h0 sbmax pout_from0 inline_for_extraction noextract let swrite_filter (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (cond: (t1 -> GTot bool)) (w1: swriter s1 h0 space_beyond sout pout_from0 { cond (swvalue w1) } ) : Tot (w2: swriter (serialize_filter s1 cond) h0 space_beyond sout pout_from0 { swvalue w2 == swvalue w1 }) = SWriter (Ghost.hide (swvalue w1)) (fun pout_from -> serialized_length_eq (serialize_filter s1 cond) (swvalue w1); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_filter h p1 cond sout pout_from; res ) inline_for_extraction noextract let swrite_synth (#h0: HS.mem) (#sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (#pout_from0: U32.t) (#k1: parser_kind) (#t1: Type) (#p1: parser k1 t1) (#s1: serializer p1 { k1.parser_kind_subkind == Some ParserStrong }) (#space_beyond: nat) (w1: swriter s1 h0 space_beyond sout pout_from0) (#t2: Type) (f12: (t1 -> GTot t2)) (f21: (t2 -> GTot t1)) (prf: squash ( synth_injective f12 /\ synth_inverse f12 f21 )) : Tot (w2: swriter (serialize_synth p1 f12 s1 f21 ()) h0 space_beyond sout pout_from0 { swvalue w2 == f12 (swvalue w1) /\ swvalue w1 == f21 (swvalue w2) }) = [@inline_let] let _ = serialize_synth_eq p1 f12 s1 f21 () (f12 (swvalue w1)); synth_injective_synth_inverse_synth_inverse_recip f12 f21 () in SWriter (Ghost.hide (f12 (swvalue w1))) (fun pout_from -> serialized_length_eq (serialize_synth p1 f12 s1 f21 ()) (f12 (swvalue w1)); serialized_length_eq s1 (swvalue w1); let res = swrite w1 pout_from in let h = HST.get () in valid_synth h p1 f12 sout pout_from; res ) module U8 = FStar.UInt8 module FB = FStar.Bytes #push-options "--z3rlimit 16" inline_for_extraction noextract let swrite_flbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (len: U32.t) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_flbytes (U32.v len)) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_flbytes (U32.v len)) (FB.hide (B.as_seq h0 b)); let payload = B.sub sout.base pout_from len in B.blit b 0ul payload 0ul len; let h = HST.get () in valid_flbytes_intro h (U32.v len) sout pout_from; pout_from `U32.add` len ) inline_for_extraction noextract let swrite_bounded_vlbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (len: U32.t { min <= U32.v len /\ U32.v len <= max }) (b: B.buffer U8.t { B.length b == U32.v len /\ B.live h0 b /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlbytes min max) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_bounded_vlbytes min max) (FB.hide (B.as_seq h0 b)); length_serialize_bounded_vlbytes min max (FB.hide (B.as_seq h0 b)); let pout_payload = pout_from `U32.add` U32.uint_to_t (log256' max) in let payload = B.sub sout.base pout_payload len in B.blit b 0ul payload 0ul len; finalize_bounded_vlbytes min max sout pout_from len ) inline_for_extraction noextract let swrite_bounded_vlgenbytes (h0: HS.mem) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (min: nat) (max: nat { min <= max /\ max > 0 /\ max < 4294967296 }) (#kk: parser_kind) (#pk: parser kk (bounded_int32 min max)) (#sk: serializer pk { kk.parser_kind_subkind == Some ParserStrong }) (wk: leaf_writer_strong sk) (len: U32.t { min <= U32.v len /\ U32.v len <= max }) (b: B.buffer U8.t { B.live h0 b /\ B.length b == U32.v len /\ B.loc_disjoint (B.loc_buffer b) (loc_slice_from sout pout_from0) }) : Tot (w: swriter (serialize_bounded_vlgenbytes min max sk) h0 0 sout pout_from0 { swvalue w == FB.hide (B.as_seq h0 b) }) = SWriter (Ghost.hide (FB.hide (B.as_seq h0 b))) (fun pout_from -> serialized_length_eq (serialize_bounded_vlgenbytes min max sk) (FB.hide (B.as_seq h0 b)); length_serialize_bounded_vlgenbytes min max sk (FB.hide (B.as_seq h0 b)); serialized_length_eq sk len; let pout_payload = swrite (swrite_leaf wk h0 sout pout_from0 len) pout_from in let payload = B.sub sout.base pout_payload len in B.blit b 0ul payload 0ul len; let h = HST.get () in valid_bounded_vlgenbytes min max pk sout pout_from h; pout_payload `U32.add` len ) #pop-options #push-options "--z3rlimit 32" inline_for_extraction noextract let swrite_bitsum (h0: HS.mem) (space_beyond: nat) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (#kt: parser_kind) (#tot: pos) (#t: eqtype) (#cl: uint_t tot t) (b: bitsum' cl tot) (#data: Type) (tag_of_data: (data -> Tot (bitsum'_type b))) (type_of_tag: (bitsum'_key_type b -> Tot Type)) (synth_case: synth_case_t b data tag_of_data type_of_tag) (#p: parser kt t) (#s: serializer p { kt.parser_kind_subkind == Some ParserStrong } ) (w_tg: leaf_writer_strong s) (mk: synth_bitsum'_recip_t b) (#f: (x: bitsum'_key_type b) -> Tot (k: parser_kind & parser k (type_of_tag x))) (g: (x: bitsum'_key_type b) -> Tot (serializer (dsnd (f x)))) (k: bitsum'_type b { (parse_bitsum_kind kt b type_of_tag f).parser_kind_subkind == Some ParserStrong /\ (dfst (f (bitsum'_key_of_t b k))).parser_kind_subkind == Some ParserStrong }) (w_pl: swriter (g (bitsum'_key_of_t b k)) h0 space_beyond sout pout_from0) : Tot (w' : swriter (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g) h0 space_beyond sout pout_from0 { swvalue w' == synth_case.f k (swvalue w_pl)
false
false
LowParse.Low.Writers.Instances.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": 32, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val swrite_bitsum (h0: HS.mem) (space_beyond: nat) (sout: slice (srel_of_buffer_srel (B.trivial_preorder _)) (srel_of_buffer_srel (B.trivial_preorder _))) (pout_from0: U32.t) (#kt: parser_kind) (#tot: pos) (#t: eqtype) (#cl: uint_t tot t) (b: bitsum' cl tot) (#data: Type) (tag_of_data: (data -> Tot (bitsum'_type b))) (type_of_tag: (bitsum'_key_type b -> Tot Type)) (synth_case: synth_case_t b data tag_of_data type_of_tag) (#p: parser kt t) (#s: serializer p {kt.parser_kind_subkind == Some ParserStrong}) (w_tg: leaf_writer_strong s) (mk: synth_bitsum'_recip_t b) (#f: (x: bitsum'_key_type b -> Tot (k: parser_kind & parser k (type_of_tag x)))) (g: (x: bitsum'_key_type b -> Tot (serializer (dsnd (f x))))) (k: bitsum'_type b { (parse_bitsum_kind kt b type_of_tag f).parser_kind_subkind == Some ParserStrong /\ (dfst (f (bitsum'_key_of_t b k))).parser_kind_subkind == Some ParserStrong }) (w_pl: swriter (g (bitsum'_key_of_t b k)) h0 space_beyond sout pout_from0) : Tot (w': swriter (serialize_bitsum b tag_of_data type_of_tag synth_case s #f g) h0 space_beyond sout pout_from0 {swvalue w' == synth_case.f k (swvalue w_pl)})
[]
LowParse.Low.Writers.Instances.swrite_bitsum
{ "file_name": "src/lowparse/LowParse.Low.Writers.Instances.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
h0: FStar.Monotonic.HyperStack.mem -> space_beyond: Prims.nat -> sout: LowParse.Slice.slice (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte )) (LowParse.Slice.srel_of_buffer_srel (LowStar.Buffer.trivial_preorder LowParse.Bytes.byte)) -> pout_from0: FStar.UInt32.t -> b: LowParse.Spec.BitSum.bitsum' cl tot -> tag_of_data: (_: data -> LowParse.Spec.BitSum.bitsum'_type b) -> type_of_tag: (_: LowParse.Spec.BitSum.bitsum'_key_type b -> Type) -> synth_case: LowParse.Spec.BitSum.synth_case_t b data tag_of_data type_of_tag -> w_tg: LowParse.Low.Base.leaf_writer_strong s -> mk: LowParse.Spec.BitSum.synth_bitsum'_recip_t b -> g: (x: LowParse.Spec.BitSum.bitsum'_key_type b -> LowParse.Spec.Base.serializer (FStar.Pervasives.dsnd (f x))) -> k: LowParse.Spec.BitSum.bitsum'_type b { Mkparser_kind'?.parser_kind_subkind (LowParse.Spec.BitSum.parse_bitsum_kind kt b type_of_tag f) == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\ Mkparser_kind'?.parser_kind_subkind (FStar.Pervasives.dfst (f (LowParse.Spec.BitSum.bitsum'_key_of_t b k))) == FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } -> w_pl: LowParse.Low.Writers.swriter (g (LowParse.Spec.BitSum.bitsum'_key_of_t b k)) h0 space_beyond sout pout_from0 -> w': LowParse.Low.Writers.swriter (LowParse.Spec.BitSum.serialize_bitsum b tag_of_data type_of_tag synth_case s g) h0 space_beyond sout pout_from0 { LowParse.Low.Writers.swvalue w' == SynthCase?.f synth_case k (LowParse.Low.Writers.swvalue w_pl) }
{ "end_col": 3, "end_line": 298, "start_col": 2, "start_line": 282 }
Prims.Tot
val qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem = let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128
val qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem =
false
null
false
let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "total" ]
[ "Spec.P256.PointOps.qelem", "Spec.P256.PointOps.qmul", "Hacl.Spec.P256.Qinv.qsquare_times" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b)
false
true
Hacl.Spec.P256.Qinv.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 qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem
[]
Hacl.Spec.P256.Qinv.qinv_x8_x128
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x6: Spec.P256.PointOps.qelem -> x_11: Spec.P256.PointOps.qelem -> Spec.P256.PointOps.qelem
{ "end_col": 6, "end_line": 54, "start_col": 47, "start_line": 48 }
Prims.Tot
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order
let nat_mod_comm_monoid =
false
null
false
M.mk_nat_mod_comm_monoid S.order
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "total" ]
[ "Lib.NatMod.mk_nat_mod_comm_monoid", "Spec.P256.PointOps.order" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
false
true
Hacl.Spec.P256.Qinv.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 nat_mod_comm_monoid : Lib.Exponentiation.Definition.comm_monoid (Lib.NatMod.nat_mod Spec.P256.PointOps.order)
[]
Hacl.Spec.P256.Qinv.nat_mod_comm_monoid
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Exponentiation.Definition.comm_monoid (Lib.NatMod.nat_mod Spec.P256.PointOps.order)
{ "end_col": 58, "end_line": 12, "start_col": 26, "start_line": 12 }
Prims.Tot
val qinv_x240_x256 (f x240 x_1111 x_10101: S.qelem) : S.qelem
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qinv_x240_x256 (f x240 x_1111 x_10101: S.qelem) : S.qelem = let x243 = S.qmul (qsquare_times x240 3) f in let x250 = S.qmul (qsquare_times x243 7) x_10101 in let x256 = S.qmul (qsquare_times x250 6) x_1111 in x256
val qinv_x240_x256 (f x240 x_1111 x_10101: S.qelem) : S.qelem let qinv_x240_x256 (f x240 x_1111 x_10101: S.qelem) : S.qelem =
false
null
false
let x243 = S.qmul (qsquare_times x240 3) f in let x250 = S.qmul (qsquare_times x243 7) x_10101 in let x256 = S.qmul (qsquare_times x250 6) x_1111 in x256
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "total" ]
[ "Spec.P256.PointOps.qelem", "Spec.P256.PointOps.qmul", "Hacl.Spec.P256.Qinv.qsquare_times" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b) let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem = let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128 let qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem = let x134 = S.qmul (qsquare_times x128 6) x_101111 in let x139 = S.qmul (qsquare_times x134 5) x_111 in let x143 = S.qmul (qsquare_times x139 4) x_11 in let x148 = S.qmul (qsquare_times x143 5) x_1111 in let x153 = S.qmul (qsquare_times x148 5) x_10101 in x153 let qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem = let x157 = S.qmul (qsquare_times x153 4) x_101 in let x160 = S.qmul (qsquare_times x157 3) x_101 in let x163 = S.qmul (qsquare_times x160 3) x_101 in let x168 = S.qmul (qsquare_times x163 5) x_111 in let x177 = S.qmul (qsquare_times x168 9) x_101111 in x177 let qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem = let x183 = S.qmul (qsquare_times x177 6) x_1111 in let x185 = S.qmul (qsquare_times x183 2) f in let x190 = S.qmul (qsquare_times x185 5) f in let x196 = S.qmul (qsquare_times x190 6) x_1111 in let x201 = S.qmul (qsquare_times x196 5) x_111 in let x205 = S.qmul (qsquare_times x201 4) x_111 in let x210 = S.qmul (qsquare_times x205 5) x_111 in x210 let qinv_x210_x240 (x210 x_11 x_101 x_101111: S.qelem) : S.qelem = let x215 = S.qmul (qsquare_times x210 5) x_101 in let x218 = S.qmul (qsquare_times x215 3) x_11 in let x228 = S.qmul (qsquare_times x218 10) x_101111 in let x230 = S.qmul (qsquare_times x228 2) x_11 in let x235 = S.qmul (qsquare_times x230 5) x_11 in let x240 = S.qmul (qsquare_times x235 5) x_11 in x240
false
true
Hacl.Spec.P256.Qinv.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 qinv_x240_x256 (f x240 x_1111 x_10101: S.qelem) : S.qelem
[]
Hacl.Spec.P256.Qinv.qinv_x240_x256
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.P256.PointOps.qelem -> x240: Spec.P256.PointOps.qelem -> x_1111: Spec.P256.PointOps.qelem -> x_10101: Spec.P256.PointOps.qelem -> Spec.P256.PointOps.qelem
{ "end_col": 6, "end_line": 100, "start_col": 63, "start_line": 96 }
Prims.Tot
val qinv_x8_x256 (f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qinv_x8_x256 (f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111 : S.qelem) : S.qelem = let x128 = qinv_x8_x128 x6 x_11 in let x153 = qinv_x134_x153 x128 x_11 x_111 x_1111 x_10101 x_101111 in let x177 = qinv_x153_x177 x153 x_101 x_111 x_101111 in let x210 = qinv_x177_x210 f x177 x_111 x_1111 in let x240 = qinv_x210_x240 x210 x_11 x_101 x_101111 in let x256 = qinv_x240_x256 f x240 x_1111 x_10101 in x256
val qinv_x8_x256 (f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem let qinv_x8_x256 (f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem =
false
null
false
let x128 = qinv_x8_x128 x6 x_11 in let x153 = qinv_x134_x153 x128 x_11 x_111 x_1111 x_10101 x_101111 in let x177 = qinv_x153_x177 x153 x_101 x_111 x_101111 in let x210 = qinv_x177_x210 f x177 x_111 x_1111 in let x240 = qinv_x210_x240 x210 x_11 x_101 x_101111 in let x256 = qinv_x240_x256 f x240 x_1111 x_10101 in x256
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "total" ]
[ "Spec.P256.PointOps.qelem", "Hacl.Spec.P256.Qinv.qinv_x240_x256", "Hacl.Spec.P256.Qinv.qinv_x210_x240", "Hacl.Spec.P256.Qinv.qinv_x177_x210", "Hacl.Spec.P256.Qinv.qinv_x153_x177", "Hacl.Spec.P256.Qinv.qinv_x134_x153", "Hacl.Spec.P256.Qinv.qinv_x8_x128" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b) let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem = let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128 let qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem = let x134 = S.qmul (qsquare_times x128 6) x_101111 in let x139 = S.qmul (qsquare_times x134 5) x_111 in let x143 = S.qmul (qsquare_times x139 4) x_11 in let x148 = S.qmul (qsquare_times x143 5) x_1111 in let x153 = S.qmul (qsquare_times x148 5) x_10101 in x153 let qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem = let x157 = S.qmul (qsquare_times x153 4) x_101 in let x160 = S.qmul (qsquare_times x157 3) x_101 in let x163 = S.qmul (qsquare_times x160 3) x_101 in let x168 = S.qmul (qsquare_times x163 5) x_111 in let x177 = S.qmul (qsquare_times x168 9) x_101111 in x177 let qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem = let x183 = S.qmul (qsquare_times x177 6) x_1111 in let x185 = S.qmul (qsquare_times x183 2) f in let x190 = S.qmul (qsquare_times x185 5) f in let x196 = S.qmul (qsquare_times x190 6) x_1111 in let x201 = S.qmul (qsquare_times x196 5) x_111 in let x205 = S.qmul (qsquare_times x201 4) x_111 in let x210 = S.qmul (qsquare_times x205 5) x_111 in x210 let qinv_x210_x240 (x210 x_11 x_101 x_101111: S.qelem) : S.qelem = let x215 = S.qmul (qsquare_times x210 5) x_101 in let x218 = S.qmul (qsquare_times x215 3) x_11 in let x228 = S.qmul (qsquare_times x218 10) x_101111 in let x230 = S.qmul (qsquare_times x228 2) x_11 in let x235 = S.qmul (qsquare_times x230 5) x_11 in let x240 = S.qmul (qsquare_times x235 5) x_11 in x240 let qinv_x240_x256 (f x240 x_1111 x_10101: S.qelem) : S.qelem = let x243 = S.qmul (qsquare_times x240 3) f in let x250 = S.qmul (qsquare_times x243 7) x_10101 in let x256 = S.qmul (qsquare_times x250 6) x_1111 in x256
false
true
Hacl.Spec.P256.Qinv.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 qinv_x8_x256 (f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem
[]
Hacl.Spec.P256.Qinv.qinv_x8_x256
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.P256.PointOps.qelem -> x6: Spec.P256.PointOps.qelem -> x_11: Spec.P256.PointOps.qelem -> x_101: Spec.P256.PointOps.qelem -> x_111: Spec.P256.PointOps.qelem -> x_1111: Spec.P256.PointOps.qelem -> x_10101: Spec.P256.PointOps.qelem -> x_101111: Spec.P256.PointOps.qelem -> Spec.P256.PointOps.qelem
{ "end_col": 6, "end_line": 110, "start_col": 86, "start_line": 103 }
Prims.Tot
val qsquare_times (a: S.qelem) (b: nat) : S.qelem
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b
val qsquare_times (a: S.qelem) (b: nat) : S.qelem let qsquare_times (a: S.qelem) (b: nat) : S.qelem =
false
null
false
SE.exp_pow2 mk_nat_mod_concrete_ops a b
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "total" ]
[ "Spec.P256.PointOps.qelem", "Prims.nat", "Spec.Exponentiation.exp_pow2", "Hacl.Spec.P256.Qinv.mk_nat_mod_concrete_ops" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; }
false
true
Hacl.Spec.P256.Qinv.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 qsquare_times (a: S.qelem) (b: nat) : S.qelem
[]
Hacl.Spec.P256.Qinv.qsquare_times
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.P256.PointOps.qelem -> b: Prims.nat -> Spec.P256.PointOps.qelem
{ "end_col": 41, "end_line": 37, "start_col": 2, "start_line": 37 }
Prims.Tot
val qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem = let x183 = S.qmul (qsquare_times x177 6) x_1111 in let x185 = S.qmul (qsquare_times x183 2) f in let x190 = S.qmul (qsquare_times x185 5) f in let x196 = S.qmul (qsquare_times x190 6) x_1111 in let x201 = S.qmul (qsquare_times x196 5) x_111 in let x205 = S.qmul (qsquare_times x201 4) x_111 in let x210 = S.qmul (qsquare_times x205 5) x_111 in x210
val qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem let qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem =
false
null
false
let x183 = S.qmul (qsquare_times x177 6) x_1111 in let x185 = S.qmul (qsquare_times x183 2) f in let x190 = S.qmul (qsquare_times x185 5) f in let x196 = S.qmul (qsquare_times x190 6) x_1111 in let x201 = S.qmul (qsquare_times x196 5) x_111 in let x205 = S.qmul (qsquare_times x201 4) x_111 in let x210 = S.qmul (qsquare_times x205 5) x_111 in x210
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "total" ]
[ "Spec.P256.PointOps.qelem", "Spec.P256.PointOps.qmul", "Hacl.Spec.P256.Qinv.qsquare_times" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b) let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem = let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128 let qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem = let x134 = S.qmul (qsquare_times x128 6) x_101111 in let x139 = S.qmul (qsquare_times x134 5) x_111 in let x143 = S.qmul (qsquare_times x139 4) x_11 in let x148 = S.qmul (qsquare_times x143 5) x_1111 in let x153 = S.qmul (qsquare_times x148 5) x_10101 in x153 let qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem = let x157 = S.qmul (qsquare_times x153 4) x_101 in let x160 = S.qmul (qsquare_times x157 3) x_101 in let x163 = S.qmul (qsquare_times x160 3) x_101 in let x168 = S.qmul (qsquare_times x163 5) x_111 in let x177 = S.qmul (qsquare_times x168 9) x_101111 in x177
false
true
Hacl.Spec.P256.Qinv.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 qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem
[]
Hacl.Spec.P256.Qinv.qinv_x177_x210
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.P256.PointOps.qelem -> x177: Spec.P256.PointOps.qelem -> x_111: Spec.P256.PointOps.qelem -> x_1111: Spec.P256.PointOps.qelem -> Spec.P256.PointOps.qelem
{ "end_col": 6, "end_line": 83, "start_col": 61, "start_line": 75 }
Prims.Tot
val qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem = let x134 = S.qmul (qsquare_times x128 6) x_101111 in let x139 = S.qmul (qsquare_times x134 5) x_111 in let x143 = S.qmul (qsquare_times x139 4) x_11 in let x148 = S.qmul (qsquare_times x143 5) x_1111 in let x153 = S.qmul (qsquare_times x148 5) x_10101 in x153
val qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem let qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem =
false
null
false
let x134 = S.qmul (qsquare_times x128 6) x_101111 in let x139 = S.qmul (qsquare_times x134 5) x_111 in let x143 = S.qmul (qsquare_times x139 4) x_11 in let x148 = S.qmul (qsquare_times x143 5) x_1111 in let x153 = S.qmul (qsquare_times x148 5) x_10101 in x153
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "total" ]
[ "Spec.P256.PointOps.qelem", "Spec.P256.PointOps.qmul", "Hacl.Spec.P256.Qinv.qsquare_times" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b) let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem = let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128
false
true
Hacl.Spec.P256.Qinv.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 qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem
[]
Hacl.Spec.P256.Qinv.qinv_x134_x153
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x128: Spec.P256.PointOps.qelem -> x_11: Spec.P256.PointOps.qelem -> x_111: Spec.P256.PointOps.qelem -> x_1111: Spec.P256.PointOps.qelem -> x_10101: Spec.P256.PointOps.qelem -> x_101111: Spec.P256.PointOps.qelem -> Spec.P256.PointOps.qelem
{ "end_col": 6, "end_line": 63, "start_col": 81, "start_line": 57 }
Prims.Tot
val qinv_x210_x240 (x210 x_11 x_101 x_101111: S.qelem) : S.qelem
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qinv_x210_x240 (x210 x_11 x_101 x_101111: S.qelem) : S.qelem = let x215 = S.qmul (qsquare_times x210 5) x_101 in let x218 = S.qmul (qsquare_times x215 3) x_11 in let x228 = S.qmul (qsquare_times x218 10) x_101111 in let x230 = S.qmul (qsquare_times x228 2) x_11 in let x235 = S.qmul (qsquare_times x230 5) x_11 in let x240 = S.qmul (qsquare_times x235 5) x_11 in x240
val qinv_x210_x240 (x210 x_11 x_101 x_101111: S.qelem) : S.qelem let qinv_x210_x240 (x210 x_11 x_101 x_101111: S.qelem) : S.qelem =
false
null
false
let x215 = S.qmul (qsquare_times x210 5) x_101 in let x218 = S.qmul (qsquare_times x215 3) x_11 in let x228 = S.qmul (qsquare_times x218 10) x_101111 in let x230 = S.qmul (qsquare_times x228 2) x_11 in let x235 = S.qmul (qsquare_times x230 5) x_11 in let x240 = S.qmul (qsquare_times x235 5) x_11 in x240
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "total" ]
[ "Spec.P256.PointOps.qelem", "Spec.P256.PointOps.qmul", "Hacl.Spec.P256.Qinv.qsquare_times" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b) let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem = let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128 let qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem = let x134 = S.qmul (qsquare_times x128 6) x_101111 in let x139 = S.qmul (qsquare_times x134 5) x_111 in let x143 = S.qmul (qsquare_times x139 4) x_11 in let x148 = S.qmul (qsquare_times x143 5) x_1111 in let x153 = S.qmul (qsquare_times x148 5) x_10101 in x153 let qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem = let x157 = S.qmul (qsquare_times x153 4) x_101 in let x160 = S.qmul (qsquare_times x157 3) x_101 in let x163 = S.qmul (qsquare_times x160 3) x_101 in let x168 = S.qmul (qsquare_times x163 5) x_111 in let x177 = S.qmul (qsquare_times x168 9) x_101111 in x177 let qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem = let x183 = S.qmul (qsquare_times x177 6) x_1111 in let x185 = S.qmul (qsquare_times x183 2) f in let x190 = S.qmul (qsquare_times x185 5) f in let x196 = S.qmul (qsquare_times x190 6) x_1111 in let x201 = S.qmul (qsquare_times x196 5) x_111 in let x205 = S.qmul (qsquare_times x201 4) x_111 in let x210 = S.qmul (qsquare_times x205 5) x_111 in x210
false
true
Hacl.Spec.P256.Qinv.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 qinv_x210_x240 (x210 x_11 x_101 x_101111: S.qelem) : S.qelem
[]
Hacl.Spec.P256.Qinv.qinv_x210_x240
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x210: Spec.P256.PointOps.qelem -> x_11: Spec.P256.PointOps.qelem -> x_101: Spec.P256.PointOps.qelem -> x_101111: Spec.P256.PointOps.qelem -> Spec.P256.PointOps.qelem
{ "end_col": 6, "end_line": 93, "start_col": 66, "start_line": 86 }
Prims.Tot
val qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem = let x157 = S.qmul (qsquare_times x153 4) x_101 in let x160 = S.qmul (qsquare_times x157 3) x_101 in let x163 = S.qmul (qsquare_times x160 3) x_101 in let x168 = S.qmul (qsquare_times x163 5) x_111 in let x177 = S.qmul (qsquare_times x168 9) x_101111 in x177
val qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem let qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem =
false
null
false
let x157 = S.qmul (qsquare_times x153 4) x_101 in let x160 = S.qmul (qsquare_times x157 3) x_101 in let x163 = S.qmul (qsquare_times x160 3) x_101 in let x168 = S.qmul (qsquare_times x163 5) x_111 in let x177 = S.qmul (qsquare_times x168 9) x_101111 in x177
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "total" ]
[ "Spec.P256.PointOps.qelem", "Spec.P256.PointOps.qmul", "Hacl.Spec.P256.Qinv.qsquare_times" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b) let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem = let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128 let qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem = let x134 = S.qmul (qsquare_times x128 6) x_101111 in let x139 = S.qmul (qsquare_times x134 5) x_111 in let x143 = S.qmul (qsquare_times x139 4) x_11 in let x148 = S.qmul (qsquare_times x143 5) x_1111 in let x153 = S.qmul (qsquare_times x148 5) x_10101 in x153
false
true
Hacl.Spec.P256.Qinv.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 qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem
[]
Hacl.Spec.P256.Qinv.qinv_x153_x177
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x153: Spec.P256.PointOps.qelem -> x_101: Spec.P256.PointOps.qelem -> x_111: Spec.P256.PointOps.qelem -> x_101111: Spec.P256.PointOps.qelem -> Spec.P256.PointOps.qelem
{ "end_col": 6, "end_line": 72, "start_col": 67, "start_line": 66 }
Prims.Tot
val qinv: f:S.qelem -> S.qelem
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qinv f = let x_10 = qsquare_times f 1 in // x_10 is used 3x let x_11 = S.qmul x_10 f in let x_101 = S.qmul x_10 x_11 in let x_111 = S.qmul x_10 x_101 in let x_1010 = qsquare_times x_101 1 in // x_1010 is used 2x let x_1111 = S.qmul x_101 x_1010 in let x_10101 = S.qmul (qsquare_times x_1010 1) f in let x_101010 = qsquare_times x_10101 1 in // x_101010 is used 2x let x_101111 = S.qmul x_101 x_101010 in let x6 = S.qmul x_10101 x_101010 in qinv_x8_x256 f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111
val qinv: f:S.qelem -> S.qelem let qinv f =
false
null
false
let x_10 = qsquare_times f 1 in let x_11 = S.qmul x_10 f in let x_101 = S.qmul x_10 x_11 in let x_111 = S.qmul x_10 x_101 in let x_1010 = qsquare_times x_101 1 in let x_1111 = S.qmul x_101 x_1010 in let x_10101 = S.qmul (qsquare_times x_1010 1) f in let x_101010 = qsquare_times x_10101 1 in let x_101111 = S.qmul x_101 x_101010 in let x6 = S.qmul x_10101 x_101010 in qinv_x8_x256 f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "total" ]
[ "Spec.P256.PointOps.qelem", "Hacl.Spec.P256.Qinv.qinv_x8_x256", "Spec.P256.PointOps.qmul", "Hacl.Spec.P256.Qinv.qsquare_times" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b) let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem = let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128 let qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem = let x134 = S.qmul (qsquare_times x128 6) x_101111 in let x139 = S.qmul (qsquare_times x134 5) x_111 in let x143 = S.qmul (qsquare_times x139 4) x_11 in let x148 = S.qmul (qsquare_times x143 5) x_1111 in let x153 = S.qmul (qsquare_times x148 5) x_10101 in x153 let qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem = let x157 = S.qmul (qsquare_times x153 4) x_101 in let x160 = S.qmul (qsquare_times x157 3) x_101 in let x163 = S.qmul (qsquare_times x160 3) x_101 in let x168 = S.qmul (qsquare_times x163 5) x_111 in let x177 = S.qmul (qsquare_times x168 9) x_101111 in x177 let qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem = let x183 = S.qmul (qsquare_times x177 6) x_1111 in let x185 = S.qmul (qsquare_times x183 2) f in let x190 = S.qmul (qsquare_times x185 5) f in let x196 = S.qmul (qsquare_times x190 6) x_1111 in let x201 = S.qmul (qsquare_times x196 5) x_111 in let x205 = S.qmul (qsquare_times x201 4) x_111 in let x210 = S.qmul (qsquare_times x205 5) x_111 in x210 let qinv_x210_x240 (x210 x_11 x_101 x_101111: S.qelem) : S.qelem = let x215 = S.qmul (qsquare_times x210 5) x_101 in let x218 = S.qmul (qsquare_times x215 3) x_11 in let x228 = S.qmul (qsquare_times x218 10) x_101111 in let x230 = S.qmul (qsquare_times x228 2) x_11 in let x235 = S.qmul (qsquare_times x230 5) x_11 in let x240 = S.qmul (qsquare_times x235 5) x_11 in x240 let qinv_x240_x256 (f x240 x_1111 x_10101: S.qelem) : S.qelem = let x243 = S.qmul (qsquare_times x240 3) f in let x250 = S.qmul (qsquare_times x243 7) x_10101 in let x256 = S.qmul (qsquare_times x250 6) x_1111 in x256 let qinv_x8_x256 (f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111 : S.qelem) : S.qelem = let x128 = qinv_x8_x128 x6 x_11 in let x153 = qinv_x134_x153 x128 x_11 x_111 x_1111 x_10101 x_101111 in let x177 = qinv_x153_x177 x153 x_101 x_111 x_101111 in let x210 = qinv_x177_x210 f x177 x_111 x_1111 in let x240 = qinv_x210_x240 x210 x_11 x_101 x_101111 in let x256 = qinv_x240_x256 f x240 x_1111 x_10101 in x256 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *)
false
true
Hacl.Spec.P256.Qinv.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 qinv: f:S.qelem -> S.qelem
[]
Hacl.Spec.P256.Qinv.qinv
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.P256.PointOps.qelem -> Spec.P256.PointOps.qelem
{ "end_col": 60, "end_line": 131, "start_col": 12, "start_line": 118 }
Prims.Tot
val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sqr_mod x = S.qmul x x
val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x =
false
null
false
S.qmul x x
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "total" ]
[ "Spec.P256.PointOps.qelem", "Spec.P256.PointOps.qmul" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y
false
true
Hacl.Spec.P256.Qinv.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 sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid
[]
Hacl.Spec.P256.Qinv.sqr_mod
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Exponentiation.sqr_st Spec.P256.PointOps.qelem Hacl.Spec.P256.Qinv.mk_to_nat_mod_comm_monoid
{ "end_col": 26, "end_line": 27, "start_col": 16, "start_line": 27 }
Prims.Tot
val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul_mod x y = S.qmul x y
val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y =
false
null
false
S.qmul x y
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "total" ]
[ "Spec.P256.PointOps.qelem", "Spec.P256.PointOps.qmul" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1
false
true
Hacl.Spec.P256.Qinv.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 mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid
[]
Hacl.Spec.P256.Qinv.mul_mod
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Exponentiation.mul_st Spec.P256.PointOps.qelem Hacl.Spec.P256.Qinv.mk_to_nat_mod_comm_monoid
{ "end_col": 28, "end_line": 24, "start_col": 18, "start_line": 24 }
FStar.Pervasives.Lemma
val qinv_is_qinv_lemma: f:S.qelem -> Lemma (qinv f == S.qinv f)
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qinv_is_qinv_lemma f = qinv_lemma f; assert (qinv f == M.pow f (S.order - 2) % S.order); M.lemma_pow_mod #S.order f (S.order - 2)
val qinv_is_qinv_lemma: f:S.qelem -> Lemma (qinv f == S.qinv f) let qinv_is_qinv_lemma f =
false
null
true
qinv_lemma f; assert (qinv f == M.pow f (S.order - 2) % S.order); M.lemma_pow_mod #S.order f (S.order - 2)
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "lemma" ]
[ "Spec.P256.PointOps.qelem", "Lib.NatMod.lemma_pow_mod", "Spec.P256.PointOps.order", "Prims.op_Subtraction", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.int", "Hacl.Spec.P256.Qinv.qinv", "Prims.op_Modulus", "Lib.NatMod.pow", "Hacl.Spec.P256.Qinv.qinv_lemma" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b) let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem = let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128 let qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem = let x134 = S.qmul (qsquare_times x128 6) x_101111 in let x139 = S.qmul (qsquare_times x134 5) x_111 in let x143 = S.qmul (qsquare_times x139 4) x_11 in let x148 = S.qmul (qsquare_times x143 5) x_1111 in let x153 = S.qmul (qsquare_times x148 5) x_10101 in x153 let qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem = let x157 = S.qmul (qsquare_times x153 4) x_101 in let x160 = S.qmul (qsquare_times x157 3) x_101 in let x163 = S.qmul (qsquare_times x160 3) x_101 in let x168 = S.qmul (qsquare_times x163 5) x_111 in let x177 = S.qmul (qsquare_times x168 9) x_101111 in x177 let qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem = let x183 = S.qmul (qsquare_times x177 6) x_1111 in let x185 = S.qmul (qsquare_times x183 2) f in let x190 = S.qmul (qsquare_times x185 5) f in let x196 = S.qmul (qsquare_times x190 6) x_1111 in let x201 = S.qmul (qsquare_times x196 5) x_111 in let x205 = S.qmul (qsquare_times x201 4) x_111 in let x210 = S.qmul (qsquare_times x205 5) x_111 in x210 let qinv_x210_x240 (x210 x_11 x_101 x_101111: S.qelem) : S.qelem = let x215 = S.qmul (qsquare_times x210 5) x_101 in let x218 = S.qmul (qsquare_times x215 3) x_11 in let x228 = S.qmul (qsquare_times x218 10) x_101111 in let x230 = S.qmul (qsquare_times x228 2) x_11 in let x235 = S.qmul (qsquare_times x230 5) x_11 in let x240 = S.qmul (qsquare_times x235 5) x_11 in x240 let qinv_x240_x256 (f x240 x_1111 x_10101: S.qelem) : S.qelem = let x243 = S.qmul (qsquare_times x240 3) f in let x250 = S.qmul (qsquare_times x243 7) x_10101 in let x256 = S.qmul (qsquare_times x250 6) x_1111 in x256 let qinv_x8_x256 (f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111 : S.qelem) : S.qelem = let x128 = qinv_x8_x128 x6 x_11 in let x153 = qinv_x134_x153 x128 x_11 x_111 x_1111 x_10101 x_101111 in let x177 = qinv_x153_x177 x153 x_101 x_111 x_101111 in let x210 = qinv_x177_x210 f x177 x_111 x_1111 in let x240 = qinv_x210_x240 x210 x_11 x_101 x_101111 in let x256 = qinv_x240_x256 f x240 x_1111 x_10101 in x256 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val qinv: f:S.qelem -> S.qelem let qinv f = let x_10 = qsquare_times f 1 in // x_10 is used 3x let x_11 = S.qmul x_10 f in let x_101 = S.qmul x_10 x_11 in let x_111 = S.qmul x_10 x_101 in let x_1010 = qsquare_times x_101 1 in // x_1010 is used 2x let x_1111 = S.qmul x_101 x_1010 in let x_10101 = S.qmul (qsquare_times x_1010 1) f in let x_101010 = qsquare_times x_10101 1 in // x_101010 is used 2x let x_101111 = S.qmul x_101 x_101010 in let x6 = S.qmul x_10101 x_101010 in qinv_x8_x256 f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111 // TODO: mv to lib/ val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.order) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.order; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.order) val lemma_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.order) (M.pow f b % S.order) == M.pow f (a + b) % S.order) let lemma_pow_mod_mul f a b = calc (==) { S.qmul (M.pow f a % S.order) (M.pow f b % S.order); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.order) S.order; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.order } M.pow f a * M.pow f b % S.order; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.order; } val lemma_pow_pow_mod: f:S.qelem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.order) b % S.order == M.pow f (a * b) % S.order) let lemma_pow_pow_mod f a b = calc (==) { M.pow (M.pow f a % S.order) b % S.order; (==) { M.lemma_pow_mod_base (M.pow f a) b S.order } M.pow (M.pow f a) b % S.order; (==) { M.lemma_pow_mul f a b } M.pow f (a * b) % S.order; } val lemma_pow_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> c:nat -> Lemma (S.qmul (M.pow (M.pow f a % S.order) b % S.order) (M.pow f c % S.order) == M.pow f (a * b + c) % S.order) let lemma_pow_pow_mod_mul f a b c = calc (==) { S.qmul (M.pow (M.pow f a % S.order) b % S.order) (M.pow f c % S.order); (==) { lemma_pow_pow_mod f a b } S.qmul (M.pow f (a * b) % S.order) (M.pow f c % S.order); (==) { lemma_pow_mod_mul f (a * b) c } M.pow f (a * b + c) % S.order; } ////////////////////////////// // S.order - 2 = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f val qinv_lemma: f:S.qelem -> Lemma (qinv f == M.pow f (S.order - 2) % S.order) let qinv_lemma f = let x_10 = qsquare_times f 1 in qsquare_times_lemma f 1; assert_norm (pow2 1 = 0x2); assert (x_10 == M.pow f 0x2 % S.order); let x_11 = S.qmul x_10 f in lemma_pow_mod_1 f; lemma_pow_mod_mul f 0x2 0x1; assert (x_11 == M.pow f 0x3 % S.order); let x_101 = S.qmul x_10 x_11 in lemma_pow_mod_mul f 0x2 0x3; assert (x_101 == M.pow f 0x5 % S.order); let x_111 = S.qmul x_10 x_101 in lemma_pow_mod_mul f 0x2 0x5; assert (x_111 == M.pow f 0x7 % S.order); let x_1010 = qsquare_times x_101 1 in qsquare_times_lemma x_101 1; assert_norm (pow2 1 = 2); lemma_pow_pow_mod f 0x5 0x2; assert (x_1010 == M.pow f 0xa % S.order); let x_1111 = S.qmul x_101 x_1010 in lemma_pow_mod_mul f 0x5 0xa; assert (x_1111 == M.pow f 0xf % S.order); let x_10101 = S.qmul (qsquare_times x_1010 1) f in qsquare_times_lemma x_1010 1; lemma_pow_pow_mod_mul f 0xa 0x2 0x1; assert (x_10101 == M.pow f 0x15 % S.order); let x_101010 = qsquare_times x_10101 1 in qsquare_times_lemma x_10101 1; lemma_pow_pow_mod f 0x15 0x2; assert (x_101010 == M.pow f 0x2a % S.order); let x_101111 = S.qmul x_101 x_101010 in lemma_pow_mod_mul f 0x5 0x2a; assert (x_101111 == M.pow f 0x2f % S.order); let x6 = S.qmul x_10101 x_101010 in lemma_pow_mod_mul f 0x15 0x2a; assert (x6 == M.pow f 0x3f % S.order); let x8 = S.qmul (qsquare_times x6 2) x_11 in qsquare_times_lemma x6 2; assert_norm (pow2 2 = 0x4); lemma_pow_pow_mod_mul f 0x3f 0x4 0x3; assert (x8 == M.pow f 0xff % S.order); let x16 = S.qmul (qsquare_times x8 8) x8 in qsquare_times_lemma x8 8; assert_norm (pow2 8 = 0x100); lemma_pow_pow_mod_mul f 0xff 0x100 0xff; assert (x16 == M.pow f 0xffff % S.order); let x32 = S.qmul (qsquare_times x16 16) x16 in qsquare_times_lemma x16 16; assert_norm (pow2 16 = 0x10000); lemma_pow_pow_mod_mul f 0xffff 0x10000 0xffff; assert (x32 == M.pow f 0xffffffff % S.order); let x96 = S.qmul (qsquare_times x32 64) x32 in qsquare_times_lemma x32 64; assert_norm (pow2 64 = 0x10000000000000000); lemma_pow_pow_mod_mul f 0xffffffff 0x10000000000000000 0xffffffff; assert (x96 == M.pow f 0xffffffff00000000ffffffff % S.order); let x128 = S.qmul (qsquare_times x96 32) x32 in qsquare_times_lemma x96 32; assert_norm (pow2 32 = 0x100000000); lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffff 0x100000000 0xffffffff; assert (x128 == M.pow f 0xffffffff00000000ffffffffffffffff % S.order); let x134 = S.qmul (qsquare_times x128 6) x_101111 in qsquare_times_lemma x128 6; assert_norm (pow2 6 = 0x40); lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffff 0x40 0x2f; assert (x134 == M.pow f 0x3fffffffc00000003fffffffffffffffef % S.order); let x139 = S.qmul (qsquare_times x134 5) x_111 in qsquare_times_lemma x134 5; assert_norm (pow2 5 = 0x20); lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef 0x20 0x7; assert (x139 == M.pow f 0x7fffffff800000007fffffffffffffffde7 % S.order); let x143 = S.qmul (qsquare_times x139 4) x_11 in qsquare_times_lemma x139 4; assert_norm (pow2 4 = 0x10); lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde7 0x10 0x3; assert (x143 == M.pow f 0x7fffffff800000007fffffffffffffffde73 % S.order); let x148 = S.qmul (qsquare_times x143 5) x_1111 in qsquare_times_lemma x143 5; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde73 0x20 0xf; assert (x148 == M.pow f 0xffffffff00000000ffffffffffffffffbce6f % S.order); let x153 = S.qmul (qsquare_times x148 5) x_10101 in qsquare_times_lemma x148 5; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6f 0x20 0x15; assert (x153 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf5 % S.order); let x157 = S.qmul (qsquare_times x153 4) x_101 in qsquare_times_lemma x153 4; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf5 0x10 0x5; assert (x157 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55 % S.order); let x160 = S.qmul (qsquare_times x157 3) x_101 in qsquare_times_lemma x157 3; assert_norm (pow2 3 = 0x8); lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55 0x8 0x5; assert (x160 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faad % S.order); let x163 = S.qmul (qsquare_times x160 3) x_101 in qsquare_times_lemma x160 3; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faad 0x8 0x5; assert (x163 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d % S.order); let x168 = S.qmul (qsquare_times x163 5) x_111 in qsquare_times_lemma x163 5; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d 0x20 0x7; assert (x168 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7 % S.order); let x177 = S.qmul (qsquare_times x168 9) x_101111 in qsquare_times_lemma x168 9; assert_norm (pow2 9 = 0x200); lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faada7 0x200 0x2f; assert (x177 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f % S.order); let x183 = S.qmul (qsquare_times x177 6) x_1111 in qsquare_times_lemma x177 6; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f 0x40 0xf; assert (x183 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d38bcf % S.order); let x185 = S.qmul (qsquare_times x183 2) f in qsquare_times_lemma x183 2; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d38bcf 0x4 0x1; assert (x185 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d % S.order); let x190 = S.qmul (qsquare_times x185 5) f in qsquare_times_lemma x185 5; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d 0x20 0x1; assert (x190 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a1 % S.order); let x196 = S.qmul (qsquare_times x190 6) x_1111 in qsquare_times_lemma x190 6; lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a1 0x40 0xf; assert (x196 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f % S.order); let x201 = S.qmul (qsquare_times x196 5) x_111 in qsquare_times_lemma x196 5; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f 0x20 0x7; assert (x201 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d09e7 % S.order); let x205 = S.qmul (qsquare_times x201 4) x_111 in qsquare_times_lemma x201 4; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d09e7 0x10 0x7; assert (x205 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d09e77 % S.order); let x210 = S.qmul (qsquare_times x205 5) x_111 in qsquare_times_lemma x205 5; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d09e77 0x20 0x7; assert (x210 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee7 % S.order); let x215 = S.qmul (qsquare_times x210 5) x_101 in qsquare_times_lemma x210 5; lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee7 0x20 0x5; assert (x215 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5 % S.order); let x218 = S.qmul (qsquare_times x215 3) x_11 in qsquare_times_lemma x215 3; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5 0x8 0x3; assert (x218 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b % S.order); let x228 = S.qmul (qsquare_times x218 10) x_101111 in qsquare_times_lemma x218 10; assert_norm (pow2 10 = 0x400); lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b 0x400 0x2f; assert (x228 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2f % S.order); let x230 = S.qmul (qsquare_times x228 2) x_11 in qsquare_times_lemma x228 2; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2f 0x4 0x3; assert (x230 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b0bf % S.order); let x235 = S.qmul (qsquare_times x230 5) x_11 in qsquare_times_lemma x230 5; lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b0bf 0x20 0x3; assert (x235 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e3 % S.order); let x240 = S.qmul (qsquare_times x235 5) x_11 in qsquare_times_lemma x235 5; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e3 0x20 0x3; assert (x240 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63 % S.order); let x243 = S.qmul (qsquare_times x240 3) f in qsquare_times_lemma x240 3; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63 0x8 0x1; assert (x243 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e319 % S.order); let x250 = S.qmul (qsquare_times x243 7) x_10101 in qsquare_times_lemma x243 7; assert_norm (pow2 7 = 0x80); lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e319 0x80 0x15; assert (x250 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b0bf18c95 % S.order); let x256 = S.qmul (qsquare_times x250 6) x_1111 in qsquare_times_lemma x250 6; lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b0bf18c95 0x40 0xf; assert (x256 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f % S.order); assert_norm (S.order - 2 = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f) val qinv_is_qinv_lemma: f:S.qelem -> Lemma (qinv f == S.qinv f)
false
false
Hacl.Spec.P256.Qinv.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 qinv_is_qinv_lemma: f:S.qelem -> Lemma (qinv f == S.qinv f)
[]
Hacl.Spec.P256.Qinv.qinv_is_qinv_lemma
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.P256.PointOps.qelem -> FStar.Pervasives.Lemma (ensures Hacl.Spec.P256.Qinv.qinv f == Spec.P256.PointOps.qinv f)
{ "end_col": 42, "end_line": 405, "start_col": 2, "start_line": 403 }
FStar.Pervasives.Lemma
val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.order)
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.order; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.order)
val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.order) let lemma_pow_mod_1 f =
false
null
true
M.lemma_pow1 f; Math.Lemmas.small_mod f S.order; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.order)
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "lemma" ]
[ "Spec.P256.PointOps.qelem", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Lib.NatMod.pow", "Spec.P256.PointOps.order", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.pow2", "FStar.Math.Lemmas.small_mod", "Lib.NatMod.lemma_pow1" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b) let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem = let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128 let qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem = let x134 = S.qmul (qsquare_times x128 6) x_101111 in let x139 = S.qmul (qsquare_times x134 5) x_111 in let x143 = S.qmul (qsquare_times x139 4) x_11 in let x148 = S.qmul (qsquare_times x143 5) x_1111 in let x153 = S.qmul (qsquare_times x148 5) x_10101 in x153 let qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem = let x157 = S.qmul (qsquare_times x153 4) x_101 in let x160 = S.qmul (qsquare_times x157 3) x_101 in let x163 = S.qmul (qsquare_times x160 3) x_101 in let x168 = S.qmul (qsquare_times x163 5) x_111 in let x177 = S.qmul (qsquare_times x168 9) x_101111 in x177 let qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem = let x183 = S.qmul (qsquare_times x177 6) x_1111 in let x185 = S.qmul (qsquare_times x183 2) f in let x190 = S.qmul (qsquare_times x185 5) f in let x196 = S.qmul (qsquare_times x190 6) x_1111 in let x201 = S.qmul (qsquare_times x196 5) x_111 in let x205 = S.qmul (qsquare_times x201 4) x_111 in let x210 = S.qmul (qsquare_times x205 5) x_111 in x210 let qinv_x210_x240 (x210 x_11 x_101 x_101111: S.qelem) : S.qelem = let x215 = S.qmul (qsquare_times x210 5) x_101 in let x218 = S.qmul (qsquare_times x215 3) x_11 in let x228 = S.qmul (qsquare_times x218 10) x_101111 in let x230 = S.qmul (qsquare_times x228 2) x_11 in let x235 = S.qmul (qsquare_times x230 5) x_11 in let x240 = S.qmul (qsquare_times x235 5) x_11 in x240 let qinv_x240_x256 (f x240 x_1111 x_10101: S.qelem) : S.qelem = let x243 = S.qmul (qsquare_times x240 3) f in let x250 = S.qmul (qsquare_times x243 7) x_10101 in let x256 = S.qmul (qsquare_times x250 6) x_1111 in x256 let qinv_x8_x256 (f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111 : S.qelem) : S.qelem = let x128 = qinv_x8_x128 x6 x_11 in let x153 = qinv_x134_x153 x128 x_11 x_111 x_1111 x_10101 x_101111 in let x177 = qinv_x153_x177 x153 x_101 x_111 x_101111 in let x210 = qinv_x177_x210 f x177 x_111 x_1111 in let x240 = qinv_x210_x240 x210 x_11 x_101 x_101111 in let x256 = qinv_x240_x256 f x240 x_1111 x_10101 in x256 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val qinv: f:S.qelem -> S.qelem let qinv f = let x_10 = qsquare_times f 1 in // x_10 is used 3x let x_11 = S.qmul x_10 f in let x_101 = S.qmul x_10 x_11 in let x_111 = S.qmul x_10 x_101 in let x_1010 = qsquare_times x_101 1 in // x_1010 is used 2x let x_1111 = S.qmul x_101 x_1010 in let x_10101 = S.qmul (qsquare_times x_1010 1) f in let x_101010 = qsquare_times x_10101 1 in // x_101010 is used 2x let x_101111 = S.qmul x_101 x_101010 in let x6 = S.qmul x_10101 x_101010 in qinv_x8_x256 f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111 // TODO: mv to lib/ val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.order)
false
false
Hacl.Spec.P256.Qinv.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_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.order)
[]
Hacl.Spec.P256.Qinv.lemma_pow_mod_1
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.P256.PointOps.qelem -> FStar.Pervasives.Lemma (ensures f == Lib.NatMod.pow f 1 % Spec.P256.PointOps.order)
{ "end_col": 35, "end_line": 140, "start_col": 2, "start_line": 137 }
Prims.Tot
val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let one_mod _ = 1
val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ =
false
null
false
1
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "total" ]
[ "Prims.unit", "Spec.P256.PointOps.qelem" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); }
false
true
Hacl.Spec.P256.Qinv.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 one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid
[]
Hacl.Spec.P256.Qinv.one_mod
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Exponentiation.one_st Spec.P256.PointOps.qelem Hacl.Spec.P256.Qinv.mk_to_nat_mod_comm_monoid
{ "end_col": 17, "end_line": 21, "start_col": 16, "start_line": 21 }
FStar.Pervasives.Lemma
val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order)
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b)
val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b =
false
null
true
SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b)
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "lemma" ]
[ "Spec.P256.PointOps.qelem", "Prims.nat", "Lib.NatMod.lemma_pow_nat_mod_is_pow", "Spec.P256.PointOps.order", "Prims.pow2", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.l_or", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.P256.Qinv.qsquare_times", "Lib.Exponentiation.Definition.pow", "Lib.NatMod.nat_mod", "Hacl.Spec.P256.Qinv.nat_mod_comm_monoid", "Lib.Exponentiation.exp_pow2_lemma", "Spec.Exponentiation.exp_pow2_lemma", "Hacl.Spec.P256.Qinv.mk_nat_mod_concrete_ops" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order)
false
false
Hacl.Spec.P256.Qinv.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 qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order)
[]
Hacl.Spec.P256.Qinv.qsquare_times_lemma
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.P256.PointOps.qelem -> b: Prims.nat -> FStar.Pervasives.Lemma (ensures Hacl.Spec.P256.Qinv.qsquare_times a b == Lib.NatMod.pow a (Prims.pow2 b) % Spec.P256.PointOps.order)
{ "end_col": 48, "end_line": 45, "start_col": 2, "start_line": 42 }
FStar.Pervasives.Lemma
val lemma_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.order) (M.pow f b % S.order) == M.pow f (a + b) % S.order)
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_pow_mod_mul f a b = calc (==) { S.qmul (M.pow f a % S.order) (M.pow f b % S.order); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.order) S.order; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.order } M.pow f a * M.pow f b % S.order; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.order; }
val lemma_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.order) (M.pow f b % S.order) == M.pow f (a + b) % S.order) let lemma_pow_mod_mul f a b =
false
null
true
calc ( == ) { S.qmul (M.pow f a % S.order) (M.pow f b % S.order); ( == ) { (Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.order) S.order; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.order) } M.pow f a * M.pow f b % S.order; ( == ) { M.lemma_pow_add f a b } M.pow f (a + b) % S.order; }
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "lemma" ]
[ "Spec.P256.PointOps.qelem", "Prims.nat", "FStar.Calc.calc_finish", "Prims.eq2", "Spec.P256.PointOps.qmul", "Prims.op_Modulus", "Lib.NatMod.pow", "Spec.P256.PointOps.order", "Prims.op_Addition", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Mul.op_Star", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "FStar.Math.Lemmas.lemma_mod_mul_distr_r", "FStar.Math.Lemmas.lemma_mod_mul_distr_l", "Prims.squash", "Lib.NatMod.lemma_pow_add" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b) let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem = let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128 let qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem = let x134 = S.qmul (qsquare_times x128 6) x_101111 in let x139 = S.qmul (qsquare_times x134 5) x_111 in let x143 = S.qmul (qsquare_times x139 4) x_11 in let x148 = S.qmul (qsquare_times x143 5) x_1111 in let x153 = S.qmul (qsquare_times x148 5) x_10101 in x153 let qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem = let x157 = S.qmul (qsquare_times x153 4) x_101 in let x160 = S.qmul (qsquare_times x157 3) x_101 in let x163 = S.qmul (qsquare_times x160 3) x_101 in let x168 = S.qmul (qsquare_times x163 5) x_111 in let x177 = S.qmul (qsquare_times x168 9) x_101111 in x177 let qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem = let x183 = S.qmul (qsquare_times x177 6) x_1111 in let x185 = S.qmul (qsquare_times x183 2) f in let x190 = S.qmul (qsquare_times x185 5) f in let x196 = S.qmul (qsquare_times x190 6) x_1111 in let x201 = S.qmul (qsquare_times x196 5) x_111 in let x205 = S.qmul (qsquare_times x201 4) x_111 in let x210 = S.qmul (qsquare_times x205 5) x_111 in x210 let qinv_x210_x240 (x210 x_11 x_101 x_101111: S.qelem) : S.qelem = let x215 = S.qmul (qsquare_times x210 5) x_101 in let x218 = S.qmul (qsquare_times x215 3) x_11 in let x228 = S.qmul (qsquare_times x218 10) x_101111 in let x230 = S.qmul (qsquare_times x228 2) x_11 in let x235 = S.qmul (qsquare_times x230 5) x_11 in let x240 = S.qmul (qsquare_times x235 5) x_11 in x240 let qinv_x240_x256 (f x240 x_1111 x_10101: S.qelem) : S.qelem = let x243 = S.qmul (qsquare_times x240 3) f in let x250 = S.qmul (qsquare_times x243 7) x_10101 in let x256 = S.qmul (qsquare_times x250 6) x_1111 in x256 let qinv_x8_x256 (f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111 : S.qelem) : S.qelem = let x128 = qinv_x8_x128 x6 x_11 in let x153 = qinv_x134_x153 x128 x_11 x_111 x_1111 x_10101 x_101111 in let x177 = qinv_x153_x177 x153 x_101 x_111 x_101111 in let x210 = qinv_x177_x210 f x177 x_111 x_1111 in let x240 = qinv_x210_x240 x210 x_11 x_101 x_101111 in let x256 = qinv_x240_x256 f x240 x_1111 x_10101 in x256 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val qinv: f:S.qelem -> S.qelem let qinv f = let x_10 = qsquare_times f 1 in // x_10 is used 3x let x_11 = S.qmul x_10 f in let x_101 = S.qmul x_10 x_11 in let x_111 = S.qmul x_10 x_101 in let x_1010 = qsquare_times x_101 1 in // x_1010 is used 2x let x_1111 = S.qmul x_101 x_1010 in let x_10101 = S.qmul (qsquare_times x_1010 1) f in let x_101010 = qsquare_times x_10101 1 in // x_101010 is used 2x let x_101111 = S.qmul x_101 x_101010 in let x6 = S.qmul x_10101 x_101010 in qinv_x8_x256 f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111 // TODO: mv to lib/ val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.order) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.order; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.order) val lemma_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.order) (M.pow f b % S.order) == M.pow f (a + b) % S.order)
false
false
Hacl.Spec.P256.Qinv.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_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.order) (M.pow f b % S.order) == M.pow f (a + b) % S.order)
[]
Hacl.Spec.P256.Qinv.lemma_pow_mod_mul
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.P256.PointOps.qelem -> a: Prims.nat -> b: Prims.nat -> FStar.Pervasives.Lemma (ensures Spec.P256.PointOps.qmul (Lib.NatMod.pow f a % Spec.P256.PointOps.order) (Lib.NatMod.pow f b % Spec.P256.PointOps.order) == Lib.NatMod.pow f (a + b) % Spec.P256.PointOps.order)
{ "end_col": 3, "end_line": 154, "start_col": 2, "start_line": 146 }
FStar.Pervasives.Lemma
val lemma_pow_pow_mod: f:S.qelem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.order) b % S.order == M.pow f (a * b) % S.order)
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_pow_pow_mod f a b = calc (==) { M.pow (M.pow f a % S.order) b % S.order; (==) { M.lemma_pow_mod_base (M.pow f a) b S.order } M.pow (M.pow f a) b % S.order; (==) { M.lemma_pow_mul f a b } M.pow f (a * b) % S.order; }
val lemma_pow_pow_mod: f:S.qelem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.order) b % S.order == M.pow f (a * b) % S.order) let lemma_pow_pow_mod f a b =
false
null
true
calc ( == ) { M.pow (M.pow f a % S.order) b % S.order; ( == ) { M.lemma_pow_mod_base (M.pow f a) b S.order } M.pow (M.pow f a) b % S.order; ( == ) { M.lemma_pow_mul f a b } M.pow f (a * b) % S.order; }
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "lemma" ]
[ "Spec.P256.PointOps.qelem", "Prims.nat", "FStar.Calc.calc_finish", "Prims.int", "Prims.eq2", "Prims.op_Modulus", "Lib.NatMod.pow", "Spec.P256.PointOps.order", "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", "Lib.NatMod.lemma_pow_mod_base", "Prims.squash", "Lib.NatMod.lemma_pow_mul" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b) let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem = let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128 let qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem = let x134 = S.qmul (qsquare_times x128 6) x_101111 in let x139 = S.qmul (qsquare_times x134 5) x_111 in let x143 = S.qmul (qsquare_times x139 4) x_11 in let x148 = S.qmul (qsquare_times x143 5) x_1111 in let x153 = S.qmul (qsquare_times x148 5) x_10101 in x153 let qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem = let x157 = S.qmul (qsquare_times x153 4) x_101 in let x160 = S.qmul (qsquare_times x157 3) x_101 in let x163 = S.qmul (qsquare_times x160 3) x_101 in let x168 = S.qmul (qsquare_times x163 5) x_111 in let x177 = S.qmul (qsquare_times x168 9) x_101111 in x177 let qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem = let x183 = S.qmul (qsquare_times x177 6) x_1111 in let x185 = S.qmul (qsquare_times x183 2) f in let x190 = S.qmul (qsquare_times x185 5) f in let x196 = S.qmul (qsquare_times x190 6) x_1111 in let x201 = S.qmul (qsquare_times x196 5) x_111 in let x205 = S.qmul (qsquare_times x201 4) x_111 in let x210 = S.qmul (qsquare_times x205 5) x_111 in x210 let qinv_x210_x240 (x210 x_11 x_101 x_101111: S.qelem) : S.qelem = let x215 = S.qmul (qsquare_times x210 5) x_101 in let x218 = S.qmul (qsquare_times x215 3) x_11 in let x228 = S.qmul (qsquare_times x218 10) x_101111 in let x230 = S.qmul (qsquare_times x228 2) x_11 in let x235 = S.qmul (qsquare_times x230 5) x_11 in let x240 = S.qmul (qsquare_times x235 5) x_11 in x240 let qinv_x240_x256 (f x240 x_1111 x_10101: S.qelem) : S.qelem = let x243 = S.qmul (qsquare_times x240 3) f in let x250 = S.qmul (qsquare_times x243 7) x_10101 in let x256 = S.qmul (qsquare_times x250 6) x_1111 in x256 let qinv_x8_x256 (f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111 : S.qelem) : S.qelem = let x128 = qinv_x8_x128 x6 x_11 in let x153 = qinv_x134_x153 x128 x_11 x_111 x_1111 x_10101 x_101111 in let x177 = qinv_x153_x177 x153 x_101 x_111 x_101111 in let x210 = qinv_x177_x210 f x177 x_111 x_1111 in let x240 = qinv_x210_x240 x210 x_11 x_101 x_101111 in let x256 = qinv_x240_x256 f x240 x_1111 x_10101 in x256 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val qinv: f:S.qelem -> S.qelem let qinv f = let x_10 = qsquare_times f 1 in // x_10 is used 3x let x_11 = S.qmul x_10 f in let x_101 = S.qmul x_10 x_11 in let x_111 = S.qmul x_10 x_101 in let x_1010 = qsquare_times x_101 1 in // x_1010 is used 2x let x_1111 = S.qmul x_101 x_1010 in let x_10101 = S.qmul (qsquare_times x_1010 1) f in let x_101010 = qsquare_times x_10101 1 in // x_101010 is used 2x let x_101111 = S.qmul x_101 x_101010 in let x6 = S.qmul x_10101 x_101010 in qinv_x8_x256 f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111 // TODO: mv to lib/ val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.order) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.order; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.order) val lemma_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.order) (M.pow f b % S.order) == M.pow f (a + b) % S.order) let lemma_pow_mod_mul f a b = calc (==) { S.qmul (M.pow f a % S.order) (M.pow f b % S.order); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.order) S.order; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.order } M.pow f a * M.pow f b % S.order; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.order; } val lemma_pow_pow_mod: f:S.qelem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.order) b % S.order == M.pow f (a * b) % S.order)
false
false
Hacl.Spec.P256.Qinv.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_pow_pow_mod: f:S.qelem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.order) b % S.order == M.pow f (a * b) % S.order)
[]
Hacl.Spec.P256.Qinv.lemma_pow_pow_mod
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.P256.PointOps.qelem -> a: Prims.nat -> b: Prims.nat -> FStar.Pervasives.Lemma (ensures Lib.NatMod.pow (Lib.NatMod.pow f a % Spec.P256.PointOps.order) b % Spec.P256.PointOps.order == Lib.NatMod.pow f (a * b) % Spec.P256.PointOps.order)
{ "end_col": 5, "end_line": 166, "start_col": 2, "start_line": 160 }
FStar.Pervasives.Lemma
val lemma_pow_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> c:nat -> Lemma (S.qmul (M.pow (M.pow f a % S.order) b % S.order) (M.pow f c % S.order) == M.pow f (a * b + c) % S.order)
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_pow_pow_mod_mul f a b c = calc (==) { S.qmul (M.pow (M.pow f a % S.order) b % S.order) (M.pow f c % S.order); (==) { lemma_pow_pow_mod f a b } S.qmul (M.pow f (a * b) % S.order) (M.pow f c % S.order); (==) { lemma_pow_mod_mul f (a * b) c } M.pow f (a * b + c) % S.order; }
val lemma_pow_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> c:nat -> Lemma (S.qmul (M.pow (M.pow f a % S.order) b % S.order) (M.pow f c % S.order) == M.pow f (a * b + c) % S.order) let lemma_pow_pow_mod_mul f a b c =
false
null
true
calc ( == ) { S.qmul (M.pow (M.pow f a % S.order) b % S.order) (M.pow f c % S.order); ( == ) { lemma_pow_pow_mod f a b } S.qmul (M.pow f (a * b) % S.order) (M.pow f c % S.order); ( == ) { lemma_pow_mod_mul f (a * b) c } M.pow f (a * b + c) % S.order; }
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "lemma" ]
[ "Spec.P256.PointOps.qelem", "Prims.nat", "FStar.Calc.calc_finish", "Prims.eq2", "Spec.P256.PointOps.qmul", "Prims.op_Modulus", "Lib.NatMod.pow", "Spec.P256.PointOps.order", "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", "Hacl.Spec.P256.Qinv.lemma_pow_pow_mod", "Prims.squash", "Hacl.Spec.P256.Qinv.lemma_pow_mod_mul" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b) let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem = let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128 let qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem = let x134 = S.qmul (qsquare_times x128 6) x_101111 in let x139 = S.qmul (qsquare_times x134 5) x_111 in let x143 = S.qmul (qsquare_times x139 4) x_11 in let x148 = S.qmul (qsquare_times x143 5) x_1111 in let x153 = S.qmul (qsquare_times x148 5) x_10101 in x153 let qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem = let x157 = S.qmul (qsquare_times x153 4) x_101 in let x160 = S.qmul (qsquare_times x157 3) x_101 in let x163 = S.qmul (qsquare_times x160 3) x_101 in let x168 = S.qmul (qsquare_times x163 5) x_111 in let x177 = S.qmul (qsquare_times x168 9) x_101111 in x177 let qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem = let x183 = S.qmul (qsquare_times x177 6) x_1111 in let x185 = S.qmul (qsquare_times x183 2) f in let x190 = S.qmul (qsquare_times x185 5) f in let x196 = S.qmul (qsquare_times x190 6) x_1111 in let x201 = S.qmul (qsquare_times x196 5) x_111 in let x205 = S.qmul (qsquare_times x201 4) x_111 in let x210 = S.qmul (qsquare_times x205 5) x_111 in x210 let qinv_x210_x240 (x210 x_11 x_101 x_101111: S.qelem) : S.qelem = let x215 = S.qmul (qsquare_times x210 5) x_101 in let x218 = S.qmul (qsquare_times x215 3) x_11 in let x228 = S.qmul (qsquare_times x218 10) x_101111 in let x230 = S.qmul (qsquare_times x228 2) x_11 in let x235 = S.qmul (qsquare_times x230 5) x_11 in let x240 = S.qmul (qsquare_times x235 5) x_11 in x240 let qinv_x240_x256 (f x240 x_1111 x_10101: S.qelem) : S.qelem = let x243 = S.qmul (qsquare_times x240 3) f in let x250 = S.qmul (qsquare_times x243 7) x_10101 in let x256 = S.qmul (qsquare_times x250 6) x_1111 in x256 let qinv_x8_x256 (f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111 : S.qelem) : S.qelem = let x128 = qinv_x8_x128 x6 x_11 in let x153 = qinv_x134_x153 x128 x_11 x_111 x_1111 x_10101 x_101111 in let x177 = qinv_x153_x177 x153 x_101 x_111 x_101111 in let x210 = qinv_x177_x210 f x177 x_111 x_1111 in let x240 = qinv_x210_x240 x210 x_11 x_101 x_101111 in let x256 = qinv_x240_x256 f x240 x_1111 x_10101 in x256 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val qinv: f:S.qelem -> S.qelem let qinv f = let x_10 = qsquare_times f 1 in // x_10 is used 3x let x_11 = S.qmul x_10 f in let x_101 = S.qmul x_10 x_11 in let x_111 = S.qmul x_10 x_101 in let x_1010 = qsquare_times x_101 1 in // x_1010 is used 2x let x_1111 = S.qmul x_101 x_1010 in let x_10101 = S.qmul (qsquare_times x_1010 1) f in let x_101010 = qsquare_times x_10101 1 in // x_101010 is used 2x let x_101111 = S.qmul x_101 x_101010 in let x6 = S.qmul x_10101 x_101010 in qinv_x8_x256 f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111 // TODO: mv to lib/ val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.order) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.order; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.order) val lemma_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.order) (M.pow f b % S.order) == M.pow f (a + b) % S.order) let lemma_pow_mod_mul f a b = calc (==) { S.qmul (M.pow f a % S.order) (M.pow f b % S.order); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.order) S.order; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.order } M.pow f a * M.pow f b % S.order; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.order; } val lemma_pow_pow_mod: f:S.qelem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.order) b % S.order == M.pow f (a * b) % S.order) let lemma_pow_pow_mod f a b = calc (==) { M.pow (M.pow f a % S.order) b % S.order; (==) { M.lemma_pow_mod_base (M.pow f a) b S.order } M.pow (M.pow f a) b % S.order; (==) { M.lemma_pow_mul f a b } M.pow f (a * b) % S.order; } val lemma_pow_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> c:nat -> Lemma (S.qmul (M.pow (M.pow f a % S.order) b % S.order) (M.pow f c % S.order) == M.pow f (a * b + c) % S.order)
false
false
Hacl.Spec.P256.Qinv.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_pow_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> c:nat -> Lemma (S.qmul (M.pow (M.pow f a % S.order) b % S.order) (M.pow f c % S.order) == M.pow f (a * b + c) % S.order)
[]
Hacl.Spec.P256.Qinv.lemma_pow_pow_mod_mul
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.P256.PointOps.qelem -> a: Prims.nat -> b: Prims.nat -> c: Prims.nat -> FStar.Pervasives.Lemma (ensures Spec.P256.PointOps.qmul (Lib.NatMod.pow (Lib.NatMod.pow f a % Spec.P256.PointOps.order) b % Spec.P256.PointOps.order) (Lib.NatMod.pow f c % Spec.P256.PointOps.order) == Lib.NatMod.pow f (a * b + c) % Spec.P256.PointOps.order)
{ "end_col": 3, "end_line": 178, "start_col": 2, "start_line": 172 }
FStar.Pervasives.Lemma
val qinv_lemma: f:S.qelem -> Lemma (qinv f == M.pow f (S.order - 2) % S.order)
[ { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.NatMod", "short_module": "M" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let qinv_lemma f = let x_10 = qsquare_times f 1 in qsquare_times_lemma f 1; assert_norm (pow2 1 = 0x2); assert (x_10 == M.pow f 0x2 % S.order); let x_11 = S.qmul x_10 f in lemma_pow_mod_1 f; lemma_pow_mod_mul f 0x2 0x1; assert (x_11 == M.pow f 0x3 % S.order); let x_101 = S.qmul x_10 x_11 in lemma_pow_mod_mul f 0x2 0x3; assert (x_101 == M.pow f 0x5 % S.order); let x_111 = S.qmul x_10 x_101 in lemma_pow_mod_mul f 0x2 0x5; assert (x_111 == M.pow f 0x7 % S.order); let x_1010 = qsquare_times x_101 1 in qsquare_times_lemma x_101 1; assert_norm (pow2 1 = 2); lemma_pow_pow_mod f 0x5 0x2; assert (x_1010 == M.pow f 0xa % S.order); let x_1111 = S.qmul x_101 x_1010 in lemma_pow_mod_mul f 0x5 0xa; assert (x_1111 == M.pow f 0xf % S.order); let x_10101 = S.qmul (qsquare_times x_1010 1) f in qsquare_times_lemma x_1010 1; lemma_pow_pow_mod_mul f 0xa 0x2 0x1; assert (x_10101 == M.pow f 0x15 % S.order); let x_101010 = qsquare_times x_10101 1 in qsquare_times_lemma x_10101 1; lemma_pow_pow_mod f 0x15 0x2; assert (x_101010 == M.pow f 0x2a % S.order); let x_101111 = S.qmul x_101 x_101010 in lemma_pow_mod_mul f 0x5 0x2a; assert (x_101111 == M.pow f 0x2f % S.order); let x6 = S.qmul x_10101 x_101010 in lemma_pow_mod_mul f 0x15 0x2a; assert (x6 == M.pow f 0x3f % S.order); let x8 = S.qmul (qsquare_times x6 2) x_11 in qsquare_times_lemma x6 2; assert_norm (pow2 2 = 0x4); lemma_pow_pow_mod_mul f 0x3f 0x4 0x3; assert (x8 == M.pow f 0xff % S.order); let x16 = S.qmul (qsquare_times x8 8) x8 in qsquare_times_lemma x8 8; assert_norm (pow2 8 = 0x100); lemma_pow_pow_mod_mul f 0xff 0x100 0xff; assert (x16 == M.pow f 0xffff % S.order); let x32 = S.qmul (qsquare_times x16 16) x16 in qsquare_times_lemma x16 16; assert_norm (pow2 16 = 0x10000); lemma_pow_pow_mod_mul f 0xffff 0x10000 0xffff; assert (x32 == M.pow f 0xffffffff % S.order); let x96 = S.qmul (qsquare_times x32 64) x32 in qsquare_times_lemma x32 64; assert_norm (pow2 64 = 0x10000000000000000); lemma_pow_pow_mod_mul f 0xffffffff 0x10000000000000000 0xffffffff; assert (x96 == M.pow f 0xffffffff00000000ffffffff % S.order); let x128 = S.qmul (qsquare_times x96 32) x32 in qsquare_times_lemma x96 32; assert_norm (pow2 32 = 0x100000000); lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffff 0x100000000 0xffffffff; assert (x128 == M.pow f 0xffffffff00000000ffffffffffffffff % S.order); let x134 = S.qmul (qsquare_times x128 6) x_101111 in qsquare_times_lemma x128 6; assert_norm (pow2 6 = 0x40); lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffff 0x40 0x2f; assert (x134 == M.pow f 0x3fffffffc00000003fffffffffffffffef % S.order); let x139 = S.qmul (qsquare_times x134 5) x_111 in qsquare_times_lemma x134 5; assert_norm (pow2 5 = 0x20); lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef 0x20 0x7; assert (x139 == M.pow f 0x7fffffff800000007fffffffffffffffde7 % S.order); let x143 = S.qmul (qsquare_times x139 4) x_11 in qsquare_times_lemma x139 4; assert_norm (pow2 4 = 0x10); lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde7 0x10 0x3; assert (x143 == M.pow f 0x7fffffff800000007fffffffffffffffde73 % S.order); let x148 = S.qmul (qsquare_times x143 5) x_1111 in qsquare_times_lemma x143 5; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde73 0x20 0xf; assert (x148 == M.pow f 0xffffffff00000000ffffffffffffffffbce6f % S.order); let x153 = S.qmul (qsquare_times x148 5) x_10101 in qsquare_times_lemma x148 5; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6f 0x20 0x15; assert (x153 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf5 % S.order); let x157 = S.qmul (qsquare_times x153 4) x_101 in qsquare_times_lemma x153 4; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf5 0x10 0x5; assert (x157 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55 % S.order); let x160 = S.qmul (qsquare_times x157 3) x_101 in qsquare_times_lemma x157 3; assert_norm (pow2 3 = 0x8); lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55 0x8 0x5; assert (x160 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faad % S.order); let x163 = S.qmul (qsquare_times x160 3) x_101 in qsquare_times_lemma x160 3; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faad 0x8 0x5; assert (x163 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d % S.order); let x168 = S.qmul (qsquare_times x163 5) x_111 in qsquare_times_lemma x163 5; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d 0x20 0x7; assert (x168 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7 % S.order); let x177 = S.qmul (qsquare_times x168 9) x_101111 in qsquare_times_lemma x168 9; assert_norm (pow2 9 = 0x200); lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faada7 0x200 0x2f; assert (x177 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f % S.order); let x183 = S.qmul (qsquare_times x177 6) x_1111 in qsquare_times_lemma x177 6; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f 0x40 0xf; assert (x183 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d38bcf % S.order); let x185 = S.qmul (qsquare_times x183 2) f in qsquare_times_lemma x183 2; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d38bcf 0x4 0x1; assert (x185 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d % S.order); let x190 = S.qmul (qsquare_times x185 5) f in qsquare_times_lemma x185 5; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d 0x20 0x1; assert (x190 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a1 % S.order); let x196 = S.qmul (qsquare_times x190 6) x_1111 in qsquare_times_lemma x190 6; lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a1 0x40 0xf; assert (x196 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f % S.order); let x201 = S.qmul (qsquare_times x196 5) x_111 in qsquare_times_lemma x196 5; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f 0x20 0x7; assert (x201 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d09e7 % S.order); let x205 = S.qmul (qsquare_times x201 4) x_111 in qsquare_times_lemma x201 4; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d09e7 0x10 0x7; assert (x205 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d09e77 % S.order); let x210 = S.qmul (qsquare_times x205 5) x_111 in qsquare_times_lemma x205 5; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d09e77 0x20 0x7; assert (x210 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee7 % S.order); let x215 = S.qmul (qsquare_times x210 5) x_101 in qsquare_times_lemma x210 5; lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee7 0x20 0x5; assert (x215 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5 % S.order); let x218 = S.qmul (qsquare_times x215 3) x_11 in qsquare_times_lemma x215 3; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5 0x8 0x3; assert (x218 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b % S.order); let x228 = S.qmul (qsquare_times x218 10) x_101111 in qsquare_times_lemma x218 10; assert_norm (pow2 10 = 0x400); lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b 0x400 0x2f; assert (x228 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2f % S.order); let x230 = S.qmul (qsquare_times x228 2) x_11 in qsquare_times_lemma x228 2; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2f 0x4 0x3; assert (x230 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b0bf % S.order); let x235 = S.qmul (qsquare_times x230 5) x_11 in qsquare_times_lemma x230 5; lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b0bf 0x20 0x3; assert (x235 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e3 % S.order); let x240 = S.qmul (qsquare_times x235 5) x_11 in qsquare_times_lemma x235 5; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e3 0x20 0x3; assert (x240 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63 % S.order); let x243 = S.qmul (qsquare_times x240 3) f in qsquare_times_lemma x240 3; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63 0x8 0x1; assert (x243 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e319 % S.order); let x250 = S.qmul (qsquare_times x243 7) x_10101 in qsquare_times_lemma x243 7; assert_norm (pow2 7 = 0x80); lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e319 0x80 0x15; assert (x250 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b0bf18c95 % S.order); let x256 = S.qmul (qsquare_times x250 6) x_1111 in qsquare_times_lemma x250 6; lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b0bf18c95 0x40 0xf; assert (x256 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f % S.order); assert_norm (S.order - 2 = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f)
val qinv_lemma: f:S.qelem -> Lemma (qinv f == M.pow f (S.order - 2) % S.order) let qinv_lemma f =
false
null
true
let x_10 = qsquare_times f 1 in qsquare_times_lemma f 1; assert_norm (pow2 1 = 0x2); assert (x_10 == M.pow f 0x2 % S.order); let x_11 = S.qmul x_10 f in lemma_pow_mod_1 f; lemma_pow_mod_mul f 0x2 0x1; assert (x_11 == M.pow f 0x3 % S.order); let x_101 = S.qmul x_10 x_11 in lemma_pow_mod_mul f 0x2 0x3; assert (x_101 == M.pow f 0x5 % S.order); let x_111 = S.qmul x_10 x_101 in lemma_pow_mod_mul f 0x2 0x5; assert (x_111 == M.pow f 0x7 % S.order); let x_1010 = qsquare_times x_101 1 in qsquare_times_lemma x_101 1; assert_norm (pow2 1 = 2); lemma_pow_pow_mod f 0x5 0x2; assert (x_1010 == M.pow f 0xa % S.order); let x_1111 = S.qmul x_101 x_1010 in lemma_pow_mod_mul f 0x5 0xa; assert (x_1111 == M.pow f 0xf % S.order); let x_10101 = S.qmul (qsquare_times x_1010 1) f in qsquare_times_lemma x_1010 1; lemma_pow_pow_mod_mul f 0xa 0x2 0x1; assert (x_10101 == M.pow f 0x15 % S.order); let x_101010 = qsquare_times x_10101 1 in qsquare_times_lemma x_10101 1; lemma_pow_pow_mod f 0x15 0x2; assert (x_101010 == M.pow f 0x2a % S.order); let x_101111 = S.qmul x_101 x_101010 in lemma_pow_mod_mul f 0x5 0x2a; assert (x_101111 == M.pow f 0x2f % S.order); let x6 = S.qmul x_10101 x_101010 in lemma_pow_mod_mul f 0x15 0x2a; assert (x6 == M.pow f 0x3f % S.order); let x8 = S.qmul (qsquare_times x6 2) x_11 in qsquare_times_lemma x6 2; assert_norm (pow2 2 = 0x4); lemma_pow_pow_mod_mul f 0x3f 0x4 0x3; assert (x8 == M.pow f 0xff % S.order); let x16 = S.qmul (qsquare_times x8 8) x8 in qsquare_times_lemma x8 8; assert_norm (pow2 8 = 0x100); lemma_pow_pow_mod_mul f 0xff 0x100 0xff; assert (x16 == M.pow f 0xffff % S.order); let x32 = S.qmul (qsquare_times x16 16) x16 in qsquare_times_lemma x16 16; assert_norm (pow2 16 = 0x10000); lemma_pow_pow_mod_mul f 0xffff 0x10000 0xffff; assert (x32 == M.pow f 0xffffffff % S.order); let x96 = S.qmul (qsquare_times x32 64) x32 in qsquare_times_lemma x32 64; assert_norm (pow2 64 = 0x10000000000000000); lemma_pow_pow_mod_mul f 0xffffffff 0x10000000000000000 0xffffffff; assert (x96 == M.pow f 0xffffffff00000000ffffffff % S.order); let x128 = S.qmul (qsquare_times x96 32) x32 in qsquare_times_lemma x96 32; assert_norm (pow2 32 = 0x100000000); lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffff 0x100000000 0xffffffff; assert (x128 == M.pow f 0xffffffff00000000ffffffffffffffff % S.order); let x134 = S.qmul (qsquare_times x128 6) x_101111 in qsquare_times_lemma x128 6; assert_norm (pow2 6 = 0x40); lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffff 0x40 0x2f; assert (x134 == M.pow f 0x3fffffffc00000003fffffffffffffffef % S.order); let x139 = S.qmul (qsquare_times x134 5) x_111 in qsquare_times_lemma x134 5; assert_norm (pow2 5 = 0x20); lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef 0x20 0x7; assert (x139 == M.pow f 0x7fffffff800000007fffffffffffffffde7 % S.order); let x143 = S.qmul (qsquare_times x139 4) x_11 in qsquare_times_lemma x139 4; assert_norm (pow2 4 = 0x10); lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde7 0x10 0x3; assert (x143 == M.pow f 0x7fffffff800000007fffffffffffffffde73 % S.order); let x148 = S.qmul (qsquare_times x143 5) x_1111 in qsquare_times_lemma x143 5; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde73 0x20 0xf; assert (x148 == M.pow f 0xffffffff00000000ffffffffffffffffbce6f % S.order); let x153 = S.qmul (qsquare_times x148 5) x_10101 in qsquare_times_lemma x148 5; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6f 0x20 0x15; assert (x153 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf5 % S.order); let x157 = S.qmul (qsquare_times x153 4) x_101 in qsquare_times_lemma x153 4; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf5 0x10 0x5; assert (x157 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55 % S.order); let x160 = S.qmul (qsquare_times x157 3) x_101 in qsquare_times_lemma x157 3; assert_norm (pow2 3 = 0x8); lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55 0x8 0x5; assert (x160 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faad % S.order); let x163 = S.qmul (qsquare_times x160 3) x_101 in qsquare_times_lemma x160 3; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faad 0x8 0x5; assert (x163 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d % S.order); let x168 = S.qmul (qsquare_times x163 5) x_111 in qsquare_times_lemma x163 5; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d 0x20 0x7; assert (x168 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7 % S.order); let x177 = S.qmul (qsquare_times x168 9) x_101111 in qsquare_times_lemma x168 9; assert_norm (pow2 9 = 0x200); lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faada7 0x200 0x2f; assert (x177 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f % S.order); let x183 = S.qmul (qsquare_times x177 6) x_1111 in qsquare_times_lemma x177 6; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f 0x40 0xf; assert (x183 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d38bcf % S.order); let x185 = S.qmul (qsquare_times x183 2) f in qsquare_times_lemma x183 2; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d38bcf 0x4 0x1; assert (x185 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d % S.order); let x190 = S.qmul (qsquare_times x185 5) f in qsquare_times_lemma x185 5; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d 0x20 0x1; assert (x190 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a1 % S.order); let x196 = S.qmul (qsquare_times x190 6) x_1111 in qsquare_times_lemma x190 6; lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a1 0x40 0xf; assert (x196 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f % S.order); let x201 = S.qmul (qsquare_times x196 5) x_111 in qsquare_times_lemma x196 5; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f 0x20 0x7; assert (x201 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d09e7 % S.order); let x205 = S.qmul (qsquare_times x201 4) x_111 in qsquare_times_lemma x201 4; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d09e7 0x10 0x7; assert (x205 == M.pow f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d09e77 % S.order); let x210 = S.qmul (qsquare_times x205 5) x_111 in qsquare_times_lemma x205 5; lemma_pow_pow_mod_mul f 0x1fffffffe00000001ffffffffffffffff79cdf55b4e2f3d09e77 0x20 0x7; assert (x210 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee7 % S.order); let x215 = S.qmul (qsquare_times x210 5) x_101 in qsquare_times_lemma x210 5; lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee7 0x20 0x5; assert (x215 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5 % S.order); let x218 = S.qmul (qsquare_times x215 3) x_11 in qsquare_times_lemma x215 3; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5 0x8 0x3; assert (x218 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b % S.order); let x228 = S.qmul (qsquare_times x218 10) x_101111 in qsquare_times_lemma x218 10; assert_norm (pow2 10 = 0x400); lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b 0x400 0x2f; assert (x228 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2f % S.order); let x230 = S.qmul (qsquare_times x228 2) x_11 in qsquare_times_lemma x228 2; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2f 0x4 0x3; assert (x230 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b0bf % S.order); let x235 = S.qmul (qsquare_times x230 5) x_11 in qsquare_times_lemma x230 5; lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b0bf 0x20 0x3; assert (x235 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e3 % S.order); let x240 = S.qmul (qsquare_times x235 5) x_11 in qsquare_times_lemma x235 5; lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e3 0x20 0x3; assert (x240 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63 % S.order); let x243 = S.qmul (qsquare_times x240 3) f in qsquare_times_lemma x240 3; lemma_pow_pow_mod_mul f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63 0x8 0x1; assert (x243 == M.pow f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e319 % S.order); let x250 = S.qmul (qsquare_times x243 7) x_10101 in qsquare_times_lemma x243 7; assert_norm (pow2 7 = 0x80); lemma_pow_pow_mod_mul f 0x7fffffff800000007fffffffffffffffde737d56d38bcf4279dce5617e319 0x80 0x15; assert (x250 == M.pow f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b0bf18c95 % S.order); let x256 = S.qmul (qsquare_times x250 6) x_1111 in qsquare_times_lemma x250 6; lemma_pow_pow_mod_mul f 0x3fffffffc00000003fffffffffffffffef39beab69c5e7a13cee72b0bf18c95 0x40 0xf; assert (x256 == M.pow f 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f % S.order ); assert_norm (S.order - 2 = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f)
{ "checked_file": "Hacl.Spec.P256.Qinv.fst.checked", "dependencies": [ "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.NatMod.fsti.checked", "Lib.Exponentiation.fsti.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.P256.Qinv.fst" }
[ "lemma" ]
[ "Spec.P256.PointOps.qelem", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "Prims.op_Subtraction", "Spec.P256.PointOps.order", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.op_Modulus", "Lib.NatMod.pow", "Hacl.Spec.P256.Qinv.lemma_pow_pow_mod_mul", "Hacl.Spec.P256.Qinv.qsquare_times_lemma", "Spec.P256.PointOps.qmul", "Hacl.Spec.P256.Qinv.qsquare_times", "Prims.pow2", "Hacl.Spec.P256.Qinv.lemma_pow_mod_mul", "Hacl.Spec.P256.Qinv.lemma_pow_pow_mod", "Hacl.Spec.P256.Qinv.lemma_pow_mod_1" ]
[]
module Hacl.Spec.P256.Qinv open FStar.Mul module SE = Spec.Exponentiation module LE = Lib.Exponentiation module M = Lib.NatMod module S = Spec.P256 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let nat_mod_comm_monoid = M.mk_nat_mod_comm_monoid S.order let mk_to_nat_mod_comm_monoid : SE.to_comm_monoid S.qelem = { SE.a_spec = S.qelem; SE.comm_monoid = nat_mod_comm_monoid; SE.refl = (fun (x:S.qelem) -> x); } val one_mod : SE.one_st S.qelem mk_to_nat_mod_comm_monoid let one_mod _ = 1 val mul_mod : SE.mul_st S.qelem mk_to_nat_mod_comm_monoid let mul_mod x y = S.qmul x y val sqr_mod : SE.sqr_st S.qelem mk_to_nat_mod_comm_monoid let sqr_mod x = S.qmul x x let mk_nat_mod_concrete_ops : SE.concrete_ops S.qelem = { SE.to = mk_to_nat_mod_comm_monoid; SE.one = one_mod; SE.mul = mul_mod; SE.sqr = sqr_mod; } let qsquare_times (a:S.qelem) (b:nat) : S.qelem = SE.exp_pow2 mk_nat_mod_concrete_ops a b val qsquare_times_lemma: a:S.qelem -> b:nat -> Lemma (qsquare_times a b == M.pow a (pow2 b) % S.order) let qsquare_times_lemma a b = SE.exp_pow2_lemma mk_nat_mod_concrete_ops a b; LE.exp_pow2_lemma nat_mod_comm_monoid a b; assert (qsquare_times a b == LE.pow nat_mod_comm_monoid a (pow2 b)); M.lemma_pow_nat_mod_is_pow #S.order a (pow2 b) let qinv_x8_x128 (x6 x_11: S.qelem) : S.qelem = let x8 = S.qmul (qsquare_times x6 2) x_11 in let x16 = S.qmul (qsquare_times x8 8) x8 in let x32 = S.qmul (qsquare_times x16 16) x16 in let x96 = S.qmul (qsquare_times x32 64) x32 in let x128 = S.qmul (qsquare_times x96 32) x32 in x128 let qinv_x134_x153 (x128 x_11 x_111 x_1111 x_10101 x_101111: S.qelem) : S.qelem = let x134 = S.qmul (qsquare_times x128 6) x_101111 in let x139 = S.qmul (qsquare_times x134 5) x_111 in let x143 = S.qmul (qsquare_times x139 4) x_11 in let x148 = S.qmul (qsquare_times x143 5) x_1111 in let x153 = S.qmul (qsquare_times x148 5) x_10101 in x153 let qinv_x153_x177 (x153 x_101 x_111 x_101111: S.qelem) : S.qelem = let x157 = S.qmul (qsquare_times x153 4) x_101 in let x160 = S.qmul (qsquare_times x157 3) x_101 in let x163 = S.qmul (qsquare_times x160 3) x_101 in let x168 = S.qmul (qsquare_times x163 5) x_111 in let x177 = S.qmul (qsquare_times x168 9) x_101111 in x177 let qinv_x177_x210 (f x177 x_111 x_1111: S.qelem) : S.qelem = let x183 = S.qmul (qsquare_times x177 6) x_1111 in let x185 = S.qmul (qsquare_times x183 2) f in let x190 = S.qmul (qsquare_times x185 5) f in let x196 = S.qmul (qsquare_times x190 6) x_1111 in let x201 = S.qmul (qsquare_times x196 5) x_111 in let x205 = S.qmul (qsquare_times x201 4) x_111 in let x210 = S.qmul (qsquare_times x205 5) x_111 in x210 let qinv_x210_x240 (x210 x_11 x_101 x_101111: S.qelem) : S.qelem = let x215 = S.qmul (qsquare_times x210 5) x_101 in let x218 = S.qmul (qsquare_times x215 3) x_11 in let x228 = S.qmul (qsquare_times x218 10) x_101111 in let x230 = S.qmul (qsquare_times x228 2) x_11 in let x235 = S.qmul (qsquare_times x230 5) x_11 in let x240 = S.qmul (qsquare_times x235 5) x_11 in x240 let qinv_x240_x256 (f x240 x_1111 x_10101: S.qelem) : S.qelem = let x243 = S.qmul (qsquare_times x240 3) f in let x250 = S.qmul (qsquare_times x243 7) x_10101 in let x256 = S.qmul (qsquare_times x250 6) x_1111 in x256 let qinv_x8_x256 (f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111 : S.qelem) : S.qelem = let x128 = qinv_x8_x128 x6 x_11 in let x153 = qinv_x134_x153 x128 x_11 x_111 x_1111 x_10101 x_101111 in let x177 = qinv_x153_x177 x153 x_101 x_111 x_101111 in let x210 = qinv_x177_x210 f x177 x_111 x_1111 in let x240 = qinv_x210_x240 x210 x_11 x_101 x_101111 in let x256 = qinv_x240_x256 f x240 x_1111 x_10101 in x256 (** The algorithm is taken from https://briansmith.org/ecc-inversion-addition-chains-01 *) val qinv: f:S.qelem -> S.qelem let qinv f = let x_10 = qsquare_times f 1 in // x_10 is used 3x let x_11 = S.qmul x_10 f in let x_101 = S.qmul x_10 x_11 in let x_111 = S.qmul x_10 x_101 in let x_1010 = qsquare_times x_101 1 in // x_1010 is used 2x let x_1111 = S.qmul x_101 x_1010 in let x_10101 = S.qmul (qsquare_times x_1010 1) f in let x_101010 = qsquare_times x_10101 1 in // x_101010 is used 2x let x_101111 = S.qmul x_101 x_101010 in let x6 = S.qmul x_10101 x_101010 in qinv_x8_x256 f x6 x_11 x_101 x_111 x_1111 x_10101 x_101111 // TODO: mv to lib/ val lemma_pow_mod_1: f:S.qelem -> Lemma (f == M.pow f 1 % S.order) let lemma_pow_mod_1 f = M.lemma_pow1 f; Math.Lemmas.small_mod f S.order; assert_norm (pow2 0 = 1); assert (f == M.pow f 1 % S.order) val lemma_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> Lemma (S.qmul (M.pow f a % S.order) (M.pow f b % S.order) == M.pow f (a + b) % S.order) let lemma_pow_mod_mul f a b = calc (==) { S.qmul (M.pow f a % S.order) (M.pow f b % S.order); (==) { Math.Lemmas.lemma_mod_mul_distr_l (M.pow f a) (M.pow f b % S.order) S.order; Math.Lemmas.lemma_mod_mul_distr_r (M.pow f a) (M.pow f b) S.order } M.pow f a * M.pow f b % S.order; (==) { M.lemma_pow_add f a b } M.pow f (a + b) % S.order; } val lemma_pow_pow_mod: f:S.qelem -> a:nat -> b:nat -> Lemma (M.pow (M.pow f a % S.order) b % S.order == M.pow f (a * b) % S.order) let lemma_pow_pow_mod f a b = calc (==) { M.pow (M.pow f a % S.order) b % S.order; (==) { M.lemma_pow_mod_base (M.pow f a) b S.order } M.pow (M.pow f a) b % S.order; (==) { M.lemma_pow_mul f a b } M.pow f (a * b) % S.order; } val lemma_pow_pow_mod_mul: f:S.qelem -> a:nat -> b:nat -> c:nat -> Lemma (S.qmul (M.pow (M.pow f a % S.order) b % S.order) (M.pow f c % S.order) == M.pow f (a * b + c) % S.order) let lemma_pow_pow_mod_mul f a b c = calc (==) { S.qmul (M.pow (M.pow f a % S.order) b % S.order) (M.pow f c % S.order); (==) { lemma_pow_pow_mod f a b } S.qmul (M.pow f (a * b) % S.order) (M.pow f c % S.order); (==) { lemma_pow_mod_mul f (a * b) c } M.pow f (a * b + c) % S.order; } ////////////////////////////// // S.order - 2 = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f
false
false
Hacl.Spec.P256.Qinv.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 qinv_lemma: f:S.qelem -> Lemma (qinv f == M.pow f (S.order - 2) % S.order)
[]
Hacl.Spec.P256.Qinv.qinv_lemma
{ "file_name": "code/ecdsap256/Hacl.Spec.P256.Qinv.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Spec.P256.PointOps.qelem -> FStar.Pervasives.Lemma (ensures Hacl.Spec.P256.Qinv.qinv f == Lib.NatMod.pow f (Spec.P256.PointOps.order - 2) % Spec.P256.PointOps.order)
{ "end_col": 96, "end_line": 398, "start_col": 18, "start_line": 184 }
Prims.Tot
val get_bitfield16 (value: U16.t) (bitsFrom: U32.t{U32.v bitsFrom < 16}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i: U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)}
[ { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "LBF" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_bitfield16 (value:U16.t) (bitsFrom:U32.t{U32.v bitsFrom < 16}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i:U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint16.LBF.get_bitfield_gen value bitsFrom bitsTo
val get_bitfield16 (value: U16.t) (bitsFrom: U32.t{U32.v bitsFrom < 16}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i: U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)} let get_bitfield16 (value: U16.t) (bitsFrom: U32.t{U32.v bitsFrom < 16}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i: U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)} =
false
null
false
LBF.uint16.LBF.get_bitfield_gen value bitsFrom bitsTo
{ "checked_file": "EverParse3d.Prelude.StaticHeader.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.StaticHeader.fst" }
[ "total" ]
[ "FStar.UInt16.t", "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "LowParse.BitFields.__proj__Mkuint_t__item__get_bitfield_gen", "LowParse.BitFields.uint16", "FStar.UInt.size", "FStar.UInt16.v", "Prims.op_Subtraction" ]
[]
module EverParse3d.Prelude.StaticHeader module U64 = FStar.UInt64 module U32 = FStar.UInt32 module U16 = FStar.UInt16 module U8 = FStar.UInt8 module LBF = LowParse.BitFields //////////////////////////////////////////////////////////////////////////////// // Bit fields //////////////////////////////////////////////////////////////////////////////// // The get_bitfield operators are least significant bit first by default // following MSVC (https://learn.microsoft.com/en-us/cpp/c-language/c-bit-fields) let get_bitfield8 (value:U8.t) (bitsFrom:U32.t{U32.v bitsFrom < 8}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i:U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) = LBF.get_bitfield_eq_2 #8 (U8.v value) (U32.v bitsFrom) (U32.v bitsTo); (* NOTE: due to https://github.com/FStarLang/karamel/issues/102 I need to introduce explicit let-bindings here *) let op1 = value `U8.shift_left` (8ul `U32.sub` bitsTo) in let op2 = op1 `U8.shift_right` ((8ul `U32.sub` bitsTo) `U32.add` bitsFrom) in op2 let get_bitfield16 (value:U16.t) (bitsFrom:U32.t{U32.v bitsFrom < 16}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16})
false
false
EverParse3d.Prelude.StaticHeader.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_bitfield16 (value: U16.t) (bitsFrom: U32.t{U32.v bitsFrom < 16}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i: U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)}
[]
EverParse3d.Prelude.StaticHeader.get_bitfield16
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.StaticHeader.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
value: FStar.UInt16.t -> bitsFrom: FStar.UInt32.t{FStar.UInt32.v bitsFrom < 16} -> bitsTo: FStar.UInt32.t{FStar.UInt32.v bitsFrom < FStar.UInt32.v bitsTo /\ FStar.UInt32.v bitsTo <= 16} -> i: FStar.UInt16.t {FStar.UInt.size (FStar.UInt16.v i) (FStar.UInt32.v bitsTo - FStar.UInt32.v bitsFrom)}
{ "end_col": 58, "end_line": 30, "start_col": 5, "start_line": 30 }
Prims.Tot
val get_bitfield32 (value: U32.t) (bitsFrom: U32.t{U32.v bitsFrom < 32}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i: U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)}
[ { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "LBF" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_bitfield32 (value:U32.t) (bitsFrom:U32.t{U32.v bitsFrom < 32}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i:U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint32.LBF.get_bitfield_gen value bitsFrom bitsTo
val get_bitfield32 (value: U32.t) (bitsFrom: U32.t{U32.v bitsFrom < 32}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i: U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)} let get_bitfield32 (value: U32.t) (bitsFrom: U32.t{U32.v bitsFrom < 32}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i: U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)} =
false
null
false
LBF.uint32.LBF.get_bitfield_gen value bitsFrom bitsTo
{ "checked_file": "EverParse3d.Prelude.StaticHeader.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.StaticHeader.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "LowParse.BitFields.__proj__Mkuint_t__item__get_bitfield_gen", "LowParse.BitFields.uint32", "FStar.UInt.size", "Prims.op_Subtraction" ]
[]
module EverParse3d.Prelude.StaticHeader module U64 = FStar.UInt64 module U32 = FStar.UInt32 module U16 = FStar.UInt16 module U8 = FStar.UInt8 module LBF = LowParse.BitFields //////////////////////////////////////////////////////////////////////////////// // Bit fields //////////////////////////////////////////////////////////////////////////////// // The get_bitfield operators are least significant bit first by default // following MSVC (https://learn.microsoft.com/en-us/cpp/c-language/c-bit-fields) let get_bitfield8 (value:U8.t) (bitsFrom:U32.t{U32.v bitsFrom < 8}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i:U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) = LBF.get_bitfield_eq_2 #8 (U8.v value) (U32.v bitsFrom) (U32.v bitsTo); (* NOTE: due to https://github.com/FStarLang/karamel/issues/102 I need to introduce explicit let-bindings here *) let op1 = value `U8.shift_left` (8ul `U32.sub` bitsTo) in let op2 = op1 `U8.shift_right` ((8ul `U32.sub` bitsTo) `U32.add` bitsFrom) in op2 let get_bitfield16 (value:U16.t) (bitsFrom:U32.t{U32.v bitsFrom < 16}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i:U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint16.LBF.get_bitfield_gen value bitsFrom bitsTo let get_bitfield32 (value:U32.t) (bitsFrom:U32.t{U32.v bitsFrom < 32}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32})
false
false
EverParse3d.Prelude.StaticHeader.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_bitfield32 (value: U32.t) (bitsFrom: U32.t{U32.v bitsFrom < 32}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i: U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)}
[]
EverParse3d.Prelude.StaticHeader.get_bitfield32
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.StaticHeader.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
value: FStar.UInt32.t -> bitsFrom: FStar.UInt32.t{FStar.UInt32.v bitsFrom < 32} -> bitsTo: FStar.UInt32.t{FStar.UInt32.v bitsFrom < FStar.UInt32.v bitsTo /\ FStar.UInt32.v bitsTo <= 32} -> i: FStar.UInt32.t {FStar.UInt.size (FStar.UInt32.v i) (FStar.UInt32.v bitsTo - FStar.UInt32.v bitsFrom)}
{ "end_col": 58, "end_line": 36, "start_col": 5, "start_line": 36 }
Prims.Tot
val get_bitfield64 (value: U64.t) (bitsFrom: U32.t{U32.v bitsFrom < 64}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64}) : i: U64.t{FStar.UInt.size (U64.v i) (U32.v bitsTo - U32.v bitsFrom)}
[ { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "LBF" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_bitfield64 (value:U64.t) (bitsFrom:U32.t{U32.v bitsFrom < 64}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64}) : i:U64.t{FStar.UInt.size (U64.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint64.LBF.get_bitfield_gen value bitsFrom bitsTo
val get_bitfield64 (value: U64.t) (bitsFrom: U32.t{U32.v bitsFrom < 64}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64}) : i: U64.t{FStar.UInt.size (U64.v i) (U32.v bitsTo - U32.v bitsFrom)} let get_bitfield64 (value: U64.t) (bitsFrom: U32.t{U32.v bitsFrom < 64}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64}) : i: U64.t{FStar.UInt.size (U64.v i) (U32.v bitsTo - U32.v bitsFrom)} =
false
null
false
LBF.uint64.LBF.get_bitfield_gen value bitsFrom bitsTo
{ "checked_file": "EverParse3d.Prelude.StaticHeader.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.StaticHeader.fst" }
[ "total" ]
[ "FStar.UInt64.t", "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "LowParse.BitFields.__proj__Mkuint_t__item__get_bitfield_gen", "LowParse.BitFields.uint64", "FStar.UInt.size", "FStar.UInt64.v", "Prims.op_Subtraction" ]
[]
module EverParse3d.Prelude.StaticHeader module U64 = FStar.UInt64 module U32 = FStar.UInt32 module U16 = FStar.UInt16 module U8 = FStar.UInt8 module LBF = LowParse.BitFields //////////////////////////////////////////////////////////////////////////////// // Bit fields //////////////////////////////////////////////////////////////////////////////// // The get_bitfield operators are least significant bit first by default // following MSVC (https://learn.microsoft.com/en-us/cpp/c-language/c-bit-fields) let get_bitfield8 (value:U8.t) (bitsFrom:U32.t{U32.v bitsFrom < 8}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i:U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) = LBF.get_bitfield_eq_2 #8 (U8.v value) (U32.v bitsFrom) (U32.v bitsTo); (* NOTE: due to https://github.com/FStarLang/karamel/issues/102 I need to introduce explicit let-bindings here *) let op1 = value `U8.shift_left` (8ul `U32.sub` bitsTo) in let op2 = op1 `U8.shift_right` ((8ul `U32.sub` bitsTo) `U32.add` bitsFrom) in op2 let get_bitfield16 (value:U16.t) (bitsFrom:U32.t{U32.v bitsFrom < 16}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i:U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint16.LBF.get_bitfield_gen value bitsFrom bitsTo let get_bitfield32 (value:U32.t) (bitsFrom:U32.t{U32.v bitsFrom < 32}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i:U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint32.LBF.get_bitfield_gen value bitsFrom bitsTo let get_bitfield64 (value:U64.t) (bitsFrom:U32.t{U32.v bitsFrom < 64}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64})
false
false
EverParse3d.Prelude.StaticHeader.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_bitfield64 (value: U64.t) (bitsFrom: U32.t{U32.v bitsFrom < 64}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64}) : i: U64.t{FStar.UInt.size (U64.v i) (U32.v bitsTo - U32.v bitsFrom)}
[]
EverParse3d.Prelude.StaticHeader.get_bitfield64
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.StaticHeader.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
value: FStar.UInt64.t -> bitsFrom: FStar.UInt32.t{FStar.UInt32.v bitsFrom < 64} -> bitsTo: FStar.UInt32.t{FStar.UInt32.v bitsFrom < FStar.UInt32.v bitsTo /\ FStar.UInt32.v bitsTo <= 64} -> i: FStar.UInt64.t {FStar.UInt.size (FStar.UInt64.v i) (FStar.UInt32.v bitsTo - FStar.UInt32.v bitsFrom)}
{ "end_col": 58, "end_line": 42, "start_col": 5, "start_line": 42 }
Prims.Tot
val get_bitfield16_msb_first (value: U16.t) (bitsFrom: U32.t{U32.v bitsFrom < 16}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i: U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)}
[ { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "LBF" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_bitfield16_msb_first (value:U16.t) (bitsFrom:U32.t{U32.v bitsFrom < 16}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i:U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)} = get_bitfield16 value (16ul `U32.sub` bitsTo) (16ul `U32.sub` bitsFrom)
val get_bitfield16_msb_first (value: U16.t) (bitsFrom: U32.t{U32.v bitsFrom < 16}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i: U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)} let get_bitfield16_msb_first (value: U16.t) (bitsFrom: U32.t{U32.v bitsFrom < 16}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i: U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)} =
false
null
false
get_bitfield16 value (16ul `U32.sub` bitsTo) (16ul `U32.sub` bitsFrom)
{ "checked_file": "EverParse3d.Prelude.StaticHeader.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.StaticHeader.fst" }
[ "total" ]
[ "FStar.UInt16.t", "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "EverParse3d.Prelude.StaticHeader.get_bitfield16", "FStar.UInt32.sub", "FStar.UInt32.__uint_to_t", "FStar.UInt.size", "FStar.UInt16.v", "Prims.op_Subtraction" ]
[]
module EverParse3d.Prelude.StaticHeader module U64 = FStar.UInt64 module U32 = FStar.UInt32 module U16 = FStar.UInt16 module U8 = FStar.UInt8 module LBF = LowParse.BitFields //////////////////////////////////////////////////////////////////////////////// // Bit fields //////////////////////////////////////////////////////////////////////////////// // The get_bitfield operators are least significant bit first by default // following MSVC (https://learn.microsoft.com/en-us/cpp/c-language/c-bit-fields) let get_bitfield8 (value:U8.t) (bitsFrom:U32.t{U32.v bitsFrom < 8}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i:U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) = LBF.get_bitfield_eq_2 #8 (U8.v value) (U32.v bitsFrom) (U32.v bitsTo); (* NOTE: due to https://github.com/FStarLang/karamel/issues/102 I need to introduce explicit let-bindings here *) let op1 = value `U8.shift_left` (8ul `U32.sub` bitsTo) in let op2 = op1 `U8.shift_right` ((8ul `U32.sub` bitsTo) `U32.add` bitsFrom) in op2 let get_bitfield16 (value:U16.t) (bitsFrom:U32.t{U32.v bitsFrom < 16}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i:U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint16.LBF.get_bitfield_gen value bitsFrom bitsTo let get_bitfield32 (value:U32.t) (bitsFrom:U32.t{U32.v bitsFrom < 32}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i:U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint32.LBF.get_bitfield_gen value bitsFrom bitsTo let get_bitfield64 (value:U64.t) (bitsFrom:U32.t{U32.v bitsFrom < 64}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64}) : i:U64.t{FStar.UInt.size (U64.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint64.LBF.get_bitfield_gen value bitsFrom bitsTo // Most significant bit first variants: let get_bitfield8_msb_first (value:U8.t) (bitsFrom:U32.t{U32.v bitsFrom < 8}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i:U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) = get_bitfield8 value (8ul `U32.sub` bitsTo) (8ul `U32.sub` bitsFrom) let get_bitfield16_msb_first (value:U16.t) (bitsFrom:U32.t{U32.v bitsFrom < 16}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16})
false
false
EverParse3d.Prelude.StaticHeader.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_bitfield16_msb_first (value: U16.t) (bitsFrom: U32.t{U32.v bitsFrom < 16}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i: U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)}
[]
EverParse3d.Prelude.StaticHeader.get_bitfield16_msb_first
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.StaticHeader.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
value: FStar.UInt16.t -> bitsFrom: FStar.UInt32.t{FStar.UInt32.v bitsFrom < 16} -> bitsTo: FStar.UInt32.t{FStar.UInt32.v bitsFrom < FStar.UInt32.v bitsTo /\ FStar.UInt32.v bitsTo <= 16} -> i: FStar.UInt16.t {FStar.UInt.size (FStar.UInt16.v i) (FStar.UInt32.v bitsTo - FStar.UInt32.v bitsFrom)}
{ "end_col": 75, "end_line": 57, "start_col": 5, "start_line": 57 }
Prims.Tot
val get_bitfield64_msb_first (value: U64.t) (bitsFrom: U32.t{U32.v bitsFrom < 64}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64}) : i: U64.t{FStar.UInt.size (U64.v i) (U32.v bitsTo - U32.v bitsFrom)}
[ { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "LBF" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_bitfield64_msb_first (value:U64.t) (bitsFrom:U32.t{U32.v bitsFrom < 64}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64}) : i:U64.t{FStar.UInt.size (U64.v i) (U32.v bitsTo - U32.v bitsFrom)} = get_bitfield64 value (64ul `U32.sub` bitsTo) (64ul `U32.sub` bitsFrom)
val get_bitfield64_msb_first (value: U64.t) (bitsFrom: U32.t{U32.v bitsFrom < 64}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64}) : i: U64.t{FStar.UInt.size (U64.v i) (U32.v bitsTo - U32.v bitsFrom)} let get_bitfield64_msb_first (value: U64.t) (bitsFrom: U32.t{U32.v bitsFrom < 64}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64}) : i: U64.t{FStar.UInt.size (U64.v i) (U32.v bitsTo - U32.v bitsFrom)} =
false
null
false
get_bitfield64 value (64ul `U32.sub` bitsTo) (64ul `U32.sub` bitsFrom)
{ "checked_file": "EverParse3d.Prelude.StaticHeader.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.StaticHeader.fst" }
[ "total" ]
[ "FStar.UInt64.t", "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "EverParse3d.Prelude.StaticHeader.get_bitfield64", "FStar.UInt32.sub", "FStar.UInt32.__uint_to_t", "FStar.UInt.size", "FStar.UInt64.v", "Prims.op_Subtraction" ]
[]
module EverParse3d.Prelude.StaticHeader module U64 = FStar.UInt64 module U32 = FStar.UInt32 module U16 = FStar.UInt16 module U8 = FStar.UInt8 module LBF = LowParse.BitFields //////////////////////////////////////////////////////////////////////////////// // Bit fields //////////////////////////////////////////////////////////////////////////////// // The get_bitfield operators are least significant bit first by default // following MSVC (https://learn.microsoft.com/en-us/cpp/c-language/c-bit-fields) let get_bitfield8 (value:U8.t) (bitsFrom:U32.t{U32.v bitsFrom < 8}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i:U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) = LBF.get_bitfield_eq_2 #8 (U8.v value) (U32.v bitsFrom) (U32.v bitsTo); (* NOTE: due to https://github.com/FStarLang/karamel/issues/102 I need to introduce explicit let-bindings here *) let op1 = value `U8.shift_left` (8ul `U32.sub` bitsTo) in let op2 = op1 `U8.shift_right` ((8ul `U32.sub` bitsTo) `U32.add` bitsFrom) in op2 let get_bitfield16 (value:U16.t) (bitsFrom:U32.t{U32.v bitsFrom < 16}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i:U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint16.LBF.get_bitfield_gen value bitsFrom bitsTo let get_bitfield32 (value:U32.t) (bitsFrom:U32.t{U32.v bitsFrom < 32}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i:U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint32.LBF.get_bitfield_gen value bitsFrom bitsTo let get_bitfield64 (value:U64.t) (bitsFrom:U32.t{U32.v bitsFrom < 64}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64}) : i:U64.t{FStar.UInt.size (U64.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint64.LBF.get_bitfield_gen value bitsFrom bitsTo // Most significant bit first variants: let get_bitfield8_msb_first (value:U8.t) (bitsFrom:U32.t{U32.v bitsFrom < 8}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i:U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) = get_bitfield8 value (8ul `U32.sub` bitsTo) (8ul `U32.sub` bitsFrom) let get_bitfield16_msb_first (value:U16.t) (bitsFrom:U32.t{U32.v bitsFrom < 16}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i:U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)} = get_bitfield16 value (16ul `U32.sub` bitsTo) (16ul `U32.sub` bitsFrom) let get_bitfield32_msb_first (value:U32.t) (bitsFrom:U32.t{U32.v bitsFrom < 32}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i:U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)} = get_bitfield32 value (32ul `U32.sub` bitsTo) (32ul `U32.sub` bitsFrom) let get_bitfield64_msb_first (value:U64.t) (bitsFrom:U32.t{U32.v bitsFrom < 64}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64})
false
false
EverParse3d.Prelude.StaticHeader.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_bitfield64_msb_first (value: U64.t) (bitsFrom: U32.t{U32.v bitsFrom < 64}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64}) : i: U64.t{FStar.UInt.size (U64.v i) (U32.v bitsTo - U32.v bitsFrom)}
[]
EverParse3d.Prelude.StaticHeader.get_bitfield64_msb_first
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.StaticHeader.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
value: FStar.UInt64.t -> bitsFrom: FStar.UInt32.t{FStar.UInt32.v bitsFrom < 64} -> bitsTo: FStar.UInt32.t{FStar.UInt32.v bitsFrom < FStar.UInt32.v bitsTo /\ FStar.UInt32.v bitsTo <= 64} -> i: FStar.UInt64.t {FStar.UInt.size (FStar.UInt64.v i) (FStar.UInt32.v bitsTo - FStar.UInt32.v bitsFrom)}
{ "end_col": 75, "end_line": 69, "start_col": 5, "start_line": 69 }
Prims.Tot
val get_bitfield8_msb_first (value: U8.t) (bitsFrom: U32.t{U32.v bitsFrom < 8}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i: U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)})
[ { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "LBF" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_bitfield8_msb_first (value:U8.t) (bitsFrom:U32.t{U32.v bitsFrom < 8}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i:U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) = get_bitfield8 value (8ul `U32.sub` bitsTo) (8ul `U32.sub` bitsFrom)
val get_bitfield8_msb_first (value: U8.t) (bitsFrom: U32.t{U32.v bitsFrom < 8}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i: U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) let get_bitfield8_msb_first (value: U8.t) (bitsFrom: U32.t{U32.v bitsFrom < 8}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i: U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) =
false
null
false
get_bitfield8 value (8ul `U32.sub` bitsTo) (8ul `U32.sub` bitsFrom)
{ "checked_file": "EverParse3d.Prelude.StaticHeader.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.StaticHeader.fst" }
[ "total" ]
[ "FStar.UInt8.t", "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "EverParse3d.Prelude.StaticHeader.get_bitfield8", "FStar.UInt32.sub", "FStar.UInt32.__uint_to_t", "FStar.UInt.size", "FStar.UInt8.v", "Prims.op_Subtraction" ]
[]
module EverParse3d.Prelude.StaticHeader module U64 = FStar.UInt64 module U32 = FStar.UInt32 module U16 = FStar.UInt16 module U8 = FStar.UInt8 module LBF = LowParse.BitFields //////////////////////////////////////////////////////////////////////////////// // Bit fields //////////////////////////////////////////////////////////////////////////////// // The get_bitfield operators are least significant bit first by default // following MSVC (https://learn.microsoft.com/en-us/cpp/c-language/c-bit-fields) let get_bitfield8 (value:U8.t) (bitsFrom:U32.t{U32.v bitsFrom < 8}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i:U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) = LBF.get_bitfield_eq_2 #8 (U8.v value) (U32.v bitsFrom) (U32.v bitsTo); (* NOTE: due to https://github.com/FStarLang/karamel/issues/102 I need to introduce explicit let-bindings here *) let op1 = value `U8.shift_left` (8ul `U32.sub` bitsTo) in let op2 = op1 `U8.shift_right` ((8ul `U32.sub` bitsTo) `U32.add` bitsFrom) in op2 let get_bitfield16 (value:U16.t) (bitsFrom:U32.t{U32.v bitsFrom < 16}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i:U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint16.LBF.get_bitfield_gen value bitsFrom bitsTo let get_bitfield32 (value:U32.t) (bitsFrom:U32.t{U32.v bitsFrom < 32}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i:U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint32.LBF.get_bitfield_gen value bitsFrom bitsTo let get_bitfield64 (value:U64.t) (bitsFrom:U32.t{U32.v bitsFrom < 64}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64}) : i:U64.t{FStar.UInt.size (U64.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint64.LBF.get_bitfield_gen value bitsFrom bitsTo // Most significant bit first variants: let get_bitfield8_msb_first (value:U8.t) (bitsFrom:U32.t{U32.v bitsFrom < 8}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8})
false
false
EverParse3d.Prelude.StaticHeader.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_bitfield8_msb_first (value: U8.t) (bitsFrom: U32.t{U32.v bitsFrom < 8}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i: U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)})
[]
EverParse3d.Prelude.StaticHeader.get_bitfield8_msb_first
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.StaticHeader.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
value: FStar.UInt8.t -> bitsFrom: FStar.UInt32.t{FStar.UInt32.v bitsFrom < 8} -> bitsTo: FStar.UInt32.t{FStar.UInt32.v bitsFrom < FStar.UInt32.v bitsTo /\ FStar.UInt32.v bitsTo <= 8} -> i: FStar.UInt8.t {FStar.UInt.size (FStar.UInt8.v i) (FStar.UInt32.v bitsTo - FStar.UInt32.v bitsFrom)}
{ "end_col": 69, "end_line": 51, "start_col": 2, "start_line": 51 }
Prims.Tot
val get_bitfield8 (value: U8.t) (bitsFrom: U32.t{U32.v bitsFrom < 8}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i: U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)})
[ { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "LBF" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_bitfield8 (value:U8.t) (bitsFrom:U32.t{U32.v bitsFrom < 8}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i:U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) = LBF.get_bitfield_eq_2 #8 (U8.v value) (U32.v bitsFrom) (U32.v bitsTo); (* NOTE: due to https://github.com/FStarLang/karamel/issues/102 I need to introduce explicit let-bindings here *) let op1 = value `U8.shift_left` (8ul `U32.sub` bitsTo) in let op2 = op1 `U8.shift_right` ((8ul `U32.sub` bitsTo) `U32.add` bitsFrom) in op2
val get_bitfield8 (value: U8.t) (bitsFrom: U32.t{U32.v bitsFrom < 8}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i: U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) let get_bitfield8 (value: U8.t) (bitsFrom: U32.t{U32.v bitsFrom < 8}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i: U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) =
false
null
false
LBF.get_bitfield_eq_2 #8 (U8.v value) (U32.v bitsFrom) (U32.v bitsTo); let op1 = value `U8.shift_left` (8ul `U32.sub` bitsTo) in let op2 = op1 `U8.shift_right` ((8ul `U32.sub` bitsTo) `U32.add` bitsFrom) in op2
{ "checked_file": "EverParse3d.Prelude.StaticHeader.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.StaticHeader.fst" }
[ "total" ]
[ "FStar.UInt8.t", "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "FStar.UInt8.shift_right", "FStar.UInt32.add", "FStar.UInt32.sub", "FStar.UInt32.__uint_to_t", "FStar.UInt8.shift_left", "Prims.unit", "LowParse.BitFields.get_bitfield_eq_2", "FStar.UInt8.v", "FStar.UInt.size", "Prims.op_Subtraction" ]
[]
module EverParse3d.Prelude.StaticHeader module U64 = FStar.UInt64 module U32 = FStar.UInt32 module U16 = FStar.UInt16 module U8 = FStar.UInt8 module LBF = LowParse.BitFields //////////////////////////////////////////////////////////////////////////////// // Bit fields //////////////////////////////////////////////////////////////////////////////// // The get_bitfield operators are least significant bit first by default // following MSVC (https://learn.microsoft.com/en-us/cpp/c-language/c-bit-fields) let get_bitfield8 (value:U8.t) (bitsFrom:U32.t{U32.v bitsFrom < 8}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8})
false
false
EverParse3d.Prelude.StaticHeader.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_bitfield8 (value: U8.t) (bitsFrom: U32.t{U32.v bitsFrom < 8}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i: U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)})
[]
EverParse3d.Prelude.StaticHeader.get_bitfield8
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.StaticHeader.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
value: FStar.UInt8.t -> bitsFrom: FStar.UInt32.t{FStar.UInt32.v bitsFrom < 8} -> bitsTo: FStar.UInt32.t{FStar.UInt32.v bitsFrom < FStar.UInt32.v bitsTo /\ FStar.UInt32.v bitsTo <= 8} -> i: FStar.UInt8.t {FStar.UInt.size (FStar.UInt8.v i) (FStar.UInt32.v bitsTo - FStar.UInt32.v bitsFrom)}
{ "end_col": 5, "end_line": 24, "start_col": 2, "start_line": 20 }
Prims.Tot
val get_bitfield32_msb_first (value: U32.t) (bitsFrom: U32.t{U32.v bitsFrom < 32}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i: U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)}
[ { "abbrev": true, "full_module": "LowParse.BitFields", "short_module": "LBF" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "EverParse3d.Prelude", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_bitfield32_msb_first (value:U32.t) (bitsFrom:U32.t{U32.v bitsFrom < 32}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i:U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)} = get_bitfield32 value (32ul `U32.sub` bitsTo) (32ul `U32.sub` bitsFrom)
val get_bitfield32_msb_first (value: U32.t) (bitsFrom: U32.t{U32.v bitsFrom < 32}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i: U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)} let get_bitfield32_msb_first (value: U32.t) (bitsFrom: U32.t{U32.v bitsFrom < 32}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i: U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)} =
false
null
false
get_bitfield32 value (32ul `U32.sub` bitsTo) (32ul `U32.sub` bitsFrom)
{ "checked_file": "EverParse3d.Prelude.StaticHeader.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.BitFields.fsti.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "EverParse3d.Prelude.StaticHeader.fst" }
[ "total" ]
[ "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Prims.l_and", "Prims.op_LessThanOrEqual", "EverParse3d.Prelude.StaticHeader.get_bitfield32", "FStar.UInt32.sub", "FStar.UInt32.__uint_to_t", "FStar.UInt.size", "Prims.op_Subtraction" ]
[]
module EverParse3d.Prelude.StaticHeader module U64 = FStar.UInt64 module U32 = FStar.UInt32 module U16 = FStar.UInt16 module U8 = FStar.UInt8 module LBF = LowParse.BitFields //////////////////////////////////////////////////////////////////////////////// // Bit fields //////////////////////////////////////////////////////////////////////////////// // The get_bitfield operators are least significant bit first by default // following MSVC (https://learn.microsoft.com/en-us/cpp/c-language/c-bit-fields) let get_bitfield8 (value:U8.t) (bitsFrom:U32.t{U32.v bitsFrom < 8}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i:U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) = LBF.get_bitfield_eq_2 #8 (U8.v value) (U32.v bitsFrom) (U32.v bitsTo); (* NOTE: due to https://github.com/FStarLang/karamel/issues/102 I need to introduce explicit let-bindings here *) let op1 = value `U8.shift_left` (8ul `U32.sub` bitsTo) in let op2 = op1 `U8.shift_right` ((8ul `U32.sub` bitsTo) `U32.add` bitsFrom) in op2 let get_bitfield16 (value:U16.t) (bitsFrom:U32.t{U32.v bitsFrom < 16}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i:U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint16.LBF.get_bitfield_gen value bitsFrom bitsTo let get_bitfield32 (value:U32.t) (bitsFrom:U32.t{U32.v bitsFrom < 32}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i:U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint32.LBF.get_bitfield_gen value bitsFrom bitsTo let get_bitfield64 (value:U64.t) (bitsFrom:U32.t{U32.v bitsFrom < 64}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 64}) : i:U64.t{FStar.UInt.size (U64.v i) (U32.v bitsTo - U32.v bitsFrom)} = LBF.uint64.LBF.get_bitfield_gen value bitsFrom bitsTo // Most significant bit first variants: let get_bitfield8_msb_first (value:U8.t) (bitsFrom:U32.t{U32.v bitsFrom < 8}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 8}) : Tot (i:U8.t{FStar.UInt.size (U8.v i) (U32.v bitsTo - U32.v bitsFrom)}) = get_bitfield8 value (8ul `U32.sub` bitsTo) (8ul `U32.sub` bitsFrom) let get_bitfield16_msb_first (value:U16.t) (bitsFrom:U32.t{U32.v bitsFrom < 16}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 16}) : i:U16.t{FStar.UInt.size (U16.v i) (U32.v bitsTo - U32.v bitsFrom)} = get_bitfield16 value (16ul `U32.sub` bitsTo) (16ul `U32.sub` bitsFrom) let get_bitfield32_msb_first (value:U32.t) (bitsFrom:U32.t{U32.v bitsFrom < 32}) (bitsTo:U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32})
false
false
EverParse3d.Prelude.StaticHeader.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 2, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [ "smt.qi.eager_threshold=10" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_bitfield32_msb_first (value: U32.t) (bitsFrom: U32.t{U32.v bitsFrom < 32}) (bitsTo: U32.t{U32.v bitsFrom < U32.v bitsTo /\ U32.v bitsTo <= 32}) : i: U32.t{FStar.UInt.size (U32.v i) (U32.v bitsTo - U32.v bitsFrom)}
[]
EverParse3d.Prelude.StaticHeader.get_bitfield32_msb_first
{ "file_name": "src/3d/prelude/EverParse3d.Prelude.StaticHeader.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
value: FStar.UInt32.t -> bitsFrom: FStar.UInt32.t{FStar.UInt32.v bitsFrom < 32} -> bitsTo: FStar.UInt32.t{FStar.UInt32.v bitsFrom < FStar.UInt32.v bitsTo /\ FStar.UInt32.v bitsTo <= 32} -> i: FStar.UInt32.t {FStar.UInt.size (FStar.UInt32.v i) (FStar.UInt32.v bitsTo - FStar.UInt32.v bitsFrom)}
{ "end_col": 75, "end_line": 63, "start_col": 5, "start_line": 63 }
FStar.HyperStack.ST.Stack
val crypto_kem_dec_kp_s_cond: a:FP.frodo_alg -> bp_matrix:matrix_t params_nbar (params_n a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> cp_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h bp_matrix /\ live h bpp_matrix /\ live h c_matrix /\ live h cp_matrix) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix) (as_matrix h0 c_matrix) (as_matrix h0 cp_matrix))
[ { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Frodo.KEM.KeyGen", "short_module": "KG" }, { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Frodo.Random", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Sample", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Pack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Encode", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix = let b1 = matrix_eq bp_matrix bpp_matrix in let b2 = matrix_eq c_matrix cp_matrix in b1 &. b2
val crypto_kem_dec_kp_s_cond: a:FP.frodo_alg -> bp_matrix:matrix_t params_nbar (params_n a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> cp_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h bp_matrix /\ live h bpp_matrix /\ live h c_matrix /\ live h cp_matrix) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix) (as_matrix h0 c_matrix) (as_matrix h0 cp_matrix)) let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix =
true
null
false
let b1 = matrix_eq bp_matrix bpp_matrix in let b2 = matrix_eq c_matrix cp_matrix in b1 &. b2
{ "checked_file": "Hacl.Impl.Frodo.KEM.Decaps.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Sample.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "Hacl.Impl.Frodo.Pack.fst.checked", "Hacl.Impl.Frodo.KEM.KeyGen.fst.checked", "Hacl.Impl.Frodo.KEM.Encaps.fst.checked", "Hacl.Impl.Frodo.KEM.fst.checked", "Hacl.Impl.Frodo.Encode.fst.checked", "Hacl.Frodo.Random.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst" }
[]
[ "Spec.Frodo.Params.frodo_alg", "Hacl.Impl.Matrix.matrix_t", "Hacl.Impl.Frodo.Params.params_nbar", "Hacl.Impl.Frodo.Params.params_n", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Lib.IntTypes.uint16", "Lib.IntTypes.int_t", "Hacl.Impl.Matrix.matrix_eq" ]
[]
module Hacl.Impl.Frodo.KEM.Decaps open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params open Hacl.Impl.Frodo.KEM open Hacl.Impl.Frodo.KEM.Encaps open Hacl.Impl.Frodo.Encode open Hacl.Impl.Frodo.Pack open Hacl.Impl.Frodo.Sample open Hacl.Frodo.Random module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module FP = Spec.Frodo.Params module KG = Hacl.Impl.Frodo.KEM.KeyGen module S = Spec.Frodo.KEM.Decaps module M = Spec.Matrix #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" inline_for_extraction noextract val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct)) let get_bp_c_matrices a ct bp_matrix c_matrix = let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix inline_for_extraction noextract val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode = push_frame(); let s_matrix = matrix_create (params_n a) params_nbar in let m_matrix = matrix_create params_nbar params_nbar in matrix_from_lbytes s_bytes s_matrix; matrix_mul_s bp_matrix s_matrix m_matrix; matrix_sub c_matrix m_matrix; frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode; clear_matrix s_matrix; clear_matrix m_matrix; pop_frame() inline_for_extraction noextract val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix)) let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix = FP.expand_crypto_secretkeybytes a; FP.expand_crypto_publickeybytes a; let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in let seed_a = sub pk 0ul bytes_seed_a in let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix; frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix; mod_pow2 (params_logq a) bpp_matrix; mod_pow2 (params_logq a) cp_matrix #push-options "--z3rlimit 150" inline_for_extraction noextract val get_bpp_cp_matrices: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h seed_se /\ live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk)) let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix = push_frame (); let sp_matrix = matrix_create params_nbar (params_n a) in let ep_matrix = matrix_create params_nbar (params_n a) in let epp_matrix = matrix_create params_nbar params_nbar in get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix; get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix; clear_matrix3 a sp_matrix ep_matrix epp_matrix; pop_frame () #pop-options inline_for_extraction noextract val crypto_kem_dec_kp_s_cond: a:FP.frodo_alg -> bp_matrix:matrix_t params_nbar (params_n a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> cp_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h bp_matrix /\ live h bpp_matrix /\ live h c_matrix /\ live h cp_matrix) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix) (as_matrix h0 c_matrix) (as_matrix h0 cp_matrix))
false
false
Hacl.Impl.Frodo.KEM.Decaps.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crypto_kem_dec_kp_s_cond: a:FP.frodo_alg -> bp_matrix:matrix_t params_nbar (params_n a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> cp_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h bp_matrix /\ live h bpp_matrix /\ live h c_matrix /\ live h cp_matrix) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix) (as_matrix h0 c_matrix) (as_matrix h0 cp_matrix))
[]
Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_kp_s_cond
{ "file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> bp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar (Hacl.Impl.Frodo.Params.params_n a) -> bpp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar (Hacl.Impl.Frodo.Params.params_n a) -> c_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar Hacl.Impl.Frodo.Params.params_nbar -> cp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar Hacl.Impl.Frodo.Params.params_nbar -> FStar.HyperStack.ST.Stack Lib.IntTypes.uint16
{ "end_col": 10, "end_line": 166, "start_col": 72, "start_line": 163 }
FStar.HyperStack.ST.Stack
val crypto_kem_dec_mu: a:FP.frodo_alg -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h sk /\ live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\ loc_pairwise_disjoint [loc sk; loc mu_decode; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.crypto_kem_dec_mu a (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
[ { "abbrev": true, "full_module": "Spec.Matrix", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Frodo.KEM.Decaps", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Impl.Frodo.KEM.KeyGen", "short_module": "KG" }, { "abbrev": true, "full_module": "Spec.Frodo.Params", "short_module": "FP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Frodo.Random", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Sample", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Pack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Encode", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM.Encaps", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.Params", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "LowStar.Buffer", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Frodo.KEM", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let crypto_kem_dec_mu a sk bp_matrix c_matrix mu_decode = FP.expand_crypto_secretkeybytes a; let s_bytes = sub sk (crypto_bytes a +! crypto_publickeybytes a) (secretmatrixbytes_len a) in frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode
val crypto_kem_dec_mu: a:FP.frodo_alg -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h sk /\ live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\ loc_pairwise_disjoint [loc sk; loc mu_decode; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.crypto_kem_dec_mu a (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_mu a sk bp_matrix c_matrix mu_decode =
true
null
false
FP.expand_crypto_secretkeybytes a; let s_bytes = sub sk (crypto_bytes a +! crypto_publickeybytes a) (secretmatrixbytes_len a) in frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode
{ "checked_file": "Hacl.Impl.Frodo.KEM.Decaps.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "Spec.Frodo.Params.fst.checked", "Spec.Frodo.KEM.Decaps.fst.checked", "prims.fst.checked", "LowStar.Buffer.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Matrix.fst.checked", "Hacl.Impl.Frodo.Sample.fst.checked", "Hacl.Impl.Frodo.Params.fst.checked", "Hacl.Impl.Frodo.Pack.fst.checked", "Hacl.Impl.Frodo.KEM.KeyGen.fst.checked", "Hacl.Impl.Frodo.KEM.Encaps.fst.checked", "Hacl.Impl.Frodo.KEM.fst.checked", "Hacl.Impl.Frodo.Encode.fst.checked", "Hacl.Frodo.Random.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Frodo.KEM.Decaps.fst" }
[]
[ "Spec.Frodo.Params.frodo_alg", "Hacl.Impl.Matrix.lbytes", "Hacl.Impl.Frodo.Params.crypto_secretkeybytes", "Hacl.Impl.Matrix.matrix_t", "Hacl.Impl.Frodo.Params.params_nbar", "Hacl.Impl.Frodo.Params.params_n", "Hacl.Impl.Frodo.Params.bytes_mu", "Hacl.Impl.Frodo.KEM.Decaps.frodo_mu_decode", "Prims.unit", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Hacl.Impl.Frodo.Params.secretmatrixbytes_len", "Lib.Buffer.sub", "Lib.IntTypes.uint8", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Frodo.Params.crypto_bytes", "Hacl.Impl.Frodo.Params.crypto_publickeybytes", "Spec.Frodo.Params.expand_crypto_secretkeybytes" ]
[]
module Hacl.Impl.Frodo.KEM.Decaps open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open LowStar.Buffer open Lib.IntTypes open Lib.Buffer open Hacl.Impl.Matrix open Hacl.Impl.Frodo.Params open Hacl.Impl.Frodo.KEM open Hacl.Impl.Frodo.KEM.Encaps open Hacl.Impl.Frodo.Encode open Hacl.Impl.Frodo.Pack open Hacl.Impl.Frodo.Sample open Hacl.Frodo.Random module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module FP = Spec.Frodo.Params module KG = Hacl.Impl.Frodo.KEM.KeyGen module S = Spec.Frodo.KEM.Decaps module M = Spec.Matrix #set-options "--z3rlimit 100 --fuel 0 --ifuel 0" inline_for_extraction noextract val get_bp_c_matrices: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h ct /\ live h bp_matrix /\ live h c_matrix /\ disjoint bp_matrix ct /\ disjoint c_matrix ct /\ disjoint bp_matrix c_matrix) (ensures fun h0 _ h1 -> modifies (loc bp_matrix |+| loc c_matrix) h0 h1 /\ (as_matrix h1 bp_matrix, as_matrix h1 c_matrix) == S.get_bp_c_matrices a (as_seq h0 ct)) let get_bp_c_matrices a ct bp_matrix c_matrix = let c1 = sub ct 0ul (ct1bytes_len a) in let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in frodo_unpack params_nbar (params_n a) (params_logq a) c1 bp_matrix; frodo_unpack params_nbar params_nbar (params_logq a) c2 c_matrix inline_for_extraction noextract val frodo_mu_decode: a:FP.frodo_alg -> s_bytes:lbytes (secretmatrixbytes_len a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h s_bytes /\ live h bp_matrix /\ live h c_matrix /\ live h mu_decode /\ disjoint mu_decode s_bytes /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0)) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.frodo_mu_decode a (as_seq h0 s_bytes) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let frodo_mu_decode a s_bytes bp_matrix c_matrix mu_decode = push_frame(); let s_matrix = matrix_create (params_n a) params_nbar in let m_matrix = matrix_create params_nbar params_nbar in matrix_from_lbytes s_bytes s_matrix; matrix_mul_s bp_matrix s_matrix m_matrix; matrix_sub c_matrix m_matrix; frodo_key_decode (params_logq a) (params_extracted_bits a) params_nbar m_matrix mu_decode; clear_matrix s_matrix; clear_matrix m_matrix; pop_frame() inline_for_extraction noextract val get_bpp_cp_matrices_: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> sp_matrix:matrix_t params_nbar (params_n a) -> ep_matrix:matrix_t params_nbar (params_n a) -> epp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc sk; loc bpp_matrix; loc cp_matrix; loc sp_matrix; loc ep_matrix; loc epp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices_ a gen_a (as_seq h0 mu_decode) (as_seq h0 sk) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix) (as_matrix h0 epp_matrix)) let get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix = FP.expand_crypto_secretkeybytes a; FP.expand_crypto_publickeybytes a; let pk = sub sk (crypto_bytes a) (crypto_publickeybytes a) in let seed_a = sub pk 0ul bytes_seed_a in let b = sub pk bytes_seed_a (crypto_publickeybytes a -! bytes_seed_a) in frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bpp_matrix; frodo_mul_add_sb_plus_e_plus_mu a mu_decode b sp_matrix epp_matrix cp_matrix; mod_pow2 (params_logq a) bpp_matrix; mod_pow2 (params_logq a) cp_matrix #push-options "--z3rlimit 150" inline_for_extraction noextract val get_bpp_cp_matrices: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> cp_matrix:matrix_t params_nbar params_nbar -> Stack unit (requires fun h -> live h seed_se /\ live h mu_decode /\ live h sk /\ live h bpp_matrix /\ live h cp_matrix /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk; loc bpp_matrix; loc cp_matrix]) (ensures fun h0 _ h1 -> modifies (loc bpp_matrix |+| loc cp_matrix) h0 h1 /\ (as_matrix h1 bpp_matrix, as_matrix h1 cp_matrix) == S.get_bpp_cp_matrices a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk)) let get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix = push_frame (); let sp_matrix = matrix_create params_nbar (params_n a) in let ep_matrix = matrix_create params_nbar (params_n a) in let epp_matrix = matrix_create params_nbar params_nbar in get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix; get_bpp_cp_matrices_ a gen_a mu_decode sk bpp_matrix cp_matrix sp_matrix ep_matrix epp_matrix; clear_matrix3 a sp_matrix ep_matrix epp_matrix; pop_frame () #pop-options inline_for_extraction noextract val crypto_kem_dec_kp_s_cond: a:FP.frodo_alg -> bp_matrix:matrix_t params_nbar (params_n a) -> bpp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> cp_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h bp_matrix /\ live h bpp_matrix /\ live h c_matrix /\ live h cp_matrix) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s_cond a (as_matrix h0 bp_matrix) (as_matrix h0 bpp_matrix) (as_matrix h0 c_matrix) (as_matrix h0 cp_matrix)) let crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix = let b1 = matrix_eq bp_matrix bpp_matrix in let b2 = matrix_eq c_matrix cp_matrix in b1 &. b2 inline_for_extraction noextract val crypto_kem_dec_kp_s: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> mu_decode:lbytes (bytes_mu a) -> seed_se:lbytes (crypto_bytes a) -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> Stack uint16 (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se /\ live h c_matrix /\ live h sk /\ loc_pairwise_disjoint [loc mu_decode; loc seed_se; loc sk]) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.crypto_kem_dec_kp_s a gen_a (as_seq h0 mu_decode) (as_seq h0 seed_se) (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix = push_frame (); let bpp_matrix = matrix_create params_nbar (params_n a) in let cp_matrix = matrix_create params_nbar params_nbar in get_bpp_cp_matrices a gen_a mu_decode seed_se sk bpp_matrix cp_matrix; let mask = crypto_kem_dec_kp_s_cond a bp_matrix bpp_matrix c_matrix cp_matrix in pop_frame (); mask inline_for_extraction noextract val crypto_kem_dec_ss0: a:FP.frodo_alg -> ct:lbytes (crypto_ciphertextbytes a) -> mask:uint16{v mask == 0 \/ v mask == v (ones U16 SEC)} -> kp:lbytes (crypto_bytes a) -> s:lbytes (crypto_bytes a) -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h ct /\ live h kp /\ live h s /\ live h ss /\ disjoint ss ct /\ disjoint ss kp /\ disjoint ss s /\ disjoint kp s) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss0 a (as_seq h0 ct) mask (as_seq h0 kp) (as_seq h0 s)) let crypto_kem_dec_ss0 a ct mask kp s ss = push_frame (); let kp_s = create (crypto_bytes a) (u8 0) in Lib.ByteBuffer.buf_mask_select kp s (to_u8 mask) kp_s; let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in let ss_init = create ss_init_len (u8 0) in concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) kp_s ss_init; frodo_shake a ss_init_len ss_init (crypto_bytes a) ss; clear_words_u8 ss_init; clear_words_u8 kp_s; pop_frame () inline_for_extraction noextract val crypto_kem_dec_seed_se_k: a:FP.frodo_alg -> mu_decode:lbytes (bytes_mu a) -> sk:lbytes (crypto_secretkeybytes a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h sk /\ live h seed_se_k /\ disjoint mu_decode seed_se_k /\ disjoint sk seed_se_k) (ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\ as_seq h1 seed_se_k == S.crypto_kem_dec_seed_se_k a (as_seq h0 mu_decode) (as_seq h0 sk)) let crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k = push_frame (); let pkh_mu_decode_len = bytes_pkhash a +! bytes_mu a in let pkh_mu_decode = create pkh_mu_decode_len (u8 0) in let pkh = sub sk (crypto_secretkeybytes a -! bytes_pkhash a) (bytes_pkhash a) in concat2 (bytes_pkhash a) pkh (bytes_mu a) mu_decode pkh_mu_decode; frodo_shake a pkh_mu_decode_len pkh_mu_decode (2ul *! crypto_bytes a) seed_se_k; pop_frame () inline_for_extraction noextract val crypto_kem_dec_ss1: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> seed_se_k:lbytes (2ul *! crypto_bytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h seed_se_k /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc seed_se_k; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss1 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_seq h0 seed_se_k) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss = let seed_se = sub seed_se_k 0ul (crypto_bytes a) in let kp = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in let s = sub sk 0ul (crypto_bytes a) in let mask = crypto_kem_dec_kp_s a gen_a mu_decode seed_se sk bp_matrix c_matrix in crypto_kem_dec_ss0 a ct mask kp s ss inline_for_extraction noextract val crypto_kem_dec_ss2: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> ct:lbytes (crypto_ciphertextbytes a) -> sk:lbytes (crypto_secretkeybytes a) -> mu_decode:lbytes (bytes_mu a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> ss:lbytes (crypto_bytes a) -> Stack unit (requires fun h -> live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ live h sk /\ live h ct /\ live h ss /\ loc_pairwise_disjoint [loc ct; loc sk; loc mu_decode; loc bp_matrix; loc c_matrix; loc ss]) (ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\ as_seq h1 ss == S.crypto_kem_dec_ss2 a gen_a (as_seq h0 ct) (as_seq h0 sk) (as_seq h0 mu_decode) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix)) let crypto_kem_dec_ss2 a gen_a ct sk mu_decode bp_matrix c_matrix ss = push_frame (); let seed_se_k = create (2ul *! crypto_bytes a) (u8 0) in crypto_kem_dec_seed_se_k a mu_decode sk seed_se_k; crypto_kem_dec_ss1 a gen_a ct sk mu_decode seed_se_k bp_matrix c_matrix ss; clear_words_u8 seed_se_k; pop_frame () inline_for_extraction noextract val crypto_kem_dec_mu: a:FP.frodo_alg -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h sk /\ live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\ loc_pairwise_disjoint [loc sk; loc mu_decode; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.crypto_kem_dec_mu a (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
false
false
Hacl.Impl.Frodo.KEM.Decaps.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": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val crypto_kem_dec_mu: a:FP.frodo_alg -> sk:lbytes (crypto_secretkeybytes a) -> bp_matrix:matrix_t params_nbar (params_n a) -> c_matrix:matrix_t params_nbar params_nbar -> mu_decode:lbytes (bytes_mu a) -> Stack unit (requires fun h -> live h sk /\ live h mu_decode /\ live h bp_matrix /\ live h c_matrix /\ as_seq h (mu_decode) == Seq.create (v (bytes_mu a)) (u8 0) /\ loc_pairwise_disjoint [loc sk; loc mu_decode; loc bp_matrix; loc c_matrix]) (ensures fun h0 _ h1 -> modifies (loc mu_decode) h0 h1 /\ as_seq h1 mu_decode == S.crypto_kem_dec_mu a (as_seq h0 sk) (as_matrix h0 bp_matrix) (as_matrix h0 c_matrix))
[]
Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec_mu
{ "file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Decaps.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Frodo.Params.frodo_alg -> sk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_secretkeybytes a) -> bp_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar (Hacl.Impl.Frodo.Params.params_n a) -> c_matrix: Hacl.Impl.Matrix.matrix_t Hacl.Impl.Frodo.Params.params_nbar Hacl.Impl.Frodo.Params.params_nbar -> mu_decode: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 56, "end_line": 330, "start_col": 2, "start_line": 328 }